schema change; added flask-login
This commit is contained in:
parent
3f867b4027
commit
a646c96b86
8 changed files with 100 additions and 74 deletions
15
migrate_0_4_to_0_5.py
Normal file
15
migrate_0_4_to_0_5.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import config, sqlite3
|
||||
|
||||
conn = sqlite3.connect(config.DATABASE)
|
||||
|
||||
if __name__ == '__main__':
|
||||
conn.executescript('''
|
||||
BEGIN TRANSACTION;
|
||||
CREATE TABLE new_message ("id" INTEGER NOT NULL PRIMARY KEY, "user_id" INTEGER NOT NULL, "text" TEXT NOT NULL, "pub_date" DATETIME NOT NULL, "privacy" INTEGER DEFAULT 0, FOREIGN KEY ("user_id") REFERENCES "user" ("id"));
|
||||
INSERT INTO new_message (id, user_id, text, pub_date, privacy) SELECT t1.id, t1.user_id, t1.text, t1.pub_date, t2.value FROM message AS t1 LEFT JOIN messageprivacy AS t2 ON t2.message_id = t1.id;
|
||||
UPDATE new_message SET privacy = 0 WHERE privacy IS NULL;
|
||||
DROP TABLE message;
|
||||
DROP TABLE messageprivacy;
|
||||
ALTER TABLE new_message RENAME TO message;
|
||||
COMMIT;
|
||||
''')
|
||||
Loading…
Add table
Add a link
Reference in a new issue