Guest User

Untitled

a guest
Dec 4th, 2017
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. 1. Build code from sources
  2.  
  3. 2. Setup dockered roach:
  4.  
  5. ```bash
  6. docker network create -d bridge roachnet_flyway
  7.  
  8. docker run -d \
  9. --name=roach_flyway \
  10. --hostname=roach_flyway \
  11. --net=roachnet_flyway \
  12. -p 26258:26257 -p 8081:8080 \
  13. -v "${PWD}/cockroach-data/roach1:/cockroach/cockroach-data" \
  14. cockroachdb/cockroach:v1.1.3 start --insecure
  15. ```
  16.  
  17. 3. Check roach status:
  18.  
  19. ```bash
  20. docker run -it --rm --network=roachnet_flyway cockroachdb/cockroach:v1.1.3 sql --host=roach_flyway --insecure
  21.  
  22. root@roach_flyway:26257/> show database;
  23. +----------+
  24. | database |
  25. +----------+
  26. | |
  27. +----------+
  28. (1 row)
  29.  
  30. Time: 2.92223ms
  31.  
  32. root@roach_flyway:26257/> show databases;
  33. +--------------------+
  34. | Database |
  35. +--------------------+
  36. | crdb_internal |
  37. | information_schema |
  38. | pg_catalog |
  39. | system |
  40. +--------------------+
  41. (4 rows)
  42.  
  43. Time: 3.59061ms
  44.  
  45. root@roach_flyway:26257/>
  46. ```
  47.  
  48. 4. Setup commandline tool (conf/flyway.conf):
  49. ```
  50. jdbc:postgresql://127.0.0.1:26258/?sslmode=disable
  51. flyway.schemas=mydatabase
  52. ```
  53.  
  54. 5. Run migration `./flyway migrate`
  55.  
  56. Flyway Open Source 0-SNAPSHOT by Boxfuse
  57. ```
  58. Database user: root
  59. Database password:
  60. Database: jdbc:postgresql://127.0.0.1:26258/ (PostgreSQL 9.5)
  61. Creating schema "mydatabase" ...
  62. Creating Schema History table: "mydatabase"."schema_version"
  63. Current version of schema "mydatabase": null
  64. Migrating schema "mydatabase" to version 1 - testmigration
  65. Successfully applied 1 migration to schema "mydatabase" (execution time 00:00.165s).
  66. ERROR:
  67. Error restoring current schema to its original setting
  68. ------------------------------------------------------
  69. SQL State : 42601
  70. Error Code : 0
  71. Message : ERROR: syntax error at or near "EOF"
  72. Detail: source SQL:
  73. SET database =
  74. ^
  75. Hint: try \h SET SESSION
  76. ```
  77.  
  78. 6. Verify migrations:
  79.  
  80. ```
  81. root@roach_flyway:26257/> show databases
  82. -> ;
  83. +--------------------+
  84. | Database |
  85. +--------------------+
  86. | crdb_internal |
  87. | information_schema |
  88. | mydatabase |
  89. | pg_catalog |
  90. | system |
  91. +--------------------+
  92. (5 rows)
  93.  
  94. Time: 1.23419ms
  95.  
  96.  
  97. root@roach_flyway:26257/> select * from "mydatabase"."schema_version";
  98. +----------------+---------+------------------------------+--------+-----------------------+------------+--------------+----------------------------------+----------------+---------+
  99. | installed_rank | version | description | type | script | checksum | installed_by | installed_on | execution_time | success |
  100. +----------------+---------+------------------------------+--------+-----------------------+------------+--------------+----------------------------------+----------------+---------+
  101. | 0 | NULL | << Flyway Schema Creation >> | SCHEMA | "mydatabase" | NULL | root | 2017-12-02 16:29:53.671541+00:00 | 0 | true |
  102. | 1 | 1 | testmigration | SQL | V1__testmigration.sql | 2117869787 | root | 2017-12-02 16:29:54.216342+00:00 | 47 | true |
  103. +----------------+---------+------------------------------+--------+-----------------------+------------+--------------+----------------------------------+----------------+---------+
  104. (2 rows)
  105.  
  106. Time: 25.137227ms
  107. ```
Add Comment
Please, Sign In to add comment