sqldb: add table to track custom SQL migrations
This commit adds the migration_tracker table which we'll use to track if a custom migration has already been done.
This commit is contained in:
6 files changed
+108
No files matched your search
@@ -0,0 +1,17 @@
|
||||
-- The migration_tracker table keeps track of migrations that have been applied
|
||||
-- to the database. This table ensures that migrations are idempotent and are
|
||||
-- only run once. It tracks a global database version that encompasses both
|
||||
-- schema migrations handled by golang-migrate and custom in-code migrations
|
||||
-- for more complex data conversions that cannot be expressed in pure SQL.
|
||||
CREATE TABLE IF NOT EXISTS migration_tracker (
|
||||
-- version is the global version of the migration. Note that we
|
||||
-- intentionally don't set it as PRIMARY KEY as it'd auto increment on
|
||||
-- SQLite and our sqlc workflow will replace it with an auto
|
||||
-- incrementing SERIAL on Postgres too. UNIQUE achieves the same effect
|
||||
-- without the auto increment.
|
||||
version INTEGER UNIQUE NOT NULL,
|
||||
|
||||
-- migration_time is the timestamp at which the migration was run.
|
||||
migration_time TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user