qt-chat-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

U1766666708__alter_table_message.sql (729B)


      1 PRAGMA foreign_keys = OFF;
      2 
      3 CREATE TABLE "__alter_table_message" (
      4     'id' INTEGER PRIMARY KEY NOT NULL,
      5     'chat_id' INTEGER NOT NULL REFERENCES 'chat'('id'),
      6     'content' TEXT NOT NULL,
      7     'sender_id' INTEGER NULL REFERENCES 'profile'('id'),
      8     'sent_at' TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
      9 ) STRICT;
     10 
     11 INSERT INTO
     12     "__alter_table_message" (
     13         "content",
     14         "chat_id",
     15         "sender_id",
     16         "id",
     17         "sent_at"
     18     )
     19 SELECT
     20     "content",
     21     "chat_id",
     22     "sender_id",
     23     "id",
     24     "sent_at"
     25 FROM
     26     "message";
     27 
     28 DROP TABLE "message";
     29 
     30 PRAGMA legacy_alter_table = ON;
     31 
     32 ALTER TABLE
     33     "__alter_table_message" RENAME TO "message";
     34 
     35 PRAGMA legacy_alter_table = OFF;
     36 
     37 PRAGMA foreign_keys = ON;