Goose wraps each migration in a transaction automatically. Explicit BEGIN TRANSACTION/COMMIT caused a nested transaction error in SQLite.
22 lines
433 B
SQL
22 lines
433 B
SQL
-- +goose Up
|
|
PRAGMA foreign_keys = OFF;
|
|
|
|
CREATE TABLE user_new (
|
|
id TEXT PRIMARY KEY,
|
|
username TEXT NOT NULL UNIQUE,
|
|
password_hash TEXT NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
INSERT INTO user_new (id, username, password_hash, created_at)
|
|
SELECT id, username, password_hash, created_at
|
|
FROM user;
|
|
|
|
DROP TABLE user;
|
|
|
|
ALTER TABLE user_new RENAME TO user;
|
|
|
|
PRAGMA foreign_keys = ON;
|
|
|
|
-- +goose Down
|