The exception chain was:
javax.servlet.ServletException:
Caused by: javax.persistence.PersistenceException:
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column ‘ID’, table ‘CDM_TRUVEN_CCAE_6k_V5_OHDSI.dbo.EXAMPLEAPP_WIDGET’; column does not allow nulls. INSERT fails.
Re: flyway logs. I just pushed a sql server specific migration update (version 1.0.0.2.1) to set the identity column (while persisting any existing data) and to not do anything at all if the column is already identity. Also droped the HIBERNATE_SEQUENCE table because I don’t think we need it (and only try to drop it if it exists).
As far as subsequent flyway migrations, I’m wondering if makes sense to approach database updates the same way as feature branches (assuming your feature requires db changes):
- Make your feature branch.
- Make a pull request out of the new branch. Put in the comments what the expected database changes are, and ‘claim’ a shema version number (I’d vote for a numbering scheme {major}.{minor}.{release}.{feature_id}. Include int his pull request a blank file with the associated schema revision number. (this is so that other devs working on other feature branches who also need schema changes can make a migration file name that doesn’t conflict)
- Start working on the feature, as more and more schema updates are made, the developer with the feature branch will need to remember to delete the schema_version row for this feature so that all the database changes are up to date between pulls. Make the migration script idempotent so that you don’t have to rollback all the current feature branch schema changes just to ‘ammend’ the new ones.
- Once the feature branch is complete, and it gets merged in, the single feature ddl script will be folded into master, and other devs will only see 1 schema migration update for the new feature. I think this is better than having multiple files.
So, I sorta demonstrated this with my most recent checkin (introduced a new migration version 1.0.0.2.1 to address this update and made it re-runnable). THere are 2 units of work in this 1 migration script: migrate the ID column to identity(1,1) and drop the hibernte_sequence table. For feature branches like the cohort definition tables that me and Charity will work on, i’ll put that under 1.0.0.2.2 (or 1.0.0.3.1 of we think this is a different release…version numbering schemes are very stylistic…)
One last thing: I also enabled ‘out of order’ migrations to be ready for when feature branches do come in at any order, we will be able to apply the migration scripts.
Here’s the article I read about this technique:
-Chris