Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Build code from sources
- 2. Setup dockered roach:
- ```bash
- docker network create -d bridge roachnet_flyway
- docker run -d \
- --name=roach_flyway \
- --hostname=roach_flyway \
- --net=roachnet_flyway \
- -p 26258:26257 -p 8081:8080 \
- -v "${PWD}/cockroach-data/roach1:/cockroach/cockroach-data" \
- cockroachdb/cockroach:v1.1.3 start --insecure
- ```
- 3. Check roach status:
- ```bash
- docker run -it --rm --network=roachnet_flyway cockroachdb/cockroach:v1.1.3 sql --host=roach_flyway --insecure
- root@roach_flyway:26257/> show database;
- +----------+
- | database |
- +----------+
- | |
- +----------+
- (1 row)
- Time: 2.92223ms
- root@roach_flyway:26257/> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | crdb_internal |
- | information_schema |
- | pg_catalog |
- | system |
- +--------------------+
- (4 rows)
- Time: 3.59061ms
- root@roach_flyway:26257/>
- ```
- 4. Setup commandline tool (conf/flyway.conf):
- ```
- jdbc:postgresql://127.0.0.1:26258/?sslmode=disable
- flyway.schemas=mydatabase
- ```
- 5. Run migration `./flyway migrate`
- Flyway Open Source 0-SNAPSHOT by Boxfuse
- ```
- Database user: root
- Database password:
- Database: jdbc:postgresql://127.0.0.1:26258/ (PostgreSQL 9.5)
- Creating schema "mydatabase" ...
- Creating Schema History table: "mydatabase"."schema_version"
- Current version of schema "mydatabase": null
- Migrating schema "mydatabase" to version 1 - testmigration
- Successfully applied 1 migration to schema "mydatabase" (execution time 00:00.165s).
- ERROR:
- Error restoring current schema to its original setting
- ------------------------------------------------------
- SQL State : 42601
- Error Code : 0
- Message : ERROR: syntax error at or near "EOF"
- Detail: source SQL:
- SET database =
- ^
- Hint: try \h SET SESSION
- ```
- 6. Verify migrations:
- ```
- root@roach_flyway:26257/> show databases
- -> ;
- +--------------------+
- | Database |
- +--------------------+
- | crdb_internal |
- | information_schema |
- | mydatabase |
- | pg_catalog |
- | system |
- +--------------------+
- (5 rows)
- Time: 1.23419ms
- root@roach_flyway:26257/> select * from "mydatabase"."schema_version";
- +----------------+---------+------------------------------+--------+-----------------------+------------+--------------+----------------------------------+----------------+---------+
- | installed_rank | version | description | type | script | checksum | installed_by | installed_on | execution_time | success |
- +----------------+---------+------------------------------+--------+-----------------------+------------+--------------+----------------------------------+----------------+---------+
- | 0 | NULL | << Flyway Schema Creation >> | SCHEMA | "mydatabase" | NULL | root | 2017-12-02 16:29:53.671541+00:00 | 0 | true |
- | 1 | 1 | testmigration | SQL | V1__testmigration.sql | 2117869787 | root | 2017-12-02 16:29:54.216342+00:00 | 47 | true |
- +----------------+---------+------------------------------+--------+-----------------------+------------+--------------+----------------------------------+----------------+---------+
- (2 rows)
- Time: 25.137227ms
- ```
Add Comment
Please, Sign In to add comment