qt-chat-app

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

U1766771090__alter_table_message.sql (723B)


      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' BLOB NULL REFERENCES '_user'('id'),
      8     'sent_at' TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
      9 ) STRICT;
     10 
     11 INSERT INTO
     12     "__alter_table_message" (
     13         "content",
     14         "id",
     15         "sent_at",
     16         "chat_id",
     17         "sender_id"
     18     )
     19 SELECT
     20     "content",
     21     "id",
     22     "sent_at",
     23     "chat_id",
     24     "sender_id"
     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;