39 lines
1.7 KiB
SQL
39 lines
1.7 KiB
SQL
create schema life;
|
|
comment on schema life is 'Fortern的朋友与记事';
|
|
|
|
-- leaves_history table
|
|
create table life.leaves_history
|
|
(
|
|
id serial not null
|
|
constraint history_pk primary key,
|
|
title varchar(50) not null,
|
|
description text not null
|
|
);
|
|
comment on table life.leaves_history is 'Historical events';
|
|
comment on column life.leaves_history.title is 'Title';
|
|
comment on column life.leaves_history.description is 'Description';
|
|
|
|
-- leaves_history_item table
|
|
create table life.leaves_history_item
|
|
(
|
|
id serial not null
|
|
constraint leaves_history_item_pk
|
|
primary key,
|
|
qq_no bigint not null,
|
|
qq_group_no integer default 0 not null,
|
|
time_of_occurrence timestamp not null,
|
|
info varchar(1024),
|
|
history_id integer not null
|
|
constraint leaves_history_item_history_id_fk
|
|
references life.leaves_history
|
|
on update cascade on delete restrict
|
|
);
|
|
comment on column life.leaves_history_item.qq_no is 'QQ number';
|
|
comment on column life.leaves_history_item.qq_group_no is 'QQ group number';
|
|
comment on column life.leaves_history_item.info is 'Description';
|
|
comment on column life.leaves_history_item.history_id is 'History table id';
|
|
create index leaves_history_item_history_id_index on life.leaves_history_item (history_id);
|
|
create index leaves_history_item_qq_group_no_index on life.leaves_history_item (qq_group_no);
|
|
create index leaves_history_item_qq_no_index on life.leaves_history_item (qq_no);
|
|
create index leaves_history_item_time_of_occurrence_index on life.leaves_history_item (time_of_occurrence);
|