-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
54 lines (47 loc) · 1.57 KB
/
init.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- init.sql
--
-- database initialization routines
--
-- @author Prahlad Yeri <prahladyeri@yahoo.com>
-- @license MIT
drop table if exists comments;
drop table if exists posts;
drop table if exists users;
create table users (
id integer primary key,
email text not null,
pwd_hash text not null,
name text not null,
website text not null, -- comments will be posted to this site
enabled int not null default 1, -- site is enabled or not
notify int not null default 1, -- send new comment notifications or not
created_at datetime default (datetime(CURRENT_TIMESTAMP, 'localtime')),
modified_at datetime default (datetime(CURRENT_TIMESTAMP, 'localtime')),
unique (email),
check (enabled in (0, 1))
);
create table posts (
id integer primary key,
user_id integer not null references users (id),
uri text not null -- /blog/2024/05/some-slug.html
);
create table comments (
id integer primary key,
reply_to_id integer references comments (id),
post_id integer not null references posts (id),
message text not null,
name text not null,
email text not null,
website text,
ip text not null, -- $_SERVER['REMOTE_ADDR']
notify int not null default 0,
approved int not null default 0,
created_at datetime default CURRENT_TIMESTAMP,
modified_at datetime default CURRENT_TIMESTAMP,
check (notify in (0, 1)),
check (approved in (0, 1))
);
-- create default data
-- create a default admin user who handles to dashboard
-- insert into users(username, hash, name, website)
-- values("admin", "xxxx", 'Admin', 'https://example.com/');