diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index e805548..8d81632 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..887deb1 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,7 @@ + \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.1__initial_data.sql b/src/main/resources/dbmigration/1.0.1__initial_data.sql deleted file mode 100644 index 289f5f4..0000000 --- a/src/main/resources/dbmigration/1.0.1__initial_data.sql +++ /dev/null @@ -1,4 +0,0 @@ -insert into tenant_model(name, domain, created_by, modified_by) - values ('compegence', 'https://www.compegence.com', 'system', 'system'); -insert into entity_model(name, tenant_id, created_by, modified_by, pre_save_script, post_save_script) - values ('vehicle', 'compegence', 'system', 'system', 'vehicle.kts', 'vehicle.kts'); \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.1__vehicle_queries.sql b/src/main/resources/dbmigration/1.0.2.1__vehicle_queries.sql deleted file mode 100644 index e0a7459..0000000 --- a/src/main/resources/dbmigration/1.0.2.1__vehicle_queries.sql +++ /dev/null @@ -1,4 +0,0 @@ -insert into sql_model(tenant_id, entity_name, sql_id, sql, created_by, modified_by) -values ('compegence', 'vehicle', 'SQL0001', - 'select sys_pk,deleted_on,current_approval_level,required_approval_levels,deleted,version,created_at,modified_at,deleted_by,approval_status,tags,comments,tenant_id,unique_identifier,entity_name,data,created_by,modified_by from entity_model where created_at >= ?', - 'system', 'system') \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.2__vehicle_queries_upd.sql b/src/main/resources/dbmigration/1.0.2.2__vehicle_queries_upd.sql deleted file mode 100644 index 7317f73..0000000 --- a/src/main/resources/dbmigration/1.0.2.2__vehicle_queries_upd.sql +++ /dev/null @@ -1,5 +0,0 @@ -delete from sql_model where tenant_id = 'compegence' and sql_id = 'SQL0001'; -insert into sql_model(tenant_id, entity_name, sql_id, sql, created_by, modified_by) -values ('compegence', 'vehicle', 'SQL0001', - 'select sys_pk,deleted_on,current_approval_level,required_approval_levels,deleted,version,created_at,modified_at,deleted_by,approval_status,tags,comments,tenant_id,unique_identifier,entity_name,data,created_by,modified_by from entity_model where created_at >= ?', - 'system', 'system') \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.3__create_log_entity.sql b/src/main/resources/dbmigration/1.0.2.3__create_log_entity.sql deleted file mode 100644 index dfcd4f8..0000000 --- a/src/main/resources/dbmigration/1.0.2.3__create_log_entity.sql +++ /dev/null @@ -1,2 +0,0 @@ -insert into entity_model(name, tenant_id, created_by, modified_by, pre_save_script, post_save_script) -values ('log', 'compegence', 'system', 'system', '', ''); \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.4__vehicle_queries_upd_2.sql b/src/main/resources/dbmigration/1.0.2.4__vehicle_queries_upd_2.sql deleted file mode 100644 index 65b3cc3..0000000 --- a/src/main/resources/dbmigration/1.0.2.4__vehicle_queries_upd_2.sql +++ /dev/null @@ -1,5 +0,0 @@ -delete from sql_model where tenant_id = 'compegence' and sql_id = 'SQL0001'; -insert into sql_model(tenant_id, entity_name, sql_id, sql, created_by, modified_by) -values ('compegence', 'vehicle', 'SQL0001', - 'select sys_pk,deleted_on,current_approval_level,required_approval_levels,deleted,version,created_at,modified_at,deleted_by,approval_status,tags,comments,tenant_id,entity_name,data,created_by,modified_by from entity_model where created_at >= ?', - 'system', 'system') \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.5__vehicle_queries_upd_3.sql b/src/main/resources/dbmigration/1.0.2.5__vehicle_queries_upd_3.sql deleted file mode 100644 index d568530..0000000 --- a/src/main/resources/dbmigration/1.0.2.5__vehicle_queries_upd_3.sql +++ /dev/null @@ -1,5 +0,0 @@ -delete from sql_model where tenant_id = 'compegence' and sql_id = 'SQL0001'; -insert into sql_model(tenant_id, entity_name, sql_id, sql, created_by, modified_by) -values ('compegence', 'vehicle', 'SQL0001', - 'select sys_pk,deleted_on,current_approval_level,required_approval_levels,deleted,version,created_at,modified_at,deleted_by,approval_status,tags,comments,tenant_id,data,created_by,modified_by from entity_model where created_at >= ?', - 'system', 'system') \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.6__vehicle_queries_upd_4.sql b/src/main/resources/dbmigration/1.0.2.6__vehicle_queries_upd_4.sql deleted file mode 100644 index d568530..0000000 --- a/src/main/resources/dbmigration/1.0.2.6__vehicle_queries_upd_4.sql +++ /dev/null @@ -1,5 +0,0 @@ -delete from sql_model where tenant_id = 'compegence' and sql_id = 'SQL0001'; -insert into sql_model(tenant_id, entity_name, sql_id, sql, created_by, modified_by) -values ('compegence', 'vehicle', 'SQL0001', - 'select sys_pk,deleted_on,current_approval_level,required_approval_levels,deleted,version,created_at,modified_at,deleted_by,approval_status,tags,comments,tenant_id,data,created_by,modified_by from entity_model where created_at >= ?', - 'system', 'system') \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.7__vehicle_queries_upd_7.sql b/src/main/resources/dbmigration/1.0.2.7__vehicle_queries_upd_7.sql deleted file mode 100644 index 8df29df..0000000 --- a/src/main/resources/dbmigration/1.0.2.7__vehicle_queries_upd_7.sql +++ /dev/null @@ -1,5 +0,0 @@ -delete from sql_model where tenant_id = 'compegence' and sql_id = 'SQL0001'; -insert into sql_model(tenant_id, entity_name, sql_id, sql, created_by, modified_by) -values ('compegence', 'vehicle', 'SQL0001', - 'select sys_pk,deleted_on,current_approval_level,required_approval_levels,deleted,version,created_at,modified_at,deleted_by,approval_status,tags,comments,tenant_id,created_by,modified_by from entity_model where created_at >= ?', - 'system', 'system') \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.8__vehicle_approvals.sql b/src/main/resources/dbmigration/1.0.2.8__vehicle_approvals.sql deleted file mode 100644 index 51ee7ca..0000000 --- a/src/main/resources/dbmigration/1.0.2.8__vehicle_approvals.sql +++ /dev/null @@ -1 +0,0 @@ -update entity_model set required_approval_levels = 1 WHERE entity_model.name = 'vehicle' \ No newline at end of file diff --git a/src/main/resources/dbmigration/1.0.2.sql b/src/main/resources/dbmigration/1.0.2.sql deleted file mode 100644 index 7d7e39b..0000000 --- a/src/main/resources/dbmigration/1.0.2.sql +++ /dev/null @@ -1,27 +0,0 @@ --- apply changes -create table sql_model ( - sys_pk bigint generated by default as identity not null, - deleted_on timestamp, - current_approval_level integer default 0 not null, - required_approval_levels integer default 0 not null, - sql text not null, - deleted boolean default false not null, - version integer default 1 not null, - created_at timestamp default 'now()' not null, - modified_at timestamp default 'now()' not null, - deleted_by varchar(255), - approval_status varchar(8) default 'APPROVED' not null, - tags varchar[] default '{}' not null, - comments jsonb default '[]' not null, - tenant_id varchar(255) not null, - sql_id varchar(255) not null, - entity_name varchar(255) not null, - created_by varchar(255) not null, - modified_by varchar(255) not null, - constraint ck_sql_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')), - constraint sql_unique_id unique (entity_name,sql_id,tenant_id), - constraint pk_sql_model primary key (sys_pk) -); - -ALTER TABLE sql_model ADD FOREIGN KEY(tenant_id) REFERENCES tenant_model(name); -ALTER TABLE sql_model ADD FOREIGN KEY(entity_name) REFERENCES entity_model(name); diff --git a/src/main/resources/dbmigration/1.0__initial.sql b/src/main/resources/dbmigration/1.0__initial.sql index 089c80f..2157757 100644 --- a/src/main/resources/dbmigration/1.0__initial.sql +++ b/src/main/resources/dbmigration/1.0__initial.sql @@ -10,8 +10,8 @@ create table audit_log ( modified_at timestamp default 'now()' not null, deleted_by varchar(255), approval_status varchar(8) default 'APPROVED' not null, - tags text[] default '{}'::text[] not null, - comments jsonb default '[]'::jsonb not null, + tags varchar[] default '{}' not null, + comments jsonb default '[]' not null, tenant_id varchar(255) not null, audit_type varchar(7) not null, entity varchar(255) not null, @@ -36,8 +36,8 @@ create table data_model ( modified_at timestamp default 'now()' not null, deleted_by varchar(255), approval_status varchar(8) default 'APPROVED' not null, - tags text[] default '{}'::text[] not null, - comments jsonb default '[]'::jsonb not null, + tags varchar[] default '{}' not null, + comments jsonb default '[]' not null, tenant_id varchar(255) not null, unique_identifier varchar(255) not null, entity_name varchar(255) not null, @@ -61,17 +61,17 @@ create table entity_model ( modified_at timestamp default 'now()' not null, deleted_by varchar(255), approval_status varchar(8) default 'APPROVED' not null, - tags text[] default '{}'::text[] not null, - comments jsonb default '[]'::jsonb not null, + tags varchar[] default '{}' not null, + comments jsonb default '[]' not null, tenant_id varchar(255) not null, name varchar(255) not null, pre_save_script varchar(255), post_save_script varchar(255), - actions text[] default '{}'::text[] not null, - allowed_fields text[] default '{}'::text[] not null, - allowed_field_types jsonb default '{}'::jsonb not null, - audit_log_fields text[] default '{}'::text[] not null, - preferences jsonb default '{}'::jsonb not null, + actions varchar[] default '{}' not null, + allowed_fields varchar[] default '{}' not null, + allowed_field_types jsonb default '{}' not null, + audit_log_fields varchar[] default '{}' not null, + preferences jsonb default '{}' not null, created_by varchar(255) not null, modified_by varchar(255) not null, constraint ck_entity_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')), @@ -90,8 +90,8 @@ create table job_model ( modified_at timestamp default 'now()' not null, deleted_by varchar(255), approval_status varchar(8) default 'APPROVED' not null, - tags text[] default '{}'::text[] not null, - comments jsonb default '[]'::jsonb not null, + tags varchar[] default '{}' not null, + comments jsonb default '[]' not null, tenant_id varchar(255) not null, job_name varchar(255) not null, job_type varchar(6) not null, @@ -108,6 +108,30 @@ create table job_model ( constraint pk_job_model primary key (sys_pk) ); +create table sql_model ( + sys_pk bigint generated by default as identity not null, + deleted_on timestamp, + current_approval_level integer default 0 not null, + required_approval_levels integer default 0 not null, + sql text not null, + deleted boolean default false not null, + version integer default 1 not null, + created_at timestamp default 'now()' not null, + modified_at timestamp default 'now()' not null, + deleted_by varchar(255), + approval_status varchar(8) default 'APPROVED' not null, + tags varchar[] default '{}' not null, + comments jsonb default '[]' not null, + tenant_id varchar(255) not null, + sql_id varchar(255) not null, + entity_name varchar(255) not null, + created_by varchar(255) not null, + modified_by varchar(255) not null, + constraint ck_sql_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')), + constraint sql_unique_id unique (entity_name,sql_id,tenant_id), + constraint pk_sql_model primary key (sys_pk) +); + create table tenant_model ( sys_pk bigint generated by default as identity not null, deleted_on timestamp, @@ -119,11 +143,11 @@ create table tenant_model ( modified_at timestamp default 'now()' not null, deleted_by varchar(255), approval_status varchar(8) default 'APPROVED' not null, - tags text[] default '{}'::text[] not null, - comments jsonb default '[]'::jsonb not null, + tags varchar[] default '{}' not null, + comments jsonb default '[]' not null, name varchar(255) not null, domain varchar(255) not null, - preferences jsonb default '{}'::jsonb not null, + preferences jsonb not null, created_by varchar(255) not null, modified_by varchar(255) not null, constraint ck_tenant_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')), @@ -136,6 +160,3 @@ create index if not exists ix_audit_log_audit_type_entity_unique_identifier_tena create index audit_log_values_idx on audit_log using GIN (data); create index audit_log_changes_idx on audit_log using GIN (changes); create index data_jsonb_idx on data_model using GIN (data) ; - -ALTER TABLE data_model ADD FOREIGN KEY(tenant_id) REFERENCES tenant_model(name); -ALTER TABLE data_model ADD FOREIGN KEY(entity_name) REFERENCES entity_model(name); \ No newline at end of file diff --git a/src/main/resources/dbmigration/model/1.0.2.model.xml b/src/main/resources/dbmigration/model/1.0.2.model.xml deleted file mode 100644 index 4989a46..0000000 --- a/src/main/resources/dbmigration/model/1.0.2.model.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/dbmigration/model/1.0__initial.model.xml b/src/main/resources/dbmigration/model/1.0__initial.model.xml index c9895a1..480816e 100644 --- a/src/main/resources/dbmigration/model/1.0__initial.model.xml +++ b/src/main/resources/dbmigration/model/1.0__initial.model.xml @@ -95,6 +95,27 @@ + + + + + + + + + + + + + + + + + + + + +