You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added create-migration command line instruction (#943)
* Added create-migration command line instruction
This update adds a command line interface to create migrations directly with sqlpage, and have it manage the timestamps and uniqueness of migration names.
* Update sqlpage/migrations/README.md
Co-authored-by: Ophir LOJKINE <[email protected]>
* Update sqlpage/migrations/README.md
Co-authored-by: Ophir LOJKINE <[email protected]>
* Updated with changes for config directory, migration output
Now respects the configuration_directory environment variable.
It also outputs the path of the new migration created when it is created, and takes care to display that path relative to the current working directory.
Lastly, the execution of create-migration command was moved above the rest of the initialization, so that creating a new migration does not run existing migrations. This allows you to create multiple migrations before you run sqlpage normally again to execute them.
---------
Co-authored-by: Ophir LOJKINE <[email protected]>
Copy file name to clipboardExpand all lines: sqlpage/migrations/README.md
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,13 @@ that is greater than the previous one.
21
21
Use commands like `ALTER TABLE` to update the schema declaratively instead of modifying the existing `CREATE TABLE`
22
22
statements.
23
23
24
-
If you try to edit an existing migration, SQLPage will not run it again, will detect
24
+
If you try to edit an existing migration, SQLPage will not run it again, it will detect that the migration has already executed. Also, if the migration is different than the one that was executed, SQLPage will throw an error as the database structure must match.
25
+
26
+
## Creating migrations on the command line
27
+
28
+
You can create a migration directly with sqlpage by running the command `sqlpage create-migration [migration_name]`
29
+
30
+
For example if you run `sqlpage create-migration "Example Migration 1"` on the command line, you will find a new file under the `sqlpage/migrations` folder called `[timestamp]_example_migration_1.sql` where timestamp is the current time when you ran the command.
0 commit comments