db_sqlite: use TEXT instead of VARCHAR

VARCHAR(n) is pointless in SQLite and is the same as TEXT. Don't
bother with a migration since they're equivalent.

Also remove some unnecessary DEFAULT NULL statements.
This commit is contained in:
Simon Ser 2021-11-02 22:58:50 +01:00
parent 07c962018d
commit ce3d6df6b8

View File

@ -17,27 +17,27 @@ const sqliteQueryTimeout = 5 * time.Second
const sqliteSchema = ` const sqliteSchema = `
CREATE TABLE User ( CREATE TABLE User (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE, username TEXT NOT NULL UNIQUE,
password VARCHAR(255), password TEXT,
admin INTEGER NOT NULL DEFAULT 0, admin INTEGER NOT NULL DEFAULT 0,
realname VARCHAR(255) realname TEXT
); );
CREATE TABLE Network ( CREATE TABLE Network (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
name VARCHAR(255), name TEXT,
user INTEGER NOT NULL, user INTEGER NOT NULL,
addr VARCHAR(255) NOT NULL, addr TEXT NOT NULL,
nick VARCHAR(255) NOT NULL, nick TEXT NOT NULL,
username VARCHAR(255), username TEXT,
realname VARCHAR(255), realname TEXT,
pass VARCHAR(255), pass TEXT,
connect_commands VARCHAR(1023), connect_commands TEXT,
sasl_mechanism VARCHAR(255), sasl_mechanism TEXT,
sasl_plain_username VARCHAR(255), sasl_plain_username TEXT,
sasl_plain_password VARCHAR(255), sasl_plain_password TEXT,
sasl_external_cert BLOB DEFAULT NULL, sasl_external_cert BLOB,
sasl_external_key BLOB DEFAULT NULL, sasl_external_key BLOB,
enabled INTEGER NOT NULL DEFAULT 1, enabled INTEGER NOT NULL DEFAULT 1,
FOREIGN KEY(user) REFERENCES User(id), FOREIGN KEY(user) REFERENCES User(id),
UNIQUE(user, addr, nick), UNIQUE(user, addr, nick),
@ -47,10 +47,10 @@ CREATE TABLE Network (
CREATE TABLE Channel ( CREATE TABLE Channel (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
network INTEGER NOT NULL, network INTEGER NOT NULL,
name VARCHAR(255) NOT NULL, name TEXT NOT NULL,
key VARCHAR(255), key TEXT,
detached INTEGER NOT NULL DEFAULT 0, detached INTEGER NOT NULL DEFAULT 0,
detached_internal_msgid VARCHAR(255), detached_internal_msgid TEXT,
relay_detached INTEGER NOT NULL DEFAULT 0, relay_detached INTEGER NOT NULL DEFAULT 0,
reattach_on INTEGER NOT NULL DEFAULT 0, reattach_on INTEGER NOT NULL DEFAULT 0,
detach_after INTEGER NOT NULL DEFAULT 0, detach_after INTEGER NOT NULL DEFAULT 0,
@ -62,9 +62,9 @@ CREATE TABLE Channel (
CREATE TABLE DeliveryReceipt ( CREATE TABLE DeliveryReceipt (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
network INTEGER NOT NULL, network INTEGER NOT NULL,
target VARCHAR(255) NOT NULL, target TEXT NOT NULL,
client VARCHAR(255), client TEXT,
internal_msgid VARCHAR(255) NOT NULL, internal_msgid TEXT NOT NULL,
FOREIGN KEY(network) REFERENCES Network(id), FOREIGN KEY(network) REFERENCES Network(id),
UNIQUE(network, target, client) UNIQUE(network, target, client)
); );