@@ -28,14 +28,130 @@ import { PostgresMigrate } "https://raw.githubusercontent.com/udibo/migrate/0.2.
2828
2929## Usage
3030
31- ### CLI (TODO)
31+ ### CLI
3232
3333To use the command line interface, you must create a script that will initialize
34- the Migrate instance and call the run command from [cli.ts](cli.ts).
34+ the Migrate instance and call the run command from [cli.ts](cli.ts). An example
35+ can be found [here](#postgres-cli).
3536
3637See [deno docs](https://doc.deno.land/https/deno.land/x/migrate@0.2.0/cli.ts)
3738for more information.
3839
40+ #### Command: init
41+
42+ Initializes the migration table for tracking which migrations have been applied.
43+
44+ ` ` `
45+ $ ./migrate .ts init
46+ Connecting to database
47+ Creating migration table if it does not exist
48+ Created migration table
49+ ` ` `
50+
51+ #### Command: load
52+
53+ Loads all migrations current path values into the migration table.
54+
55+ ` ` `
56+ $ ./migrate .ts load
57+ Connecting to database
58+ Acquiring migrate lock
59+ Acquired migrate lock
60+ Loading migrations
61+ 2 new migrations found
62+ 1 migration updated
63+ No migrations deleted
64+ Releasing migrate lock
65+ Released migrate lock
66+ Done
67+ ` ` `
68+
69+ #### Command: status
70+
71+ Outputs the status of all migrations. By default it just outputs the counts.
72+
73+ ` ` `
74+ $ ./migrate .ts status
75+ Connecting to database
76+ Checking loaded migrations
77+ Status :
78+ Total : 5
79+ Applied : 4
80+ File moved : 1
81+ File deleted : 1
82+ Not applied : 1
83+ ` ` `
84+
85+ If the --details or -d flag is provided, it will log the filenames of migrations
86+ that have not been applied or have been changed since being applied.
87+
88+ ` ` `
89+ $ ./migrate .ts status --details
90+ Connecting to database
91+ Checking loaded migrations
92+ Status :
93+ Total : 5
94+ Applied : 4
95+ File moved : 1
96+ 2_user_add_kyle .sql -> 2_user_add_kyle .ts
97+ File deleted : 1
98+ 3_user_add_staff .sql
99+ Not applied : 1
100+ 4_user_add_column_email .sql
101+ ` ` `
102+
103+ #### Command: list
104+
105+ Outputs a list of migrations. By default it outputs all migrations.
106+
107+ ` ` `
108+ $ ./migrate .ts list
109+ Connecting to database
110+ Checking loaded migrations
111+ All migrations :
112+ 0_user_create .sql
113+ applied at : Tue Nov 09 2021 12:10:32 GMT -0600 (Central Standard Time )
114+ 1_user_add_admin .sql
115+ applied at : Wed Nov 11 2021 18:31:08 GMT -0600 (Central Standard Time )
116+ 2_user_add_kyle .sql
117+ applied at : Sat Nov 13 2021 05:31:08 GMT -0600 (Central Standard Time )
118+ file moved to : 2_user_add_kyle .ts
119+ 3_user_add_staff .sql
120+ applied at : Mon Nov 15 2021 15:31:08 GMT -0600 (Central Standard Time )
121+ file deleted
122+ 4_user_add_column_email .sql
123+ not applied
124+ ` ` `
125+
126+ If the --filter flag is provided, it will filter the migrations to only include
127+ migrations that match the filter. The filter options are applied, unapplied,
128+ renamed, and deleted.
129+
130+ ` ` `
131+ $ ./migrate .ts list --filter =unapplied
132+ Unapplied migrations :
133+ 4_user_add_column_email .sql
134+ ` ` `
135+
136+ #### Command: apply
137+
138+ Applies all unapplied migrations and outputs the filenames.
139+
140+ ` ` `
141+ $ ./migrate .ts apply
142+ Connecting to database
143+ Acquiring migrate lock
144+ Acquired migrate lock
145+ Checking loaded migrations
146+ 2 unapplied migrations
147+ Applying migration : 0_user_create .sql
148+ Applying migration : 1_user_add_column_email .sql
149+ Finished applying all migrations
150+ Releasing migrate lock
151+ Released migrate lock
152+ Done
153+ ` ` `
154+
39155### Postgres
40156
41157Examples of how to use migrate with postgres can be found
@@ -51,8 +167,8 @@ for more information.
51167
52168A basic migrate script that will apply all unapplied migrations.
53169
54- To use this script, copy [migrate .ts](examples/postgres/migrate .ts) and update
55- it with your migrate configuration.
170+ To use this script, copy [migrate_basic .ts](examples/postgres/migrate_basic .ts)
171+ and update it with your migrate configuration.
56172
57173` ` `
58174$ ./migrate_basic .ts
@@ -72,16 +188,21 @@ Released advisory lock
72188Done
73189` ` `
74190
75- #### Postgres CLI (TODO)
191+ #### Postgres CLI
76192
77193A CLI for the migration tool.
78194
79- To use this script, copy [migrate_basic .ts](examples/postgres/migrate_basic .ts)
80- and update it with your migrate configuration.
195+ To use this script, copy [migrate .ts](examples/postgres/migrate .ts) and update
196+ it with your migrate configuration.
81197
82- ` ` ` sh
198+ ` ` `
83199$ ./migrate .ts status
84- # TODO
200+ Connecting to database
201+ Checking loaded migrations
202+ Status :
203+ Total : 5
204+ Applied : 4
205+ Not applied : 1
85206` ` `
86207
87208See [CLI](#cli) for more information about available CLI commands.
0 commit comments