diff --git a/controller/store/sql/postgresql/022_v0_4_31_limits_classes.sql b/controller/store/sql/postgresql/022_v0_4_31_limits_classes.sql index 71841f16..426b80be 100644 --- a/controller/store/sql/postgresql/022_v0_4_31_limits_classes.sql +++ b/controller/store/sql/postgresql/022_v0_4_31_limits_classes.sql @@ -3,7 +3,7 @@ create type limit_scope as enum ('account', 'environment', 'share'); create type limit_action as enum ('warning', 'limit'); -create table limits_classes ( +create table limit_classes ( id serial primary key, limit_scope limit_scope not null default ('account'), limit_action limit_action not null default ('limit'), @@ -16,4 +16,13 @@ create table limits_classes ( created_at timestamptz not null default(current_timestamp), updated_at timestamptz not null default(current_timestamp), deleted boolean not null default(false) -) \ No newline at end of file +); + +create table applied_limit_classes ( + id serial primary key, + account_id integer not null references accounts (id), + limit_class_id integer not null references limit_classes (id), + created_at timestamptz not null default(current_timestamp), + updated_at timestamptz not null default(current_timestamp), + deleted boolean not null default(false) +); \ No newline at end of file diff --git a/controller/store/sql/sqlite3/022_v0_4_31_limits_classes.sql b/controller/store/sql/sqlite3/022_v0_4_31_limits_classes.sql index 70792f1e..78efd7ac 100644 --- a/controller/store/sql/sqlite3/022_v0_4_31_limits_classes.sql +++ b/controller/store/sql/sqlite3/022_v0_4_31_limits_classes.sql @@ -1,16 +1,25 @@ -- +migrate Up -create table limits_classes ( +create table limit_classes ( id serial primary key, limit_scope string not null default ('account'), limit_action string not null default ('limit'), share_mode string, backend_mode string, - period_minutes int not null default (1440), + period_minutes integer not null default (1440), rx_bytes bigint not null default (-1), tx_bytes bigint not null default (-1), total_bytes bigint not null default (-1), - created_at timestamptz not null default(current_timestamp), - updated_at timestamptz not null default(current_timestamp), + created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), + updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), deleted boolean not null default(false) -) \ No newline at end of file +); + +create table applied_limit_classes ( + id serial primary key, + account_id integer not null references accounts (id), + limit_class_id integer not null references limit_classes (id), + created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), + updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), + deleted boolean not null default(false) +); \ No newline at end of file