rpiwebapp-public/update_tables.sql
Matthew Welch 0041ad4b3b Changed the database to use models.
The database is now used through models instead of direct SQL queries.
2019-08-22 10:43:14 -07:00

29 lines
676 B
SQL

.print "start alter table"
ALTER TABLE comic_thumbnails RENAME TO old_comic_thumbnails;
.print "finish alter table"
.print ""
.print "start create new table"
CREATE TABLE IF NOT EXISTS "comic_thumbnails" (
"comic_id" INTEGER,
"pageNumber" INTEGER,
"image" BLOB,
"type" TEXT,
"id" INTEGER PRIMARY KEY AUTOINCREMENT
);
.print "finish create new table"
.print ""
.print "start copy from old table"
INSERT INTO comic_thumbnails(comic_id, pageNumber, image, type)
SELECT id, pageNumber, image, type FROM old_comic_thumbnails;
.print "finish copy from old table"
.print ""
.print "start delete old table"
DROP TABLE old_comic_thumbnails;
.print "finish delete old table"