summaryrefslogtreecommitdiff
path: root/sql/sqlite3.sql
blob: 46a9d83432ac5ccd6fffb0fb8518477d3f67ecaf (plain)
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
PRAGMA foreign_keys = ON;

drop table if exists login;
drop table if exists user;
drop table if exists userstatus;

create table userstatus(
	status char(1) primary key not null,
	description varchar(32) not null
);

insert into userstatus values( 'U', 'User unknown' );
insert into userstatus values( 'R', 'Currently in registration' );
insert into userstatus values( 'A', 'Registration ok, user active' );
insert into userstatus values( 'D', 'User disabled' );

create table user(
	id integer primary key autoincrement not null,
	username varchar(32) unique not null,
	printname varchar(32) unique not null,
	password varchar(32) not null,
	email varchar(32),
	status char(1) references userstatus(status) default 'U',
	registration_start timestamp,
	code varchar(32)
);

-- dangerous, disable default admin if necessary
insert into user( username, printname, password, status ) values( 'admin', 'The Root', 'admin', 'A' );

create table login(
	id integer primary key autoincrement not null,
	user_id integer references user(id),
	last_login timestamp
);

create table page(
	id integer primary key autoincrement not null,
	slug varchar(32) not null,
	title varchar(32) not null,
	content text,
	unique( slug )
);