база данных

This commit is contained in:
Alexander Zhirov 2023-05-29 17:40:53 +03:00
commit ca5259c638
4 changed files with 83 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/database/volumes-data

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# daster
Управление диалпланом

View File

@ -0,0 +1,17 @@
services:
postgres:
image: registry.zhirov.kz/postgresql-15.3:alpine-3.18.0-amd64
container_name: postgres-asterisk
restart: always
environment:
POSTGRES_DB: asterisk
POSTGRES_USER: asterisk
POSTGRES_PASSWORD: asterisk
PGTZ: Europe/Moscow
TZ: Europe/Moscow
ports:
- 5432:5432
volumes:
- ./volumes-data:/var/lib/postgresql/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro

62
database/script.sql Normal file
View File

@ -0,0 +1,62 @@
create table if not exists "groups" (
"name" varchar(20) not null,
"comment" varchar(100) default null,
constraint groups_pk primary key ("name")
);
insert into "groups" ("name", "comment")
values
('general', 'Общие контакты'),
('work', 'Рабочие контакты'),
('personal', 'Личные контакты');
create table if not exists lists (
"name" varchar(20) not null,
"comment" varchar(100) default null,
constraint lists_pk primary key ("name")
);
insert into lists ("name", "comment")
values
('general', 'Общий список'),
('whitelist', 'Белый список'),
('blacklist', 'Черный список');
create table if not exists numbers (
"number" varchar(12) not null,
"group" varchar(20) not null default 'general',
list varchar(20) not null default 'general',
all_cc int not null default 0,
white_cc int not null default 0,
black_cc int not null default 0,
"comment" varchar(100) default null,
constraint numbers_pk primary key ("number"),
foreign key ("group") references "groups" ("name") on delete set null on update cascade,
foreign key (list) references lists ("name") on delete set null on update cascade
);
create table if not exists sms (
id bigserial not null,
"date" timestamp not null default NOW(),
"to" varchar(12) not null,
"from" varchar(12) not null,
"text" text not null,
constraint sms_pk primary key (id)
);
create table if not exists ussd (
id bigserial not null,
"date" timestamp not null default NOW(),
"to" varchar(12) not null,
"type" smallint not null,
"text" text not null,
constraint ussd_pk primary key (id)
);
create table if not exists "server" (
address varchar(50) not null,
transparent_mode bool not null default false,
internal_number varchar(12) not null,
external_number varchar(12) not null,
constraint server_pk primary key (address)
);