Skip to content

Migration to add a RowVersion column to an existing Sqlite table #98

Closed Answered by mythz
spabd asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah migrate only adds/removes/renames columns, it doesn't add the triggers at table creation time.

You can create the SQLite's RowVersion trigger with something like:

// Up
Db.ExecuteSql(Db.GetDialectProvider().ToPostCreateTableStatement(typeof(DatabaseVersion).GetModelMetadata()));

// Down
Db.ExecuteSql(Db.GetDialectProvider().ToPostDropTableStatement(typeof(DatabaseVersion).GetModelMetadata()));

Note the way you're using migrations wont let you rollback, revert, etc. as you should be doing compensatory logic in your Down() method and I'd avoid using defensive logic and APIs in your implementations to ensure the migrations are being run in the correct state and order, i.e. if the table…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by spabd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants