|
1 | 1 | --- |
2 | 2 | title: Latest |
3 | | -description: Prints the latest schema version or migration name in either the target database or a local directory of migration files. |
| 3 | +description: Prints information about the latest migration in either the target database or a local directory of migration files. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | ## Command |
7 | 7 |
|
8 | | -The `pgroll latest` command has two subcommands: |
| 8 | +The `pgroll latest` command has three subcommands: |
9 | 9 |
|
10 | | -- `pgroll latest schema` - prints the latest version schema name |
11 | | -- `pgroll latest migration` - prints the latest migration name |
| 10 | +- [`pgroll latest schema`](./latest-schema) - prints the latest version schema name |
| 11 | +- [`pgroll latest migration`](./latest-migration) - prints the latest migration name |
| 12 | +- [`pgroll latest url`](./latest-url) - prints a database connection URL for the latest schema version |
12 | 13 |
|
13 | | -Both subcommands support the `--local` flag to retrieve the latest version from a local directory of migration files instead of the target database. |
14 | | - |
15 | | -### Schema Command |
16 | | - |
17 | | -#### Database |
18 | | - |
19 | | -Assuming that the [example migrations](https://github.com/xataio/pgroll/tree/main/examples) have been applied to the `public` schema in the target database, running: |
20 | | - |
21 | | -``` |
22 | | -$ pgroll latest schema |
23 | | -``` |
24 | | - |
25 | | -will print the latest schema version in the target database: |
26 | | - |
27 | | -``` |
28 | | -public_55_add_primary_key_constraint_to_table |
29 | | -``` |
30 | | - |
31 | | -#### Local |
32 | | - |
33 | | -Assuming that the [example migrations](https://github.com/xataio/pgroll/tree/main/examples) are on disk in a directory called `examples`, running: |
34 | | - |
35 | | -``` |
36 | | -$ pgroll latest schema --local examples/ |
37 | | -``` |
38 | | - |
39 | | -will print the latest schema version in the directory: |
40 | | - |
41 | | -``` |
42 | | -public_55_add_primary_key_constraint_to_table |
43 | | -``` |
44 | | - |
45 | | -The exact outputs will vary as the `examples/` directory is updated. |
46 | | - |
47 | | -### Migration Command |
48 | | - |
49 | | -#### Database |
50 | | - |
51 | | -Assuming that the [example migrations](https://github.com/xataio/pgroll/tree/main/examples) have been applied to the `public` schema in the target database, running: |
52 | | - |
53 | | -``` |
54 | | -$ pgroll latest migration |
55 | | -``` |
56 | | - |
57 | | -will print the latest migration name in the target database: |
58 | | - |
59 | | -``` |
60 | | -55_add_primary_key_constraint_to_table |
61 | | -``` |
62 | | - |
63 | | -#### Local |
64 | | - |
65 | | -Assuming that the [example migrations](https://github.com/xataio/pgroll/tree/main/examples) are on disk in a directory called `examples`, running: |
66 | | - |
67 | | -``` |
68 | | -$ pgroll latest migration --local examples/ |
69 | | -``` |
70 | | - |
71 | | -will print the latest migration name in the directory: |
72 | | - |
73 | | -``` |
74 | | -55_add_primary_key_constraint_to_table |
75 | | -``` |
76 | | - |
77 | | -The exact outputs will vary as the `examples/` directory is updated. |
| 14 | +All subcommands support the `--local` flag to retrieve information from a local directory of migration files instead of the target database. |
0 commit comments