From 9352ca665d7c7c7aceb6cd8e87e6fdfcb3353f59 Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Tue, 25 Jan 2022 07:12:59 +0100 Subject: [PATCH] init script to create an empty db --- dbmigration/create_empty_db.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 dbmigration/create_empty_db.py diff --git a/dbmigration/create_empty_db.py b/dbmigration/create_empty_db.py new file mode 100644 index 0000000..8bb64ac --- /dev/null +++ b/dbmigration/create_empty_db.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +import sqlite3 + +connection = sqlite3.connect("db.sqlite") +cursor = connection.cursor() + +# What script performs: +# - first, remove site table: crash here if table doesn't exist (compatibility test without effort) +# - remove site_id colum from comment table +script = """ +CREATE TABLE comment ( + id INTEGER NOT NULL PRIMARY KEY, + url VARCHAR(255) NOT NULL, + notified DATETIME, + created DATETIME NOT NULL, + published DATETIME, + author_name VARCHAR(255) NOT NULL, + author_site VARCHAR(255) NOT NULL, + author_gravatar varchar(255), + content TEXT NOT NULL +, ulid INTEGER); +""" + +cursor.executescript(script) +connection.close() \ No newline at end of file