Open SEAPUNK opened 8 years ago
now the question here is:
what do you do if there is no schema_migrations
table?
A: do not do anything, just exit out with an error
have multiple commands to resolve this:
grater init new
- creates the new database with the new schema and seeds (if database exists, require the --drop-existing
flag)grater init fresh
- just creates the schema_migrations table, and populates it with the current migrations, to indicate that the current database is already completely migratedgrater init stale
- creates the schema_migrations table, and then runs migrations. --interactive
indicates that the user wants to choose which migrations to run, mark as completed without running, or skip.should migrations have a "check" function, to make sure that the migration is applicable?
mmmmmaybe. i'll think about it when the time comes to consider it
database initialization:
/schema.sql
or/schema/
directory (schema .sql files are executed in alphabetic order)/seeds.sql
or/seeds/
directory (alphabetic order)migrations:
/migrations/
folder, format isTIMESTAMP_NAME.sql
TIMESTAMP
is the current UTC time, inYYYYMMDDHHMMSS
, like Rails' ActiveMigrationTIMESTAMP
is also essentially the id of the migration, so there cannot be multiple migrations with the same timestampNAME
is the description of the migration (no format in particular)schema_migrations
table of the databasegrater migrate [TIMESTAMP]
- migrates schemas. runs all migrations that have not been run (load schema_migrations folder). if timestamp is provided, then that specific migration is run (and error thrown if grater notices that the migration has been run before, saying you gotta run it with--force
)