daster/database/script.sql

63 lines
2.0 KiB
MySQL
Raw Normal View History

create table if not exists da_groups (
da_name varchar(20) not null,
da_comment varchar(100) default null,
constraint da_groups_pk primary key (da_name)
2023-05-29 14:40:53 +00:00
);
insert into da_groups (da_name, da_comment)
values
('general', 'Общие контакты'),
('work', 'Рабочие контакты'),
('personal', 'Личные контакты');
2023-05-29 14:40:53 +00:00
create table if not exists da_lists (
da_name varchar(20) not null,
da_comment varchar(100) default null,
constraint da_lists_pk primary key (da_name)
2023-05-29 14:40:53 +00:00
);
insert into da_lists (da_name, da_comment)
values
('general', 'Общий'),
('whitelist', 'Белый'),
('blacklist', 'Черный');
2023-05-29 14:40:53 +00:00
create table if not exists da_numbers (
da_number varchar(12) not null,
da_group varchar(20) not null default 'general',
da_list varchar(20) not null default 'general',
da_all_cc int not null default 0,
da_white_cc int not null default 0,
da_black_cc int not null default 0,
da_comment varchar(100) default null,
constraint da_numbers_pk primary key (da_number),
foreign key (da_group) references da_groups (da_name) on delete set null on update cascade,
foreign key (da_list) references da_lists (da_name) on delete set null on update cascade
2023-05-29 14:40:53 +00:00
);
create table if not exists da_sms (
da_id bigserial not null,
da_date timestamp not null default NOW(),
da_to varchar(12) not null,
da_from varchar(12) not null,
da_text text not null,
constraint da_sms_pk primary key (da_id)
2023-05-29 14:40:53 +00:00
);
create table if not exists da_ussd (
da_id bigserial not null,
da_date timestamp not null default NOW(),
da_to varchar(12) not null,
da_type smallint not null,
da_text text not null,
constraint da_ussd_pk primary key (da_id)
2023-05-29 14:40:53 +00:00
);
create table if not exists da_server (
da_address varchar(50) not null,
da_transparent_mode bool not null default false,
da_internal_number varchar(12) not null,
da_external_number varchar(12) not null,
constraint da_server_pk primary key (da_address)
2023-05-29 14:40:53 +00:00
);