mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-07 16:00:28 +00:00
Add NOT NULL constraint to all columns
Thanks @hoelzro
This commit is contained in:
parent
f925f036c9
commit
c26acfdb42
@ -61,23 +61,23 @@ SqlTiddlerDatabase.prototype.createTables = function() {
|
|||||||
-- Bags have names and access control settings
|
-- Bags have names and access control settings
|
||||||
CREATE TABLE IF NOT EXISTS bags (
|
CREATE TABLE IF NOT EXISTS bags (
|
||||||
bag_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
bag_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
bag_name TEXT UNIQUE,
|
bag_name TEXT UNIQUE NOT NULL,
|
||||||
accesscontrol TEXT,
|
accesscontrol TEXT NOT NULL,
|
||||||
description TEXT
|
description TEXT NOT NULL
|
||||||
)
|
)
|
||||||
`,`
|
`,`
|
||||||
-- Recipes have names...
|
-- Recipes have names...
|
||||||
CREATE TABLE IF NOT EXISTS recipes (
|
CREATE TABLE IF NOT EXISTS recipes (
|
||||||
recipe_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
recipe_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
recipe_name TEXT UNIQUE,
|
recipe_name TEXT UNIQUE NOT NULL,
|
||||||
description TEXT
|
description TEXT NOT NULL
|
||||||
)
|
)
|
||||||
`,`
|
`,`
|
||||||
-- ...and recipes also have an ordered list of bags
|
-- ...and recipes also have an ordered list of bags
|
||||||
CREATE TABLE IF NOT EXISTS recipe_bags (
|
CREATE TABLE IF NOT EXISTS recipe_bags (
|
||||||
recipe_id INTEGER,
|
recipe_id INTEGER NOT NULL,
|
||||||
bag_id INTEGER,
|
bag_id INTEGER NOT NULL,
|
||||||
position INTEGER,
|
position INTEGER NOT NULL,
|
||||||
FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
FOREIGN KEY (bag_id) REFERENCES bags(bag_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
FOREIGN KEY (bag_id) REFERENCES bags(bag_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
UNIQUE (recipe_id, bag_id)
|
UNIQUE (recipe_id, bag_id)
|
||||||
@ -86,8 +86,8 @@ SqlTiddlerDatabase.prototype.createTables = function() {
|
|||||||
-- Tiddlers are contained in bags and have titles
|
-- Tiddlers are contained in bags and have titles
|
||||||
CREATE TABLE IF NOT EXISTS tiddlers (
|
CREATE TABLE IF NOT EXISTS tiddlers (
|
||||||
tiddler_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
tiddler_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
bag_id INTEGER,
|
bag_id INTEGER NOT NULL,
|
||||||
title TEXT,
|
title TEXT NOT NULL,
|
||||||
FOREIGN KEY (bag_id) REFERENCES bags(bag_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
FOREIGN KEY (bag_id) REFERENCES bags(bag_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
UNIQUE (bag_id, title)
|
UNIQUE (bag_id, title)
|
||||||
)
|
)
|
||||||
@ -95,8 +95,8 @@ SqlTiddlerDatabase.prototype.createTables = function() {
|
|||||||
-- Tiddlers also have unordered lists of fields, each of which has a name and associated value
|
-- Tiddlers also have unordered lists of fields, each of which has a name and associated value
|
||||||
CREATE TABLE IF NOT EXISTS fields (
|
CREATE TABLE IF NOT EXISTS fields (
|
||||||
tiddler_id INTEGER,
|
tiddler_id INTEGER,
|
||||||
field_name TEXT,
|
field_name TEXT NOT NULL,
|
||||||
field_value TEXT,
|
field_value TEXT NOT NULL,
|
||||||
FOREIGN KEY (tiddler_id) REFERENCES tiddlers(tiddler_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
FOREIGN KEY (tiddler_id) REFERENCES tiddlers(tiddler_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
UNIQUE (tiddler_id, field_name)
|
UNIQUE (tiddler_id, field_name)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user