Neon-readme-13.sh
· 1.6 KiB · Bash
Brut
# create branch named migration_check
> cargo neon timeline branch --branch-name migration_check
Created timeline 'b3b863fa45fa9e57e615f9f2d944e601' at Lsn 0/16F9A00 for tenant: 9ef87a5bf0d92544f6fafeeb3239695c. Ancestor timeline: 'main'
# check branches tree
> cargo neon timeline list
(L) main [de200bd42b49cc1814412c7e592dd6e9]
(L) ┗━ @0/16F9A00: migration_check [b3b863fa45fa9e57e615f9f2d944e601]
# create postgres on that branch
> cargo neon endpoint create migration_check --branch-name migration_check
# start postgres on that branch
> cargo neon endpoint start migration_check
Starting new endpoint migration_check (PostgreSQL v14) on timeline b3b863fa45fa9e57e615f9f2d944e601 ...
Starting postgres at 'postgresql://cloud_admin@127.0.0.1:55434/postgres'
# check the new list of running postgres instances
> cargo neon endpoint list
ENDPOINT ADDRESS TIMELINE BRANCH NAME LSN STATUS
main 127.0.0.1:55432 de200bd42b49cc1814412c7e592dd6e9 main 0/16F9A38 running
migration_check 127.0.0.1:55434 b3b863fa45fa9e57e615f9f2d944e601 migration_check 0/16F9A70 running
# this new postgres instance will have all the data from 'main' postgres,
# but all modifications would not affect data in original postgres
> psql -p 55434 -h 127.0.0.1 -U cloud_admin postgres
postgres=# select * from t;
key | value
-----+-------
1 | 1
(1 row)
postgres=# insert into t values(2,2);
INSERT 0 1
# check that the new change doesn't affect the 'main' postgres
> psql -p 55432 -h 127.0.0.1 -U cloud_admin postgres
postgres=# select * from t;
key | value
-----+-------
1 | 1
(1 row)
1 | # create branch named migration_check |
2 | > cargo neon timeline branch --branch-name migration_check |
3 | Created timeline 'b3b863fa45fa9e57e615f9f2d944e601' at Lsn 0/16F9A00 for tenant: 9ef87a5bf0d92544f6fafeeb3239695c. Ancestor timeline: 'main' |
4 | |
5 | # check branches tree |
6 | > cargo neon timeline list |
7 | (L) main [de200bd42b49cc1814412c7e592dd6e9] |
8 | (L) ┗━ @0/16F9A00: migration_check [b3b863fa45fa9e57e615f9f2d944e601] |
9 | |
10 | # create postgres on that branch |
11 | > cargo neon endpoint create migration_check --branch-name migration_check |
12 | |
13 | # start postgres on that branch |
14 | > cargo neon endpoint start migration_check |
15 | Starting new endpoint migration_check (PostgreSQL v14) on timeline b3b863fa45fa9e57e615f9f2d944e601 ... |
16 | Starting postgres at 'postgresql://cloud_admin@127.0.0.1:55434/postgres' |
17 | |
18 | # check the new list of running postgres instances |
19 | > cargo neon endpoint list |
20 | ENDPOINT ADDRESS TIMELINE BRANCH NAME LSN STATUS |
21 | main 127.0.0.1:55432 de200bd42b49cc1814412c7e592dd6e9 main 0/16F9A38 running |
22 | migration_check 127.0.0.1:55434 b3b863fa45fa9e57e615f9f2d944e601 migration_check 0/16F9A70 running |
23 | |
24 | # this new postgres instance will have all the data from 'main' postgres, |
25 | # but all modifications would not affect data in original postgres |
26 | > psql -p 55434 -h 127.0.0.1 -U cloud_admin postgres |
27 | postgres=# select * from t; |
28 | key | value |
29 | -----+------- |
30 | 1 | 1 |
31 | (1 row) |
32 | |
33 | postgres=# insert into t values(2,2); |
34 | INSERT 0 1 |
35 | |
36 | # check that the new change doesn't affect the 'main' postgres |
37 | > psql -p 55432 -h 127.0.0.1 -U cloud_admin postgres |
38 | postgres=# select * from t; |
39 | key | value |
40 | -----+------- |
41 | 1 | 1 |
42 | (1 row) |