-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linked QL migrations are a small addition to Linked QL. And it comes ready-to-use, via the linkedql
command, upon Linked QL's installation. (No extra setup is required.)
The linkedql
command comes as part of your local Linked QL installation and not as a global package, and that means you'll need the npx
prefix to run the commands below. E.g.
npx linkedql commit
On each command, you can use the --dir
flag to point Linked QL to your "database" directory (where you have your schema.json
and driver.js
files), that's if you have chosen a different location other than ./database
:
npx linkedql commit --dir="./src/database-stuff"
(Relative paths will resolve against your current working directory (CWD).)
To run a command for a specific database out of your list of databases, use the --db
flag:
npx linkedql commit --db=database_1
To turn off prompts and get Linked QL to just take the "sensible-default" action, use the flag --auto
:
npx linkedql commit --auto
Note that as of
@linked-db/linked-ql@0.11.0
, the following commandsforget
,leaderboard
,migr ate
have been depreciated in favour ofclear-histories
,state
,commit
respectively, and a new commandgenerate
introduced.
Interactively commit your schema changes against your DB. Linked QL looks through your local schema and compares with your active DB structure to see what's new. It works interactively by default and you're able to preview each SQL query to be run.
🐹 Usage:
npx linkedql commit
npx linkedql commit --db=database_1
Use the --desc
flag to provide the description for your new changes:
npx linkedql commit --desc="Initial DB creation"
Use the flag --quiet
to turn off SQL previews:
npx linkedql commit --quiet
Interactively perform a rollback. Linked QL looks for the next savepoint at each database and initiates a rollback. It works interactively by default and you're able to preview each SQL query to be run.
🐹 Usage:
npx linkedql rollback
npx linkedql rollback --db=database_1
Use the --direction
flag to specify either a "backward" rollback (the default) or a "forward" rollback if already at a certain rollback state:
npx linkedql rollback --direction=forward
Use the flag --quiet
to turn off SQL previews:
npx linkedql migrate --quiet
View the state of each database. Linked QL displays details about the latest savepoint at each database.
🐹 Usage:
npx linkedql state
npx linkedql state --db=database_1
Use the flag --direction
to specify either a "back in time" lookup (the default) or "forward in time" lookup if already at a certain rollback state:
npx linkedql state --direction=forward
Refresh local schema file. Linked QL regenerates the schema from current DB structure for each database it has managed; refreshes local copy.
🐹 Usage:
npx linkedql refresh
npx linkedql refresh --db=database_1
Same as linkedql generate
, except that it will also eagerly generate the schema for an explicitly-named DB that has not been managed by Linked QL.
🐹 Usage:
npx linkedql generate
npx linkedql generate --db=database_1
Permanently erase savepoint histories. Linked QL deletes the savepoint history of all databases, or a specific database from the --db
flag. This is irreversible.
🐹 Usage:
npx linkedql clear-histories
npx linkedql clear-histories --db=database_1