2024-10-16 04:34:57 +00:00
|
|
|
CREATE TABLE users (
|
2024-11-11 19:55:01 +00:00
|
|
|
Id integer primary key autoincrement,
|
|
|
|
ShortId integer UNIQUE NOT NULL,
|
2024-10-16 04:34:57 +00:00
|
|
|
Username varchar(32) NOT NULL,
|
2024-11-11 19:55:01 +00:00
|
|
|
Email varchar(256) UNIQUE NOT NULL,
|
|
|
|
IsDeleted boolean NOT NULL DEFAULT FALSE,
|
|
|
|
IsBanned boolean NOT NULL DEFAULT FALSE,
|
|
|
|
HashedPassword char(60) NOT NULL,
|
|
|
|
Created datetime NOT NULL
|
|
|
|
);
|
2024-10-16 04:34:57 +00:00
|
|
|
|
|
|
|
CREATE TABLE guestbooks (
|
2024-11-11 19:55:01 +00:00
|
|
|
Id integer primary key autoincrement,
|
|
|
|
ShortId integer UNIQUE NOT NULL,
|
2024-10-16 04:34:57 +00:00
|
|
|
SiteUrl varchar(512) NOT NULL,
|
2024-12-15 17:23:53 +00:00
|
|
|
UserId integer NOT NULL,
|
2024-11-11 19:55:01 +00:00
|
|
|
Created datetime NOT NULL,
|
2024-10-16 04:34:57 +00:00
|
|
|
IsDeleted boolean NOT NULL DEFAULT FALSE,
|
|
|
|
IsActive boolean NOT NULL DEFAULT TRUE,
|
|
|
|
FOREIGN KEY (UserId) REFERENCES users(Id)
|
|
|
|
ON DELETE RESTRICT
|
|
|
|
ON UPDATE RESTRICT
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE guestbook_comments (
|
2024-11-11 19:55:01 +00:00
|
|
|
Id integer primary key autoincrement,
|
|
|
|
ShortId integer UNIQUE NOT NULL,
|
2024-12-15 17:23:53 +00:00
|
|
|
GuestbookId integer NOT NULL,
|
|
|
|
ParentId integer,
|
2024-10-16 04:34:57 +00:00
|
|
|
AuthorName varchar(256) NOT NULL,
|
|
|
|
AuthorEmail varchar(256) NOT NULL,
|
|
|
|
AuthorSite varchar(256),
|
|
|
|
CommentText text NOT NULL,
|
|
|
|
PageUrl varchar(256),
|
2024-11-11 19:55:01 +00:00
|
|
|
Created datetime NOT NULL,
|
2024-10-16 04:34:57 +00:00
|
|
|
IsPublished boolean NOT NULL DEFAULT TRUE,
|
|
|
|
IsDeleted boolean NOT NULL DEFAULT FALSE,
|
|
|
|
FOREIGN KEY (GuestbookId)
|
|
|
|
REFERENCES guestbooks(Id)
|
|
|
|
ON DELETE RESTRICT
|
|
|
|
ON UPDATE RESTRICT,
|
|
|
|
FOREIGN KEY (ParentId)
|
|
|
|
REFERENCES guestbook_comments(Id)
|
|
|
|
ON DELETE RESTRICT
|
|
|
|
ON UPDATE RESTRICT
|
|
|
|
);
|