fix: title_messages schema to fix on conflict insertion
This commit is contained in:
32
drizzle/0007_warm_alex_wilder.sql
Normal file
32
drizzle/0007_warm_alex_wilder.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
You're trying to delete PRIMARY KEY(message_id,title_id) from 'title_messages' table
|
||||
SQLite does not supportprimary key deletion from existing table
|
||||
You can do it in 3 steps with drizzle orm:
|
||||
- create new mirror table table without pk, rename current table to old_table, generate SQL
|
||||
- migrate old data from one table to another
|
||||
- delete old_table in schema, generate sql
|
||||
|
||||
or create manual migration like below:
|
||||
|
||||
ALTER TABLE table_name RENAME TO old_table;
|
||||
CREATE TABLE table_name (
|
||||
column1 datatype [ NULL | NOT NULL ],
|
||||
column2 datatype [ NULL | NOT NULL ],
|
||||
...
|
||||
PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)
|
||||
);
|
||||
INSERT INTO table_name SELECT * FROM old_table;
|
||||
|
||||
Due to that we don't generate migration automatically and it has to be done manually
|
||||
*/
|
||||
ALTER TABLE title_messages RENAME TO _title_messages;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE title_messages (
|
||||
title_id integer NOT NULL,
|
||||
message_id text NOT NULL,
|
||||
PRIMARY KEY (title_id)
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO title_messages SELECT * FROM _title_messages;
|
||||
--> statement-breakpoint
|
||||
DROP TABLE _title_messages;
|
||||
Reference in New Issue
Block a user