数据库准备 postgresql
配置环境变量
PG_HOME | D:\apptools\postgresql |
---|---|
Path | %PG_HOME%\bin |
psql -d chitchat -U postgres
执行脚本初始化数据库
setup.sql文件
-- drop table posts;
-- drop table threads;
-- drop table sessions;
-- drop table users;
create table users (
id serial primary key,
uuid varchar(64) not null unique,
name varchar(255),
email varchar(255) not null unique,
password varchar(255) not null,
created_at timestamp not null
);
create table sessions (
id serial primary key,
uuid varchar(64) not null unique,
email varchar(255),
user_id integer references users(id),
created_at timestamp not null
);
create table threads (
id serial primary key,
uuid varchar(64) not null unique,
topic text,
user_id integer references users(id),
created_at timestamp not null
);
create table posts (
id serial primary key,
uuid varchar(64) not null unique,
body text,
user_id integer references users(id),
thread_id integer references threads(id),
created_at timestamp not null
);
psql -f .\setup.sql -d chitchat -U postgres