* 1 - down - считается по download
* 2 - max - считается по максимальному среди upload/download
* 3 - up+down - считается по сумме upload и download
- * Как альтернативу этому полю можно сделать еще одну таблицу - типов
- * подсчета трафика. И в этом поле хранить ссылку на эту таблицу.
- * Вопрос только "А надо ли это?"
*
* * dm_ip. IP адресс в виде четырех байтового целого числа со знаком.
* Выполнять приведение к знаковуму целому при занесении IP в БД!!!
* CREATE DATABASE 'localhost:/var/stg/stargazer.fdb' USER 'stg' PASSWORD '123456' DEFAULT CHARACTER SET UTF8;
*/
-
+
/*
*****************************************************************************
CREATE DOMAIN dm_user_name AS VARCHAR(256) DEFAULT '';
CREATE DOMAIN dm_service_comment AS VARCHAR(256) DEFAULT '';
CREATE DOMAIN dm_service_name AS VARCHAR(32) DEFAULT '';
-/* TODO: why 0-31? Which is default? */
+
CREATE DOMAIN dm_pay_day AS SMALLINT NOT NULL
CHECK ( VALUE BETWEEN 0 AND 31 );
CREATE DOMAIN dm_period AS INTEGER NOT NULL;
CREATE DOMAIN dm_counter AS SMALLINT NOT NULL;
-/* Is it needded? */
+
CREATE DOMAIN dm_message_ver AS INTEGER NOT NULL;
CREATE DOMAIN dm_message_type AS INTEGER NOT NULL;
-/*----------------*/
+
CREATE DOMAIN dm_message AS VARCHAR(256) NOT NULL;
CREATE DOMAIN dm_user_data AS VARCHAR(256) NOT NULL;
CREATE DOMAIN dm_session_event_type AS CHAR(1) NOT NULL
(
pk_user_data dm_id PRIMARY KEY,
fk_user dm_id,
- num dm_num, /* data_id dm_id renamed */
+ num dm_num,
data dm_user_data,
FOREIGN KEY (fk_user) REFERENCES tb_users (pk_user)
END !!
SET TERM ; !!
-/*set term !! ;
-create trigger tr_tariff_bi for tb_tariffs active
-before insert position 0
-as
-begin
- if (new.pk_tariff is null)
- then new.pk_tariff = gen_id(gn_pk_tariff, 1);
-end !!
-set term ; !!*/
-
set term !! ;
create trigger tr_tariff_param_bi for tb_tariffs_params active
before insert position 0
end !!
set term ; !!
-/*set term !! ;
-create trigger tr_user_bi for tb_users active
-before insert position 0
-as
-begin
- if (new.pk_user is null)
- then new.pk_user = gen_id(gn_pk_user, 1);
-end !!
-set term ; !!*/
-
set term !! ;
create trigger tr_detail_stat_bi for tb_detail_stats active
before insert position 0
end !!
set term ; !!
-/*set term !! ;
-create trigger tr_message_bi for tb_messages active
-before insert position 0
-as
-begin
- if (new.pk_message is null)
- then new.pk_message = gen_id(gn_pk_message, 1);
-end !!
-set term ; !!*/
-
-/*set term !! ;
-create trigger tr_stat_bi for tb_stats active
-before insert position 0
-as
-begin
- if (new.pk_stat is null)
- then new.pk_stat = gen_id(gn_pk_stat, 1);
-end !!
-set term ; !!*/
-
set term !! ;
create trigger tr_stat_traffic_bi for tb_stats_traffic active
before insert position 0
end !!
set term ; !!
-/*set term !! ;
-create trigger tr_session_log_bi for tb_sessions_log active
-before insert position 0
-as
-begin
- if (new.pk_session_log is null)
- then new.pk_session_log = gen_id(gn_pk_session_log, 1);
-end !!
-set term ; !!*/
-
set term !! ;
create trigger tr_session_data_bi for tb_sessions_data active
before insert position 0
set term !! ;
create procedure sp_add_message(pk_message integer, login varchar(32), ver integer, msg_type integer, last_send_time integer, creation_time integer, show_time integer, repeat integer, repeat_period integer, msg_text varchar(256))
returns(res integer)
-as
+as
begin
if (:pk_message is null) then
begin
:ver,
:msg_type,
:last_send_time,
- :creation_time,
+ :creation_time,
:show_time,
:repeat,
:repeat_period,
insert into tb_tariffs (pk_tariff, name, fee, free, passive_cost, traff_type) values (:pk_tariff, :name, 0, 0, 0, 0);
while (dirs > 0) do
begin
- insert into tb_tariffs_params (fk_tariff, dir_num, price_day_a,
- price_day_b, price_night_a, price_night_b,
+ insert into tb_tariffs_params (fk_tariff, dir_num, price_day_a,
+ price_day_b, price_night_a, price_night_b,
threshold, time_day_begins, time_day_ends)
values (:pk_tariff, :dirs - 1, 0, 0, 0, 0, 0, '0:0', '0:0');
dirs = dirs - 1;
insert into tb_admins values(0, 'admin', 'geahonjehjfofnhammefahbbbfbmpkmkmmefahbbbfbmpkmkmmefahbbbfbmpkmk', 1, 1, 1, 1, 1, 1, 1, 1, 1);
/* EOF */
-