parent
2bad759547
commit
c18098cb8a
24
migrations/20210401070030_on_delete_cascade.sql
Normal file
24
migrations/20210401070030_on_delete_cascade.sql
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
-- Add migration script here
|
||||||
|
PRAGMA foreign_keys = off;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE new_clicks (
|
||||||
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
|
link INT NOT NULL,
|
||||||
|
created_at TIMESTAMP NOT NULL,
|
||||||
|
FOREIGN KEY (link) REFERENCES links (id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO
|
||||||
|
new_clicks
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
clicks;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE clicks;
|
||||||
|
ALTER TABLE
|
||||||
|
new_clicks RENAME TO clicks;
|
||||||
|
|
||||||
|
PRAGMA foreign_keys = on;
|
Loading…
Reference in New Issue
Block a user