Skip to content

Commit

Permalink
speedup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed Oct 9, 2023
1 parent a1f25ff commit 9c7a164
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 1 deletion.
139 changes: 139 additions & 0 deletions src/main/resources/schema/merged_schema_v1-v34.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
CREATE TABLE system_tablegroup (
id BIGSERIAL PRIMARY KEY
);

CREATE TABLE system_tablegroup_lang (
id bigint REFERENCES system_tablegroup(id) ON DELETE CASCADE,
langtag character varying(50),
name character varying(255),
description text,
CONSTRAINT system_tablegroup_lang_pkey PRIMARY KEY (id, langtag)
);

CREATE TABLE system_table (
table_id BIGSERIAL PRIMARY KEY,
user_table_name character varying(255) NOT NULL,
is_hidden boolean DEFAULT false,
ordering bigint DEFAULT currval('system_table_table_id_seq'::regclass),
langtags text[],
type text,
group_id bigint REFERENCES system_tablegroup(id) ON DELETE SET NULL ON UPDATE CASCADE,
attributes json NOT NULL DEFAULT '{}'::json
);

CREATE TABLE system_table_lang (
table_id bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
langtag character varying(50),
name character varying(255),
description text,
CONSTRAINT system_table_lang_pkey PRIMARY KEY (table_id, langtag)
);

CREATE TABLE system_link_table (
link_id BIGSERIAL PRIMARY KEY,
table_id_1 bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
table_id_2 bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
cardinality_1 integer DEFAULT 0 CHECK (cardinality_1 >= 0),
cardinality_2 integer DEFAULT 0 CHECK (cardinality_2 >= 0),
delete_cascade boolean DEFAULT false
);

CREATE TABLE system_columns (
table_id bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
column_id bigint,
column_type character varying(255) NOT NULL,
user_column_name character varying(255) NOT NULL,
ordering bigint NOT NULL,
link_id bigint REFERENCES system_link_table(link_id) ON DELETE CASCADE,
multilanguage character varying(255),
identifier boolean DEFAULT false,
country_codes text[],
format_pattern character varying(255),
separator boolean NOT NULL DEFAULT false,
attributes json NOT NULL DEFAULT '{}'::json,
rules json NOT NULL DEFAULT '[]'::json,
hidden boolean NOT NULL DEFAULT false,
max_length integer,
min_length integer,
CONSTRAINT system_columns_pkey PRIMARY KEY (table_id, column_id)
);

CREATE TABLE system_columns_lang (
table_id bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
column_id bigint,
langtag character varying(50),
name character varying(255),
description text,
CONSTRAINT system_columns_lang_pkey PRIMARY KEY (table_id, column_id, langtag),
CONSTRAINT system_columns_lang_table_id_column_id_fkey FOREIGN KEY (table_id, column_id) REFERENCES system_columns(table_id, column_id) ON DELETE CASCADE
);

CREATE TABLE system_column_groups (
table_id bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
group_column_id bigint,
grouped_column_id bigint,
CONSTRAINT system_column_groups_table_id_grouped_column_id_fkey FOREIGN KEY (table_id, grouped_column_id) REFERENCES system_columns(table_id, column_id) ON DELETE CASCADE,
CONSTRAINT system_column_groups_table_id_group_column_id_fkey FOREIGN KEY (table_id, group_column_id) REFERENCES system_columns(table_id, column_id) ON DELETE CASCADE,
CONSTRAINT system_column_groups_pkey PRIMARY KEY (table_id, group_column_id, grouped_column_id)
);

CREATE TABLE folder (
id BIGSERIAL PRIMARY KEY,
name character varying(255) NOT NULL,
description character varying(255) NOT NULL,
idparent bigint REFERENCES folder(id),
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone
);

CREATE TABLE file (
uuid uuid PRIMARY KEY,
idfolder bigint REFERENCES folder(id),
tmp boolean NOT NULL DEFAULT true,
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone
);

CREATE TABLE file_lang (
uuid uuid REFERENCES file(uuid) ON DELETE CASCADE,
langtag character varying(50),
title character varying(255),
description character varying(255),
internal_name character varying(255),
external_name character varying(255),
mime_type character varying(255),
CONSTRAINT file_lang_pkey PRIMARY KEY (uuid, langtag)
);

CREATE TABLE system_attachment (
table_id bigint REFERENCES system_table(table_id) ON DELETE CASCADE,
column_id bigint,
row_id bigint,
attachment_uuid uuid REFERENCES file(uuid) ON DELETE CASCADE,
ordering bigint NOT NULL,
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone,
CONSTRAINT system_attachment_table_id_column_id_fkey FOREIGN KEY (table_id, column_id) REFERENCES system_columns(table_id, column_id) ON DELETE CASCADE,
CONSTRAINT system_attachment_pkey PRIMARY KEY (table_id, column_id, row_id, attachment_uuid)
);

CREATE TABLE system_services (
id BIGSERIAL PRIMARY KEY,
type character varying(50) NOT NULL,
name character varying(255) NOT NULL UNIQUE,
ordering bigint,
displayname json,
description json,
active boolean DEFAULT true,
config jsonb,
scope jsonb,
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp without time zone
);

CREATE TABLE system_settings (
key character varying(255) PRIMARY KEY,
value text
);

INSERT INTO system_settings (key, value) VALUES ('langtags', $$["de-DE", "en-GB"]$$);
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ class SystemModel(override protected[this] val connection: DatabaseConnection) e
} yield ()
}

/**
* Runs all setup functions.
*/
def installMergedSchema(): Future[Unit] = {
val mergedSchema = readSchemaFile("merged_schema_v1-v34")
for {
t <- connection.begin()

// retrieve but ignore version
(t, _) <- retrieveCurrentVersion(t)

t <- setupVersion(mergedSchema, 34)(t)

_ = logger.info("Setup merged schema finished")

_ <- t.commit()
} yield ()
}

/**
* Runs only necessary setup functions based on current version.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ trait TableauxTestBase

for {
_ <- system.uninstall()
_ <- system.install()
_ <- system.installMergedSchema()
} yield async.complete()

case Failure(e) =>
Expand Down

0 comments on commit 9c7a164

Please sign in to comment.