mirror of
https://github.com/harness/drone.git
synced 2025-05-05 15:32:56 +00:00
chore: [CODE-3779]: add index for migrations table (#3742)
This commit is contained in:
parent
f296f1c37d
commit
0d51e10332
@ -0,0 +1,2 @@
|
||||
-- primary key is required by some database tools and dependencies.
|
||||
ALTER TABLE migrations ADD PRIMARY KEY (version);
|
@ -0,0 +1,16 @@
|
||||
-- primary key is required by some database tools and dependencies.
|
||||
-- 1. Create a new table with primary key
|
||||
CREATE TABLE migrations_with_primary_key (
|
||||
version TEXT PRIMARY KEY
|
||||
);
|
||||
|
||||
-- 2. Copy data (without this step, the new migration table would be empty after startup on a fresh db)
|
||||
INSERT INTO migrations_with_primary_key(version)
|
||||
SELECT version
|
||||
FROM migrations;
|
||||
|
||||
-- 3. Drop the old table
|
||||
DROP TABLE migrations;
|
||||
|
||||
-- 4. Rename the new table
|
||||
ALTER TABLE migrations_with_primary_key RENAME TO migrations;
|
Loading…
x
Reference in New Issue
Block a user