ALTER TABLE gamenight RENAME TO _gamenight_old; CREATE TABLE gamenight ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, game text TEXT NOT NULL, datetime TEXT NOT NULL, owner_id INTEGER NOT NULL, CONSTRAINT FK_OwnerId FOREIGN KEY (owner_id) REFERENCES user(id) ON DELETE CASCADE ); PRAGMA foreign_keys=off; INSERT INTO gamenight (id, game, datetime, owner_id) select id, game, datetime, -1 FROM _gamenight_old; drop table _gamenight_old; PRAGMA foreign_keys=on;