Skip to content
Permalink
Browse files

Add flyway database versioning

refs #12256
  • Loading branch information...
KevinCaseiras authored and stouffers committed Jan 15, 2019
1 parent a379d9b commit ea216dacad564a6ce402463a6beea3d1eed21f93
Showing with 47 additions and 1,004 deletions.
  1. +1 −0 .gitignore
  2. +3 −3 docs/backend/index.md
  3. +17 −0 pom.xml
  4. +25 −0 src/main/resources/flyway.conf.example
  5. 0 src/main/resources/sql/{patches/xml → }/2018-11-16.rule_sponsor_fix.sql
  6. +1 −1 src/main/resources/sql/delete_sobi_data.sql
  7. 0 src/main/resources/sql/{openleg.db-init.sql → migrations/V1__openleg.db-init.sql}
  8. 0 ...018-07-02.log_bill_updates_cleanup.sql → migrations/V20180702.0000__log_bill_updates_cleanup.sql}
  9. 0 ...l/{patches/2018-12-18.request_time_index.sql → migrations/V20181218.0000__request_time_index.sql}
  10. 0 src/main/resources/sql/{openleg.schema.sql → migrations/V2__openleg.schema.sql}
  11. 0 src/main/resources/sql/{openleg.data.sql → migrations/V3__openleg.data.sql}
  12. +0 −4 src/main/resources/sql/patches/2017-08-14.law_tree_index.sql
  13. +0 −4 src/main/resources/sql/patches/2017-10-20.agenda_bill_mismatch_name_change.sql
  14. +0 −181 src/main/resources/sql/patches/2018-01-03.remove_cascades.sql
  15. +0 −45 src/main/resources/sql/patches/2018-01-17.bill_text_alternate.sql
  16. +0 −184 src/main/resources/sql/patches/2018-04-25.xml_log_table_trigger_update.sql
  17. +0 −14 src/main/resources/sql/patches/2018-05-04. sobi_fragment_process_start.sql
  18. +0 −196 src/main/resources/sql/patches/2018-05-04a.change_log_delete_src.sql
  19. +0 −18 src/main/resources/sql/patches/2018-05-10.bill_scrape_refactor.sql
  20. +0 −184 src/main/resources/sql/patches/xml/2017-04-26.xml_log_table_trigger_update.sql
  21. +0 −1 src/main/resources/sql/patches/xml/2017-06-14.billblurb.sql
  22. +0 −1 src/main/resources/sql/patches/xml/2017-09-26.reprint.sql
  23. +0 −10 src/main/resources/sql/patches/xml/2017-10-31T111500.reprint_rename.sql
  24. +0 −6 src/main/resources/sql/patches/xml/2018-05-09.bill_amendment_full_text_html.sql
  25. +0 −2 src/main/resources/sql/qa-redesign/calendar-type-refactor_3.sql
  26. +0 −9 src/main/resources/sql/qa-redesign/mismatch-first-seen-date_4.sql
  27. +0 −19 src/main/resources/sql/qa-redesign/mismatch-refactor-status_2.sql
  28. +0 −122 src/main/resources/sql/qa-redesign/mismatch-refactor_1.sql
@@ -25,3 +25,4 @@ build
src/test/java/gov/nysenate/openleg/SillyTests.java

grunt.properties.json
src/main/resources/flyway.conf
@@ -16,9 +16,9 @@
1. Create the database (in `psql` or your preferred client). `CREATE DATABASE openleg;`
1. Connect to the openleg database. `\c openleg`
1. Run the following scripts in order (`\i script_name` in `psql`)
1. `openleg.db-init.sql`
1. `openleg.schema.sql`
1. `openleg.data.sql`
1. `V1__openleg.db-init.sql`
1. `V2__openleg.schema.sql`
1. `V3__openleg.data.sql`

### Create Login User and Grant Permissions

17 pom.xml
@@ -80,6 +80,23 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>5.2.4</version>
<configuration>
<configFile>src/main/resources/flyway.conf</configFile>
</configuration>
<executions>
<execution>
<id>flyway-migrate</id>
<phase>pre-integration-test</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

@@ -0,0 +1,25 @@
#Flyway config docs: https://flywaydb.org/documentation/configfiles

# JDBC url to use to connect to the database
flyway.url = jdbc:postgresql://localhost:5432/openleg

# Database user
flyway.user = postgres

# Database user password
flyway.password =

# Schemas managed by flyway
flyway.schemas = public, master

# Version set when using flyway:baseline
flyway.baselineVersion = 20181218.0000

# Location of migration scripts
flyway.locations = classpath:sql/migrations

# Allow execution of migration scripts with version before current version
flyway.outOfOrder = true

# Whether to allow mixing transactional and non-transactional statements within the same migration.
flyway.mixed = true
@@ -11,7 +11,7 @@ TRUNCATE calendar_change_log;
TRUNCATE bill_change_log;
TRUNCATE agenda_change_log;

-- Delete committees and committee versions generated by SOBI data, leaving only those initialized from openleg.data.sql
-- Delete committees and committee versions generated by SOBI data, leaving only those initialized from V3__openleg.data.sql
-- TODO change this when committee data model has been fixed
DELETE FROM master.committee_version WHERE last_fragment_id IS NOT NULL OR created > '2013-01-01';
UPDATE master.committee_version SET reformed = 'infinity';
File renamed without changes.
File renamed without changes.
File renamed without changes.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit ea216da

Please sign in to comment.
You can’t perform that action at this time.