diff --git a/AGENTS.md b/AGENTS.md index 225f677..cc83d94 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ Packages: - `metadata`: `CmsTableBuilder` (tables, possible values, joins, child lists, associations, permission rules), `CmsAppBuilder` and `CmsAreas` (apps and homes). - `home`: `CmsHomeRenderer` and `CmsHtml` (one renderer for every home; reads run with `PermissionEnforcement.ENFORCE`). - `security`: `CmsRole`, `CmsSecurity`, `CmsOpenReadsPermissionChecker`. -- Schema: `src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml`. Its changesets are append-only once released, and `docs/ddl/postgres.sql` is generated from it. +- Schema: `src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml`. Its changesets are append-only once released: `CmsChangelogReleasedTest` fails the build when a released changeset differs from `src/test/resources/released/qbit-cms.changelog.released.yaml`, when one runs on every migration or waives its checksum, and when an install of the first release does not migrate on. When a release is cut, copy the changelog over that file in the same change. `docs/ddl/postgres.sql` is generated from the changelog. ## Naming (owner rule) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05348e4..56d6d53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,4 +25,5 @@ All notable changes to this project are documented here. The format follows Keep ### Schema changes - `1.0.0` baseline: a prefix-parameterized Liquibase changelog (`qbit-cms/db/changelog/qbit-cms.changelog.yaml`, logical path `qbit-cms/changelog`). It creates the CORE tables with the kof22 column types, adds their foreign keys and indexes, and seeds generic reference data. Feature sections are gated by `cms.features`, and a name collision halts the install. Reference DDL is in `docs/ddl/postgres.sql`. - `1.0.0` content tables, appended to the same changelog: `1.0.0-create-` for the eighteen tables of `MEDIA`, `BLOG`, `PROJECTS` and `PHOTOS`, `1.0.0-constraints-` for each feature's foreign keys and indexes, `1.0.0-constraints-blog-projects` and `1.0.0-constraints-photos-projects` for the links between two features, and `1.0.0-seed-media_type` and `1.0.0-seed-blog_type` for generic reference data. Each is gated by `cms.features` and by the features it needs. `1.0.0-guard-existing-content-tables` halts the install when a table with one of these names already exists; it runs once, not on every run. -- **Changed, on purpose, in a released changeset:** `1.0.0-guard-existing-tables` no longer has `runAlways`. It rewrote its `DATABASECHANGELOG` row on every migration, so a second migration was never a no-op and a rollback by count began with it; a host whose migrations must be repeatable could not include this changelog and had to copy the tables instead. It now runs once, before the tables are created, and carries `validCheckSum: ANY` so an install that already ran it migrates on unchanged (`CmsInstallTest.testRerunIsNoop` covers both). A table that appears later under a qbit name still stops the install, at its `createTable`. Check constraints as in kof22: the value-list columns of `media_type`, `blog_post_version` and `project` (the project status check is new), `media_type.max_file_size_mb` above zero and the focal point of a project's image between 0 and 100. `project_category.section` is optional (kof22 requires it); latitude and longitude columns are `DOUBLE PRECISION` as in kof22. A host that already runs `CORE` gets the content tables at its next migration run unless its `cms.features` leaves them out. +- **Changed, on purpose, in a released changeset (the one recorded exception to "released changesets never change"):** `1.0.0-guard-existing-tables` no longer has `runAlways`. It rewrote its `DATABASECHANGELOG` row on every migration, so a second migration was never a no-op and a rollback by count began with it; a host whose migrations must be repeatable could not include the changelog. Only that attribute changed: the changeset's changes are what they were, so the checksum an existing install recorded is still its checksum and nothing is waived (`0.1.0-RC.3` carried `validCheckSum: ANY`, which was not needed and is removed). `CmsChangelogReleasedTest` migrates an install made by the `0.1.0-RC.2` changelog as tagged and asserts that its history rows are untouched, and from now on fails the build when any released changeset differs from `src/test/resources/released/qbit-cms.changelog.released.yaml`, runs on every migration or waives its checksum. What the guard no longer does: check for a name collision again at a later migration. A feature switched on later still cannot adopt a foreign table, because creating a table that exists fails; the message is the database's and not the guard's. +- Check constraints as in kof22: the value-list columns of `media_type`, `blog_post_version` and `project` (the project status check is new), `media_type.max_file_size_mb` above zero and the focal point of a project's image between 0 and 100. `project_category.section` is optional (kof22 requires it); latitude and longitude columns are `DOUBLE PRECISION` as in kof22. A host that already runs `CORE` gets the content tables at its next migration run unless its `cms.features` leaves them out. diff --git a/CLAUDE.md b/CLAUDE.md index ef560f1..24085a5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,7 +26,7 @@ Packages: - `metadata`: `CmsTableBuilder` (tables, possible values, joins, child lists, associations, permission rules), `CmsAppBuilder` and `CmsAreas` (apps and homes). - `home`: `CmsHomeRenderer` and `CmsHtml` (one renderer for every home; reads run with `PermissionEnforcement.ENFORCE`). - `security`: `CmsRole`, `CmsSecurity`, `CmsOpenReadsPermissionChecker`. -- Schema: `src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml`. Its changesets are append-only once released, and `docs/ddl/postgres.sql` is generated from it. +- Schema: `src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml`. Its changesets are append-only once released: `CmsChangelogReleasedTest` fails the build when a released changeset differs from `src/test/resources/released/qbit-cms.changelog.released.yaml`, when one runs on every migration or waives its checksum, and when an install of the first release does not migrate on. When a release is cut, copy the changelog over that file in the same change. `docs/ddl/postgres.sql` is generated from the changelog. ## Naming (owner rule) diff --git a/src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml b/src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml index ad8a41e..0e871b5 100644 --- a/src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml +++ b/src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml @@ -6,7 +6,9 @@ # cms.tablePrefix table name prefix, must equal CmsQBitConfig.tableNamePrefix (default cms_) # cms.features comma-separated CmsFeature names to install (default: all) # cms.seedReferenceData insert the generic redirect, page and section types (default true) -# Changesets are only ever appended; released changesets never change. +# Changesets are only ever appended; released changesets never change (CmsChangelogReleasedTest holds the build to +# it). One exception is recorded: 0.1.0-RC.3 took runAlways off 1.0.0-guard-existing-tables; its changes, and so +# its checksum, are what they were. databaseChangeLog: - property: { name: cms.tablePrefix, value: cms_ } - property: { name: cms.features, value: "CORE,MEDIA,BLOG,PROJECTS,PHOTOS,PUBLISHING,STREAM" } @@ -16,12 +18,12 @@ databaseChangeLog: # changelog (a name collision): choose another cms.tablePrefix. # It runs once, before the tables are created. Up to 0.1.0-RC.2 it ran on every migration (runAlways), which made # every run rewrite its row in DATABASECHANGELOG: a second migration was never a no-op and a rollback by count - # began with this changeset. An install that already ran it keeps its row; validCheckSum accepts what it recorded. + # began with this changeset. An install that already ran it keeps its row: the changes below are unchanged, so the + # checksum it recorded is still this changeset's, and nothing is waived. - changeSet: id: 1.0.0-guard-existing-tables author: qbit-cms logicalFilePath: qbit-cms/changelog - validCheckSum: ANY preConditions: - onFail: HALT - onFailMessage: "A table named ${cms.tablePrefix} exists but was not created by qbit-cms; set a different cms.tablePrefix" diff --git a/src/test/java/com/kingsrook/qbits/cms/CmsChangelogReleasedTest.java b/src/test/java/com/kingsrook/qbits/cms/CmsChangelogReleasedTest.java new file mode 100644 index 0000000..b15dba5 --- /dev/null +++ b/src/test/java/com/kingsrook/qbits/cms/CmsChangelogReleasedTest.java @@ -0,0 +1,157 @@ +/* + * Copyright © 2026. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com | https://github.com/Kingsrook/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.kingsrook.qbits.cms; + + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager; +import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData; +import org.junit.jupiter.api.Test; +import org.yaml.snakeyaml.Yaml; +import static org.assertj.core.api.Assertions.assertThat; + + +/******************************************************************************* + ** The changelog's contract with installs that already ran it: a released + ** changeset never changes, and new versions only append. + ** + ** Two files under src/test/resources/released hold what has shipped: + ** - qbit-cms.changelog-0.1.0-RC.2.yaml, the first release, as tagged. An + ** install made by it must migrate on with the current changelog, with no + ** checksum waiver, and its history must stay as it was. + ** - qbit-cms.changelog.released.yaml, the changelog as of the latest release. + ** Every changeset in it must be in the current changelog unchanged and in + ** the same order; new changesets go after them. When a release is cut, copy + ** the current changelog over that file in the same change. + ** + ** One exception is recorded: 0.1.0-RC.3 took runAlways off the first guard + ** changeset (it rewrote its history row on every migration). Its changes are + ** what they were, so its checksum is the one existing installs recorded. + *******************************************************************************/ +class CmsChangelogReleasedTest +{ + private static final String FIRST_RELEASE = "released/qbit-cms.changelog-0.1.0-RC.2.yaml"; + private static final String RELEASED = "released/qbit-cms.changelog.released.yaml"; + private static final String GUARD = "1.0.0-guard-existing-tables"; + + + + /******************************************************************************* + ** An install of the first release, migrated more than once as its guard did, + ** migrates on with the current changelog: no checksum is waived, the rows it + ** recorded are untouched, the content tables arrive, and a further migration + ** changes nothing. + *******************************************************************************/ + @Test + void testAnInstallOfTheFirstReleaseMigratesOn() throws Exception + { + RDBMSBackendMetaData backend = CmsTestSupport.h2Backend(); + CmsTestSupport.migrate(backend, FIRST_RELEASE, Map.of()); + CmsTestSupport.migrate(backend, FIRST_RELEASE, Map.of()); + Map first = history(backend); + assertThat(first).containsKey(GUARD); + assertThat(first.get(GUARD)).as("the first release ran its guard on every migration").contains("|RERAN"); + + CmsTestSupport.migrate(backend, Map.of()); + Map upgraded = history(backend); + for(Map.Entry row : first.entrySet()) + { + assertThat(upgraded.get(row.getKey())).as("the history row of " + row.getKey() + " after the upgrade").isEqualTo(row.getValue()); + } + assertThat(upgraded.keySet()).as("the content tables are created by the upgrade").contains("1.0.0-create-media", "1.0.0-create-blog_post"); + + CmsTestSupport.migrate(backend, Map.of()); + assertThat(history(backend)).as("the history after a further migration").isEqualTo(upgraded); + } + + + + /******************************************************************************* + ** Every released changeset is in the current changelog, unchanged and in the + ** same order; whatever is new comes after them. None runs on every migration. + *******************************************************************************/ + @Test + void testReleasedChangesetsNeverChange() throws Exception + { + List> released = changeSets(RELEASED); + List> current = changeSets(CmsQBitConfig.CHANGELOG); + assertThat(released).hasSizeGreaterThan(40); + assertThat(current.size()).as("changesets are only ever appended").isGreaterThanOrEqualTo(released.size()); + for(int i = 0; i < released.size(); i++) + { + assertThat(current.get(i)).as("released changeset " + released.get(i).get("id") + " (position " + i + ")").isEqualTo(released.get(i)); + } + for(Map changeSet : current) + { + assertThat(changeSet).as("changeset " + changeSet.get("id") + " must not run on every migration").doesNotContainKey("runAlways"); + assertThat(changeSet).as("changeset " + changeSet.get("id") + " must not waive its checksum").doesNotContainKey("validCheckSum"); + } + } + + + + /******************************************************************************* + ** The change sets of a changelog on the classpath, in file order. + *******************************************************************************/ + @SuppressWarnings("unchecked") + private static List> changeSets(String path) throws Exception + { + try(InputStream in = CmsChangelogReleasedTest.class.getClassLoader().getResourceAsStream(path)) + { + assertThat(in).as(path).isNotNull(); + Map root = new Yaml().load(in); + List> entries = (List>) root.get("databaseChangeLog"); + List> changeSets = new ArrayList<>(); + for(Map entry : entries) + { + if(entry.containsKey("changeSet")) + { + changeSets.add((Map) entry.get("changeSet")); + } + } + return (changeSets); + } + } + + + + /******************************************************************************* + ** The migration history by changeset id: order, date, checksum and how it ran. + *******************************************************************************/ + private static Map history(RDBMSBackendMetaData backend) throws Exception + { + Map rows = new LinkedHashMap<>(); + try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery("SELECT ID, ORDEREXECUTED, DATEEXECUTED, MD5SUM, EXECTYPE FROM DATABASECHANGELOG ORDER BY ORDEREXECUTED, ID")) + { + while(resultSet.next()) + { + rows.put(resultSet.getString(1), resultSet.getString(2) + "|" + resultSet.getString(3) + "|" + resultSet.getString(4) + "|" + resultSet.getString(5)); + } + } + return (rows); + } +} diff --git a/src/test/java/com/kingsrook/qbits/cms/CmsInstallTest.java b/src/test/java/com/kingsrook/qbits/cms/CmsInstallTest.java index 55d9439..bf09fe6 100644 --- a/src/test/java/com/kingsrook/qbits/cms/CmsInstallTest.java +++ b/src/test/java/com/kingsrook/qbits/cms/CmsInstallTest.java @@ -139,9 +139,8 @@ class CmsInstallTest /******************************************************************************* ** Running the changelog again changes nothing, the migration history - ** included: a host whose migrations must be repeatable can include it. An - ** install recorded by the earlier version, whose guard ran on every - ** migration, migrates on without complaint. + ** included: a host whose migrations must be repeatable can include it. + ** (An install of the first release migrating on: CmsChangelogReleasedTest.) *******************************************************************************/ @Test void testRerunIsNoop() throws Exception @@ -153,14 +152,6 @@ class CmsInstallTest assertThat(history(backend)).as("the migration history after a second run").isEqualTo(history); assertThat(history).hasSizeGreaterThan(40).anyMatch(row -> row.startsWith("1.0.0-guard-existing-tables|")); - try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement()) - { - statement.execute("UPDATE DATABASECHANGELOG SET MD5SUM = '9:00000000000000000000000000000000', EXECTYPE = 'RERAN' WHERE ID = '1.0.0-guard-existing-tables'"); - } - List earlier = history(backend); - CmsTestSupport.migrate(backend, Map.of()); - assertThat(history(backend)).as("the history of an install the earlier version recorded").isEqualTo(earlier); - QInstance qInstance = CmsTestSupport.blankInstance(backend); CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND); new CmsQBitProducer().withQBitConfig(config).produce(qInstance); diff --git a/src/test/java/com/kingsrook/qbits/cms/CmsTestSupport.java b/src/test/java/com/kingsrook/qbits/cms/CmsTestSupport.java index 8af0751..b3ab224 100644 --- a/src/test/java/com/kingsrook/qbits/cms/CmsTestSupport.java +++ b/src/test/java/com/kingsrook/qbits/cms/CmsTestSupport.java @@ -92,10 +92,20 @@ public final class CmsTestSupport ** with the given changelog properties. *******************************************************************************/ public static void migrate(RDBMSBackendMetaData backend, Map properties) throws Exception + { + migrate(backend, CmsQBitConfig.CHANGELOG, properties); + } + + + + /******************************************************************************* + ** Run a changelog of the classpath (a released one, for upgrade tests). + *******************************************************************************/ + public static void migrate(RDBMSBackendMetaData backend, String changelog, Map properties) throws Exception { Connection connection = ConnectionManager.getConnection(backend); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection)); - try(Liquibase liquibase = new Liquibase(CmsQBitConfig.CHANGELOG, new ClassLoaderResourceAccessor(), database)) + try(Liquibase liquibase = new Liquibase(changelog, new ClassLoaderResourceAccessor(), database)) { properties.forEach(liquibase::setChangeLogParameter); liquibase.update(new Contexts(), new LabelExpression()); diff --git a/src/test/resources/released/qbit-cms.changelog-0.1.0-RC.2.yaml b/src/test/resources/released/qbit-cms.changelog-0.1.0-RC.2.yaml new file mode 100644 index 0000000..909765b --- /dev/null +++ b/src/test/resources/released/qbit-cms.changelog-0.1.0-RC.2.yaml @@ -0,0 +1,1004 @@ +# qbit-cms schema, version 1.0.0 baseline. +# +# The host includes this file from the qbit jar and runs it with its own +# Liquibase (the qbit never runs DDL). Properties the host may set before the +# include (the first definition wins): +# cms.tablePrefix table name prefix, must equal CmsQBitConfig.tableNamePrefix (default cms_) +# cms.features comma-separated CmsFeature names to install (default: all) +# cms.seedReferenceData insert the generic redirect, page and section types (default true) +# Changesets are only ever appended; released changesets never change. +databaseChangeLog: + - property: { name: cms.tablePrefix, value: cms_ } + - property: { name: cms.features, value: "CORE,MEDIA,BLOG,PROJECTS,PHOTOS,PUBLISHING,STREAM" } + - property: { name: cms.seedReferenceData, value: "true" } + + # Halt when a table with a qbit-cms name exists but was not created by this + # changelog (a name collision): choose another cms.tablePrefix. + - changeSet: + id: 1.0.0-guard-existing-tables + author: qbit-cms + logicalFilePath: qbit-cms/changelog + runAlways: true + preConditions: + - onFail: HALT + - onFailMessage: "A table named ${cms.tablePrefix} exists but was not created by qbit-cms; set a different cms.tablePrefix" + - sqlCheck: + expectedResult: 0 + sql: >- + SELECT COUNT(*) FROM (VALUES ('site'), ('domain'), ('redirect_type'), ('redirect'), ('page_type'), ('page'), ('page_section_type'), ('page_section'), ('snippet'), ('menu'), ('menu_item')) AS v(n) + WHERE EXISTS (SELECT 1 FROM information_schema.tables t WHERE LOWER(t.table_name) = LOWER(CONCAT('${cms.tablePrefix}', v.n))) + AND NOT EXISTS (SELECT 1 FROM DATABASECHANGELOG c WHERE c.FILENAME = 'qbit-cms/changelog' AND c.ID = CONCAT('1.0.0-create-', v.n)) + changes: + - sql: + sql: SELECT 1 + + - changeSet: + id: 1.0.0-create-site + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}site + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}site", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}site + columnNames: name + constraintName: uq_${cms.tablePrefix}site_name + + - changeSet: + id: 1.0.0-create-domain + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}domain + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}domain", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: fqdn + type: VARCHAR(255) + constraints: { nullable: false } + - column: + name: is_primary + type: BOOLEAN + constraints: { nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}domain + columnNames: short_name + constraintName: uq_${cms.tablePrefix}domain_short_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}domain + columnNames: name + constraintName: uq_${cms.tablePrefix}domain_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}domain + columnNames: fqdn + constraintName: uq_${cms.tablePrefix}domain_fqdn + + - changeSet: + id: 1.0.0-create-redirect_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}redirect_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(500) + - column: + name: http_status_code + type: INT + constraints: { nullable: false } + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}redirect_type + columnNames: code + constraintName: uq_${cms.tablePrefix}redirect_type_code + + - changeSet: + id: 1.0.0-create-redirect + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}redirect + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}redirect", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(500) + - column: + name: source_path + type: VARCHAR(500) + constraints: { nullable: false } + - column: + name: target_path + type: VARCHAR(500) + constraints: { nullable: false } + - column: + name: redirect_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: match_type + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: priority + type: INT + constraints: { nullable: false } + - column: + name: preserve_query_params + type: BOOLEAN + constraints: { nullable: false } + - column: + name: hit_count + type: BIGINT + constraints: { nullable: false } + - column: + name: last_hit_date + type: TIMESTAMP + - column: + name: expiry_date + type: TIMESTAMP + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-create-page_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_type + columnNames: name + constraintName: uq_${cms.tablePrefix}page_type_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_type + columnNames: code + constraintName: uq_${cms.tablePrefix}page_type_code + + - changeSet: + id: 1.0.0-create-page + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: content + type: TEXT + - column: + name: page_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: template + type: VARCHAR(50) + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: publish_date + type: TIMESTAMP + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: parent_page_id + type: BIGINT + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: meta_description + type: VARCHAR(500) + - column: + name: meta_keywords + type: VARCHAR(255) + - column: + name: og_image + type: VARCHAR(255) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}page_slug_site_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page + columnNames: slug, parent_page_id + constraintName: uq_${cms.tablePrefix}page_slug_parent_page_id + + - changeSet: + id: 1.0.0-create-page_section_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page_section_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_section_type + columnNames: code + constraintName: uq_${cms.tablePrefix}page_section_type_code + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_section_type + columnNames: name + constraintName: uq_${cms.tablePrefix}page_section_type_name + + - changeSet: + id: 1.0.0-create-page_section + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page_section + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page_section", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: css_class_name + type: VARCHAR(255) + - column: + name: section_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: content + type: TEXT + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: page_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-create-snippet + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}snippet + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}snippet", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: content + type: TEXT + - column: + name: css_class_name + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}snippet + columnNames: short_name, site_id + constraintName: uq_${cms.tablePrefix}snippet_short_name_site_id + + - changeSet: + id: 1.0.0-create-menu + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}menu + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}menu", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: menu_type + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: is_active + type: BOOLEAN + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}menu + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}menu_slug_site_id + + - changeSet: + id: 1.0.0-create-menu_item + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}menu_item + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}menu_item", nullable: false } + - column: + name: menu_id + type: BIGINT + constraints: { nullable: false } + - column: + name: parent_id + type: BIGINT + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: item_type + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: link_url + type: VARCHAR(500) + - column: + name: route_path + type: VARCHAR(200) + - column: + name: target + type: VARCHAR(20) + - column: + name: icon + type: VARCHAR(100) + - column: + name: description + type: VARCHAR(255) + - column: + name: display_order + type: INT + - column: + name: is_active + type: BOOLEAN + - column: + name: css_classes + type: VARCHAR(200) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-constraints-core + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}domain + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}domain_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}redirect + baseColumnNames: redirect_type_id + referencedTableName: ${cms.tablePrefix}redirect_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}redirect_redirect_type_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}redirect + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}redirect_site_id + - createIndex: + tableName: ${cms.tablePrefix}redirect + indexName: idx_${cms.tablePrefix}redirect_site_id_source_path + columns: + - column: { name: site_id } + - column: { name: source_path } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page + baseColumnNames: page_type_id + referencedTableName: ${cms.tablePrefix}page_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_page_type_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page + baseColumnNames: parent_page_id + referencedTableName: ${cms.tablePrefix}page + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_parent_page_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_site_id + - createIndex: + tableName: ${cms.tablePrefix}page + indexName: idx_${cms.tablePrefix}page_site_id_is_published + columns: + - column: { name: site_id } + - column: { name: is_published } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page_section + baseColumnNames: page_id + referencedTableName: ${cms.tablePrefix}page + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_section_page_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page_section + baseColumnNames: section_type_id + referencedTableName: ${cms.tablePrefix}page_section_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_section_section_type_id + - createIndex: + tableName: ${cms.tablePrefix}page_section + indexName: idx_${cms.tablePrefix}page_section_page_id + columns: + - column: { name: page_id } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}snippet + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}snippet_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}menu + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}menu_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}menu_item + baseColumnNames: menu_id + referencedTableName: ${cms.tablePrefix}menu + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}menu_item_menu_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}menu_item + baseColumnNames: parent_id + referencedTableName: ${cms.tablePrefix}menu_item + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}menu_item_parent_id + - createIndex: + tableName: ${cms.tablePrefix}menu_item + indexName: idx_${cms.tablePrefix}menu_item_menu_id + columns: + - column: { name: menu_id } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-redirect_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Permanent Redirect" } + - column: { name: code, value: "PERMANENT" } + - column: { name: description, value: "301 Moved Permanently - Use for permanent URL changes" } + - column: { name: http_status_code, valueNumeric: 301 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Temporary Redirect" } + - column: { name: code, value: "TEMPORARY" } + - column: { name: description, value: "302 Found - Use for temporary URL changes" } + - column: { name: http_status_code, valueNumeric: 302 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Permanent Redirect (Alternative)" } + - column: { name: code, value: "PERMANENT_ALT" } + - column: { name: description, value: "308 Permanent Redirect - Preserves HTTP method" } + - column: { name: http_status_code, valueNumeric: 308 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 3 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Temporary Redirect (Alternative)" } + - column: { name: code, value: "TEMPORARY_ALT" } + - column: { name: description, value: "307 Temporary Redirect - Preserves HTTP method" } + - column: { name: http_status_code, valueNumeric: 307 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 4 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-page_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Static Page" } + - column: { name: code, value: "STATIC" } + - column: { name: description, value: "A standard static page" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Dynamic Page" } + - column: { name: code, value: "DYNAMIC" } + - column: { name: description, value: "A page with dynamic content" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Landing Page" } + - column: { name: code, value: "LANDING" } + - column: { name: description, value: "A marketing or landing page" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 3 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Custom Page" } + - column: { name: code, value: "CUSTOM" } + - column: { name: description, value: "A custom page type" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 4 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-page_section_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Text Content" } + - column: { name: code, value: "TEXT" } + - column: { name: description, value: "General text content section for displaying formatted text" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Hero Section" } + - column: { name: code, value: "HERO" } + - column: { name: description, value: "Hero section typically used for page headers and banners" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Gallery" } + - column: { name: code, value: "GALLERY" } + - column: { name: description, value: "Displays images or media in a gallery format" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 5 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Contact Form" } + - column: { name: code, value: "CONTACT_FORM" } + - column: { name: description, value: "Displays a contact form" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 6 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Blog List" } + - column: { name: code, value: "BLOG_LIST" } + - column: { name: description, value: "Displays blog posts in a list format" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 7 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Markdown Content" } + - column: { name: code, value: "MARKDOWN" } + - column: { name: description, value: "Displays markdown-formatted content" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 9 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Featured Posts" } + - column: { name: code, value: "FEATURED_POSTS" } + - column: { name: description, value: "Displays latest featured blog posts in a grid" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 10 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Social Links" } + - column: { name: code, value: "SOCIAL_LINKS" } + - column: { name: description, value: "Displays social media links with icons" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 11 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Image Carousel" } + - column: { name: code, value: "IMAGE_CAROUSEL" } + - column: { name: description, value: "Displays images in a rotating carousel" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 12 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + diff --git a/src/test/resources/released/qbit-cms.changelog.released.yaml b/src/test/resources/released/qbit-cms.changelog.released.yaml new file mode 100644 index 0000000..0e871b5 --- /dev/null +++ b/src/test/resources/released/qbit-cms.changelog.released.yaml @@ -0,0 +1,2996 @@ +# qbit-cms schema, version 1.0.0 baseline. +# +# The host includes this file from the qbit jar and runs it with its own +# Liquibase (the qbit never runs DDL). Properties the host may set before the +# include (the first definition wins): +# cms.tablePrefix table name prefix, must equal CmsQBitConfig.tableNamePrefix (default cms_) +# cms.features comma-separated CmsFeature names to install (default: all) +# cms.seedReferenceData insert the generic redirect, page and section types (default true) +# Changesets are only ever appended; released changesets never change (CmsChangelogReleasedTest holds the build to +# it). One exception is recorded: 0.1.0-RC.3 took runAlways off 1.0.0-guard-existing-tables; its changes, and so +# its checksum, are what they were. +databaseChangeLog: + - property: { name: cms.tablePrefix, value: cms_ } + - property: { name: cms.features, value: "CORE,MEDIA,BLOG,PROJECTS,PHOTOS,PUBLISHING,STREAM" } + - property: { name: cms.seedReferenceData, value: "true" } + + # Halt when a table with a qbit-cms name exists but was not created by this + # changelog (a name collision): choose another cms.tablePrefix. + # It runs once, before the tables are created. Up to 0.1.0-RC.2 it ran on every migration (runAlways), which made + # every run rewrite its row in DATABASECHANGELOG: a second migration was never a no-op and a rollback by count + # began with this changeset. An install that already ran it keeps its row: the changes below are unchanged, so the + # checksum it recorded is still this changeset's, and nothing is waived. + - changeSet: + id: 1.0.0-guard-existing-tables + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: HALT + - onFailMessage: "A table named ${cms.tablePrefix} exists but was not created by qbit-cms; set a different cms.tablePrefix" + - sqlCheck: + expectedResult: 0 + sql: >- + SELECT COUNT(*) FROM (VALUES ('site'), ('domain'), ('redirect_type'), ('redirect'), ('page_type'), ('page'), ('page_section_type'), ('page_section'), ('snippet'), ('menu'), ('menu_item')) AS v(n) + WHERE EXISTS (SELECT 1 FROM information_schema.tables t WHERE LOWER(t.table_name) = LOWER(CONCAT('${cms.tablePrefix}', v.n))) + AND NOT EXISTS (SELECT 1 FROM DATABASECHANGELOG c WHERE c.FILENAME = 'qbit-cms/changelog' AND c.ID = CONCAT('1.0.0-create-', v.n)) + changes: + - sql: + sql: SELECT 1 + + - changeSet: + id: 1.0.0-create-site + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}site + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}site", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}site + columnNames: name + constraintName: uq_${cms.tablePrefix}site_name + + - changeSet: + id: 1.0.0-create-domain + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}domain + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}domain", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: fqdn + type: VARCHAR(255) + constraints: { nullable: false } + - column: + name: is_primary + type: BOOLEAN + constraints: { nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}domain + columnNames: short_name + constraintName: uq_${cms.tablePrefix}domain_short_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}domain + columnNames: name + constraintName: uq_${cms.tablePrefix}domain_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}domain + columnNames: fqdn + constraintName: uq_${cms.tablePrefix}domain_fqdn + + - changeSet: + id: 1.0.0-create-redirect_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}redirect_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(500) + - column: + name: http_status_code + type: INT + constraints: { nullable: false } + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}redirect_type + columnNames: code + constraintName: uq_${cms.tablePrefix}redirect_type_code + + - changeSet: + id: 1.0.0-create-redirect + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}redirect + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}redirect", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(500) + - column: + name: source_path + type: VARCHAR(500) + constraints: { nullable: false } + - column: + name: target_path + type: VARCHAR(500) + constraints: { nullable: false } + - column: + name: redirect_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: match_type + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: priority + type: INT + constraints: { nullable: false } + - column: + name: preserve_query_params + type: BOOLEAN + constraints: { nullable: false } + - column: + name: hit_count + type: BIGINT + constraints: { nullable: false } + - column: + name: last_hit_date + type: TIMESTAMP + - column: + name: expiry_date + type: TIMESTAMP + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-create-page_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_type + columnNames: name + constraintName: uq_${cms.tablePrefix}page_type_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_type + columnNames: code + constraintName: uq_${cms.tablePrefix}page_type_code + + - changeSet: + id: 1.0.0-create-page + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: content + type: TEXT + - column: + name: page_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: template + type: VARCHAR(50) + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: publish_date + type: TIMESTAMP + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: parent_page_id + type: BIGINT + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: meta_description + type: VARCHAR(500) + - column: + name: meta_keywords + type: VARCHAR(255) + - column: + name: og_image + type: VARCHAR(255) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}page_slug_site_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page + columnNames: slug, parent_page_id + constraintName: uq_${cms.tablePrefix}page_slug_parent_page_id + + - changeSet: + id: 1.0.0-create-page_section_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page_section_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_section_type + columnNames: code + constraintName: uq_${cms.tablePrefix}page_section_type_code + - addUniqueConstraint: + tableName: ${cms.tablePrefix}page_section_type + columnNames: name + constraintName: uq_${cms.tablePrefix}page_section_type_name + + - changeSet: + id: 1.0.0-create-page_section + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}page_section + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}page_section", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: css_class_name + type: VARCHAR(255) + - column: + name: section_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: content + type: TEXT + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: page_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-create-snippet + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}snippet + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}snippet", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: content + type: TEXT + - column: + name: css_class_name + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}snippet + columnNames: short_name, site_id + constraintName: uq_${cms.tablePrefix}snippet_short_name_site_id + + - changeSet: + id: 1.0.0-create-menu + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}menu + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}menu", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: menu_type + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: is_active + type: BOOLEAN + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}menu + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}menu_slug_site_id + + - changeSet: + id: 1.0.0-create-menu_item + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}menu_item + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}menu_item", nullable: false } + - column: + name: menu_id + type: BIGINT + constraints: { nullable: false } + - column: + name: parent_id + type: BIGINT + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: item_type + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: link_url + type: VARCHAR(500) + - column: + name: route_path + type: VARCHAR(200) + - column: + name: target + type: VARCHAR(20) + - column: + name: icon + type: VARCHAR(100) + - column: + name: description + type: VARCHAR(255) + - column: + name: display_order + type: INT + - column: + name: is_active + type: BOOLEAN + - column: + name: css_classes + type: VARCHAR(200) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-constraints-core + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}domain + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}domain_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}redirect + baseColumnNames: redirect_type_id + referencedTableName: ${cms.tablePrefix}redirect_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}redirect_redirect_type_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}redirect + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}redirect_site_id + - createIndex: + tableName: ${cms.tablePrefix}redirect + indexName: idx_${cms.tablePrefix}redirect_site_id_source_path + columns: + - column: { name: site_id } + - column: { name: source_path } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page + baseColumnNames: page_type_id + referencedTableName: ${cms.tablePrefix}page_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_page_type_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page + baseColumnNames: parent_page_id + referencedTableName: ${cms.tablePrefix}page + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_parent_page_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_site_id + - createIndex: + tableName: ${cms.tablePrefix}page + indexName: idx_${cms.tablePrefix}page_site_id_is_published + columns: + - column: { name: site_id } + - column: { name: is_published } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page_section + baseColumnNames: page_id + referencedTableName: ${cms.tablePrefix}page + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_section_page_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}page_section + baseColumnNames: section_type_id + referencedTableName: ${cms.tablePrefix}page_section_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}page_section_section_type_id + - createIndex: + tableName: ${cms.tablePrefix}page_section + indexName: idx_${cms.tablePrefix}page_section_page_id + columns: + - column: { name: page_id } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}snippet + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}snippet_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}menu + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}menu_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}menu_item + baseColumnNames: menu_id + referencedTableName: ${cms.tablePrefix}menu + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}menu_item_menu_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}menu_item + baseColumnNames: parent_id + referencedTableName: ${cms.tablePrefix}menu_item + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}menu_item_parent_id + - createIndex: + tableName: ${cms.tablePrefix}menu_item + indexName: idx_${cms.tablePrefix}menu_item_menu_id + columns: + - column: { name: menu_id } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-redirect_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Permanent Redirect" } + - column: { name: code, value: "PERMANENT" } + - column: { name: description, value: "301 Moved Permanently - Use for permanent URL changes" } + - column: { name: http_status_code, valueNumeric: 301 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Temporary Redirect" } + - column: { name: code, value: "TEMPORARY" } + - column: { name: description, value: "302 Found - Use for temporary URL changes" } + - column: { name: http_status_code, valueNumeric: 302 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Permanent Redirect (Alternative)" } + - column: { name: code, value: "PERMANENT_ALT" } + - column: { name: description, value: "308 Permanent Redirect - Preserves HTTP method" } + - column: { name: http_status_code, valueNumeric: 308 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 3 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}redirect_type + columns: + - column: { name: name, value: "Temporary Redirect (Alternative)" } + - column: { name: code, value: "TEMPORARY_ALT" } + - column: { name: description, value: "307 Temporary Redirect - Preserves HTTP method" } + - column: { name: http_status_code, valueNumeric: 307 } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 4 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-page_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Static Page" } + - column: { name: code, value: "STATIC" } + - column: { name: description, value: "A standard static page" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Dynamic Page" } + - column: { name: code, value: "DYNAMIC" } + - column: { name: description, value: "A page with dynamic content" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Landing Page" } + - column: { name: code, value: "LANDING" } + - column: { name: description, value: "A marketing or landing page" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 3 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_type + columns: + - column: { name: name, value: "Custom Page" } + - column: { name: code, value: "CUSTOM" } + - column: { name: description, value: "A custom page type" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 4 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-page_section_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Text Content" } + - column: { name: code, value: "TEXT" } + - column: { name: description, value: "General text content section for displaying formatted text" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Hero Section" } + - column: { name: code, value: "HERO" } + - column: { name: description, value: "Hero section typically used for page headers and banners" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Gallery" } + - column: { name: code, value: "GALLERY" } + - column: { name: description, value: "Displays images or media in a gallery format" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 5 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Contact Form" } + - column: { name: code, value: "CONTACT_FORM" } + - column: { name: description, value: "Displays a contact form" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 6 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Blog List" } + - column: { name: code, value: "BLOG_LIST" } + - column: { name: description, value: "Displays blog posts in a list format" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 7 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Markdown Content" } + - column: { name: code, value: "MARKDOWN" } + - column: { name: description, value: "Displays markdown-formatted content" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 9 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Featured Posts" } + - column: { name: code, value: "FEATURED_POSTS" } + - column: { name: description, value: "Displays latest featured blog posts in a grid" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 10 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Social Links" } + - column: { name: code, value: "SOCIAL_LINKS" } + - column: { name: description, value: "Displays social media links with icons" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 11 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}page_section_type + columns: + - column: { name: name, value: "Image Carousel" } + - column: { name: code, value: "IMAGE_CAROUSEL" } + - column: { name: description, value: "Displays images in a rotating carousel" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 12 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + + # The content features: media, blogs, projects and photos (tables of a feature that is not in cms.features are + # skipped, and are created by a later run that names it). Every one of them needs CORE, and blogs, projects and photos + # need MEDIA, so a feature whose needs are not in cms.features installs nothing. + + # Halt when a table with a content-feature name already exists (a name collision): choose another cms.tablePrefix. + # Runs once, before any of these tables is created. + - changeSet: + id: 1.0.0-guard-existing-content-tables + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: HALT + - onFailMessage: "A table named ${cms.tablePrefix} exists but was not created by qbit-cms; set a different cms.tablePrefix" + - sqlCheck: + expectedResult: 0 + sql: >- + SELECT COUNT(*) FROM (VALUES ('media_type'), ('media'), ('blog_type'), ('blog'), ('author'), ('blog_tag'), ('blog_post'), ('blog_post_tag_int'), ('blog_post_media'), ('blog_post_version'), ('project_category'), ('project'), ('project_update'), ('photo_album_folder'), ('photo_album'), ('photo'), ('photo_tag'), ('photo_tag_int')) AS v(n) + WHERE EXISTS (SELECT 1 FROM information_schema.tables t WHERE LOWER(t.table_name) = LOWER(CONCAT('${cms.tablePrefix}', v.n))) + changes: + - sql: + sql: SELECT 1 + + - changeSet: + id: 1.0.0-create-media_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}media_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}media_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(500) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: allowed_mime_types + type: VARCHAR(1000) + - column: + name: allowed_extensions + type: VARCHAR(500) + - column: + name: max_file_size_mb + type: INT + - column: + name: thumbnail_enabled + type: BOOLEAN + constraints: { nullable: false } + - column: + name: thumbnail_width + type: INT + - column: + name: thumbnail_format + type: VARCHAR(10) + constraints: { nullable: false } + - column: + name: thumbnail_quality + type: INT + - column: + name: gallery_enabled + type: BOOLEAN + constraints: { nullable: false } + - column: + name: gallery_width + type: INT + - column: + name: gallery_format + type: VARCHAR(10) + constraints: { nullable: false } + - column: + name: gallery_quality + type: INT + - column: + name: slideshow_enabled + type: BOOLEAN + constraints: { nullable: false } + - column: + name: slideshow_width + type: INT + - column: + name: slideshow_format + type: VARCHAR(10) + constraints: { nullable: false } + - column: + name: slideshow_quality + type: INT + - column: + name: strip_metadata + type: BOOLEAN + constraints: { nullable: false } + - column: + name: require_alt_text + type: BOOLEAN + constraints: { nullable: false } + - column: + name: require_caption + type: BOOLEAN + constraints: { nullable: false } + - column: + name: default_credit + type: VARCHAR(500) + - column: + name: default_license + type: VARCHAR(500) + - column: + name: cache_class + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: storage_prefix + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}media_type + columnNames: code + constraintName: uq_${cms.tablePrefix}media_type_code + + - changeSet: + id: 1.0.0-create-media + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}media + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}media", nullable: false } + - column: + name: name + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + - column: + name: description + type: VARCHAR(500) + - column: + name: alt_text + type: VARCHAR(1000) + - column: + name: caption + type: VARCHAR(2000) + - column: + name: credit + type: VARCHAR(500) + - column: + name: license + type: VARCHAR(500) + - column: + name: media_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: file_name + type: VARCHAR(255) + - column: + name: file_extension + type: VARCHAR(20) + - column: + name: mime_type + type: VARCHAR(100) + - column: + name: file_size + type: BIGINT + - column: + name: width + type: INT + - column: + name: height + type: INT + - column: + name: duration + type: INT + - column: + name: checksum + type: VARCHAR(64) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: public_url + type: VARCHAR(500) + - column: + name: storage_key + type: VARCHAR(500) + - column: + name: thumbnail_url + type: VARCHAR(500) + - column: + name: gallery_url + type: VARCHAR(500) + - column: + name: slideshow_url + type: VARCHAR(500) + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + + - changeSet: + id: 1.0.0-create-blog_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog_type + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog_type", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: code + type: VARCHAR(50) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: is_active + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_type + columnNames: name + constraintName: uq_${cms.tablePrefix}blog_type_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_type + columnNames: code + constraintName: uq_${cms.tablePrefix}blog_type_code + + - changeSet: + id: 1.0.0-create-blog + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog", nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: slug + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: blog_type_id + type: BIGINT + constraints: { nullable: false } + - column: + name: meta_title + type: VARCHAR(255) + - column: + name: meta_description + type: VARCHAR(500) + - column: + name: meta_keywords + type: VARCHAR(255) + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog + columnNames: name + constraintName: uq_${cms.tablePrefix}blog_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}blog_slug_site_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog + columnNames: short_name + constraintName: uq_${cms.tablePrefix}blog_short_name + + - changeSet: + id: 1.0.0-create-author + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}author + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}author", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: slug + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: email + type: VARCHAR(255) + - column: + name: profile_media_id + type: BIGINT + - column: + name: profile_image_url + type: VARCHAR(500) + - column: + name: website + type: VARCHAR(255) + - column: + name: social_links + type: TEXT + - column: + name: is_active + type: BOOLEAN + - column: + name: display_order + type: INT + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}author + columnNames: name + constraintName: uq_${cms.tablePrefix}author_name + - addUniqueConstraint: + tableName: ${cms.tablePrefix}author + columnNames: slug + constraintName: uq_${cms.tablePrefix}author_slug + + - changeSet: + id: 1.0.0-create-blog_tag + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog_tag + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog_tag", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: blog_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_tag + columnNames: name, blog_id + constraintName: uq_${cms.tablePrefix}blog_tag_name_blog_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_tag + columnNames: slug, blog_id + constraintName: uq_${cms.tablePrefix}blog_tag_slug_blog_id + + - changeSet: + id: 1.0.0-create-blog_post + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog_post + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog_post", nullable: false } + - column: + name: name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: title + type: VARCHAR(100) + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: content + type: TEXT + constraints: { nullable: false } + - column: + name: author_id + type: BIGINT + constraints: { nullable: false } + - column: + name: blog_id + type: BIGINT + constraints: { nullable: false } + - column: + name: is_published + type: BOOLEAN + - column: + name: publish_date + type: TIMESTAMP + - column: + name: featured_media_id + type: BIGINT + - column: + name: featured_image + type: VARCHAR(255) + - column: + name: meta_title + type: VARCHAR(255) + - column: + name: meta_description + type: VARCHAR(500) + - column: + name: meta_keywords + type: VARCHAR(255) + - column: + name: read_time + type: INT + - column: + name: view_count + type: BIGINT + - column: + name: is_featured + type: BOOLEAN + constraints: { nullable: false } + - column: + name: excerpt + type: TEXT + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post + columnNames: name, blog_id + constraintName: uq_${cms.tablePrefix}blog_post_name_blog_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post + columnNames: short_name, blog_id + constraintName: uq_${cms.tablePrefix}blog_post_short_name_blog_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post + columnNames: slug, blog_id + constraintName: uq_${cms.tablePrefix}blog_post_slug_blog_id + + - changeSet: + id: 1.0.0-create-blog_post_tag_int + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog_post_tag_int + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog_post_tag_int", nullable: false } + - column: + name: blog_post_id + type: BIGINT + constraints: { nullable: false } + - column: + name: blog_tag_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post_tag_int + columnNames: blog_post_id, blog_tag_id + constraintName: uq_${cms.tablePrefix}blog_post_tag_int_blog_post_id_blog_tag_id + + - changeSet: + id: 1.0.0-create-blog_post_media + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog_post_media + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog_post_media", nullable: false } + - column: + name: blog_post_id + type: BIGINT + constraints: { nullable: false } + - column: + name: media_id + type: BIGINT + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: alt_text + type: VARCHAR(1000) + - column: + name: caption + type: VARCHAR(2000) + - column: + name: url + type: VARCHAR(1000) + constraints: { nullable: false } + - column: + name: thumbnail_url + type: VARCHAR(1000) + - column: + name: width + type: INT + - column: + name: height + type: INT + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post_media + columnNames: blog_post_id, media_id + constraintName: uq_${cms.tablePrefix}blog_post_media_blog_post_id_media_id + + - changeSet: + id: 1.0.0-create-blog_post_version + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}blog_post_version + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}blog_post_version", nullable: false } + - column: + name: blog_post_id + type: BIGINT + - column: + name: project_id + type: BIGINT + - column: + name: project_update_id + type: BIGINT + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: variant_key + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: channel + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + - column: + name: content + type: TEXT + constraints: { nullable: false } + - column: + name: content_format + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: status + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: source_digest + type: VARCHAR(64) + - column: + name: source_commit + type: VARCHAR(64) + - column: + name: published_url + type: VARCHAR(2000) + - column: + name: published_date + type: TIMESTAMP + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post_version + columnNames: blog_post_id, variant_key + constraintName: uq_${cms.tablePrefix}blog_post_version_blog_post_id_variant_key + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post_version + columnNames: project_id, variant_key + constraintName: uq_${cms.tablePrefix}blog_post_version_project_id_variant_key + - addUniqueConstraint: + tableName: ${cms.tablePrefix}blog_post_version + columnNames: project_update_id, variant_key + constraintName: uq_${cms.tablePrefix}blog_post_version_project_update_id_variant_key + + - changeSet: + id: 1.0.0-create-project_category + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PROJECTS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}project_category + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}project_category", nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: section + type: VARCHAR(20) + - column: + name: description + type: VARCHAR(1000) + - column: + name: featured_media_id + type: BIGINT + - column: + name: featured_image + type: VARCHAR(500) + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}project_category + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}project_category_slug_site_id + + - changeSet: + id: 1.0.0-create-project + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PROJECTS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}project + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}project", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: description + type: TEXT + - column: + name: content + type: TEXT + - column: + name: project_status + type: VARCHAR(20) + constraints: { nullable: false } + - column: + name: github_url + type: VARCHAR(255) + - column: + name: live_url + type: VARCHAR(255) + - column: + name: featured_media_id + type: BIGINT + - column: + name: featured_image + type: VARCHAR(255) + - column: + name: image_alt + type: VARCHAR(500) + - column: + name: image_caption + type: VARCHAR(1000) + - column: + name: image_focal_x + type: INT + - column: + name: image_focal_y + type: INT + - column: + name: start_date + type: TIMESTAMP + - column: + name: end_date + type: TIMESTAMP + - column: + name: is_featured + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: category_id + type: BIGINT + constraints: { nullable: false } + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: publish_date + type: TIMESTAMP + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}project + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}project_slug_site_id + + - changeSet: + id: 1.0.0-create-project_update + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PROJECTS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}project_update + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}project_update", nullable: false } + - column: + name: project_id + type: BIGINT + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: excerpt + type: VARCHAR(1000) + - column: + name: content + type: TEXT + constraints: { nullable: false } + - column: + name: update_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: publish_date + type: TIMESTAMP + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: featured_media_id + type: BIGINT + - column: + name: featured_image + type: VARCHAR(500) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}project_update + columnNames: slug, project_id + constraintName: uq_${cms.tablePrefix}project_update_slug_project_id + + - changeSet: + id: 1.0.0-create-photo_album_folder + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}photo_album_folder + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}photo_album_folder", nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: parent_id + type: BIGINT + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(500) + - column: + name: folder_image_url + type: VARCHAR(500) + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: meta_title + type: VARCHAR(255) + - column: + name: meta_description + type: VARCHAR(500) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo_album_folder + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}photo_album_folder_slug_site_id + + - changeSet: + id: 1.0.0-create-photo_album + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}photo_album + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}photo_album", nullable: false } + - column: + name: site_id + type: BIGINT + constraints: { nullable: false } + - column: + name: photo_album_folder_id + type: BIGINT + - column: + name: project_id + type: BIGINT + - column: + name: project_update_id + type: BIGINT + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: short_name + type: VARCHAR(40) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: title + type: VARCHAR(200) + - column: + name: description + type: VARCHAR(1000) + - column: + name: cover_photo_id + type: BIGINT + - column: + name: cover_image_url + type: VARCHAR(500) + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: publish_date + type: TIMESTAMP + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: location + type: VARCHAR(200) + - column: + name: location_latitude + type: DOUBLE + - column: + name: location_longitude + type: DOUBLE + - column: + name: album_date + type: TIMESTAMP + - column: + name: album_end_date + type: TIMESTAMP + - column: + name: primary_camera + type: VARCHAR(100) + - column: + name: primary_lens + type: VARCHAR(100) + - column: + name: weather + type: VARCHAR(100) + - column: + name: meta_title + type: VARCHAR(255) + - column: + name: meta_description + type: VARCHAR(500) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo_album + columnNames: slug, site_id + constraintName: uq_${cms.tablePrefix}photo_album_slug_site_id + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo_album + columnNames: short_name, site_id + constraintName: uq_${cms.tablePrefix}photo_album_short_name_site_id + + - changeSet: + id: 1.0.0-create-photo + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}photo + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}photo", nullable: false } + - column: + name: photo_album_id + type: BIGINT + constraints: { nullable: false } + - column: + name: media_id + type: BIGINT + - column: + name: title + type: VARCHAR(200) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: caption + type: VARCHAR(500) + - column: + name: description + type: VARCHAR(1000) + - column: + name: score + type: INT + - column: + name: is_favorite + type: BOOLEAN + constraints: { nullable: false } + - column: + name: is_album_cover + type: BOOLEAN + constraints: { nullable: false } + - column: + name: sort_order + type: INT + constraints: { nullable: false } + - column: + name: is_published + type: BOOLEAN + constraints: { nullable: false } + - column: + name: publish_date + type: TIMESTAMP + - column: + name: original_url + type: VARCHAR(500) + - column: + name: gallery_url + type: VARCHAR(500) + - column: + name: slideshow_url + type: VARCHAR(500) + - column: + name: thumbnail_url + type: VARCHAR(500) + - column: + name: original_filename + type: VARCHAR(255) + - column: + name: storage_key + type: VARCHAR(500) + - column: + name: mime_type + type: VARCHAR(100) + - column: + name: file_size + type: BIGINT + - column: + name: width + type: INT + - column: + name: height + type: INT + - column: + name: exif_date_taken + type: TIMESTAMP + - column: + name: exif_camera_make + type: VARCHAR(100) + - column: + name: exif_camera_model + type: VARCHAR(100) + - column: + name: exif_lens_model + type: VARCHAR(200) + - column: + name: exif_focal_length + type: VARCHAR(20) + - column: + name: exif_aperture + type: VARCHAR(20) + - column: + name: exif_shutter_speed + type: VARCHAR(20) + - column: + name: exif_iso + type: INT + - column: + name: exif_white_balance + type: VARCHAR(50) + - column: + name: exif_flash + type: VARCHAR(50) + - column: + name: exif_gps_latitude + type: DOUBLE + - column: + name: exif_gps_longitude + type: DOUBLE + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo + columnNames: slug, photo_album_id + constraintName: uq_${cms.tablePrefix}photo_slug_photo_album_id + + - changeSet: + id: 1.0.0-create-photo_tag + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}photo_tag + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}photo_tag", nullable: false } + - column: + name: name + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: slug + type: VARCHAR(100) + constraints: { nullable: false } + - column: + name: description + type: VARCHAR(255) + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo_tag + columnNames: slug + constraintName: uq_${cms.tablePrefix}photo_tag_slug + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo_tag + columnNames: name + constraintName: uq_${cms.tablePrefix}photo_tag_name + + - changeSet: + id: 1.0.0-create-photo_tag_int + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - createTable: + tableName: ${cms.tablePrefix}photo_tag_int + columns: + - column: + name: id + type: BIGINT + autoIncrement: true + constraints: { primaryKey: true, primaryKeyName: "pk_${cms.tablePrefix}photo_tag_int", nullable: false } + - column: + name: photo_id + type: BIGINT + constraints: { nullable: false } + - column: + name: photo_tag_id + type: BIGINT + constraints: { nullable: false } + - column: + name: create_date + type: TIMESTAMP + constraints: { nullable: false } + - column: + name: modify_date + type: TIMESTAMP + constraints: { nullable: false } + - addUniqueConstraint: + tableName: ${cms.tablePrefix}photo_tag_int + columnNames: photo_id, photo_tag_id + constraintName: uq_${cms.tablePrefix}photo_tag_int_photo_id_photo_tag_id + + - changeSet: + id: 1.0.0-constraints-media + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - sql: + sql: ALTER TABLE ${cms.tablePrefix}media_type ADD CONSTRAINT ck_${cms.tablePrefix}media_type_thumbnail_format CHECK (thumbnail_format IN ('JPEG', 'PNG', 'WEBP')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}media_type ADD CONSTRAINT ck_${cms.tablePrefix}media_type_gallery_format CHECK (gallery_format IN ('JPEG', 'PNG', 'WEBP')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}media_type ADD CONSTRAINT ck_${cms.tablePrefix}media_type_slideshow_format CHECK (slideshow_format IN ('JPEG', 'PNG', 'WEBP')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}media_type ADD CONSTRAINT ck_${cms.tablePrefix}media_type_cache_class CHECK (cache_class IN ('IMMUTABLE', 'MUTABLE')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}media_type ADD CONSTRAINT ck_${cms.tablePrefix}media_type_max_file_size_mb CHECK (max_file_size_mb IS NULL OR max_file_size_mb > 0) + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}media + baseColumnNames: media_type_id + referencedTableName: ${cms.tablePrefix}media_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}media_media_type_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}media + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}media_site_id + - createIndex: + tableName: ${cms.tablePrefix}media + indexName: idx_${cms.tablePrefix}media_site_id_name + columns: + - column: { name: site_id } + - column: { name: name } + - createIndex: + tableName: ${cms.tablePrefix}media + indexName: idx_${cms.tablePrefix}media_media_type_id + columns: + - column: { name: media_type_id } + + - changeSet: + id: 1.0.0-constraints-blog + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog + baseColumnNames: blog_type_id + referencedTableName: ${cms.tablePrefix}blog_type + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_blog_type_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}author + baseColumnNames: profile_media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}author_profile_media_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_tag + baseColumnNames: blog_id + referencedTableName: ${cms.tablePrefix}blog + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_tag_blog_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post + baseColumnNames: author_id + referencedTableName: ${cms.tablePrefix}author + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_author_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post + baseColumnNames: blog_id + referencedTableName: ${cms.tablePrefix}blog + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_blog_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post + baseColumnNames: featured_media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_featured_media_id + - createIndex: + tableName: ${cms.tablePrefix}blog_post + indexName: idx_${cms.tablePrefix}blog_post_blog_id_is_published + columns: + - column: { name: blog_id } + - column: { name: is_published } + - createIndex: + tableName: ${cms.tablePrefix}blog_post + indexName: idx_${cms.tablePrefix}blog_post_author_id + columns: + - column: { name: author_id } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_tag_int + baseColumnNames: blog_post_id + referencedTableName: ${cms.tablePrefix}blog_post + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_tag_int_blog_post_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_tag_int + baseColumnNames: blog_tag_id + referencedTableName: ${cms.tablePrefix}blog_tag + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_tag_int_blog_tag_id + - createIndex: + tableName: ${cms.tablePrefix}blog_post_tag_int + indexName: idx_${cms.tablePrefix}blog_post_tag_int_blog_tag_id + columns: + - column: { name: blog_tag_id } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_media + baseColumnNames: blog_post_id + referencedTableName: ${cms.tablePrefix}blog_post + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_media_blog_post_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_media + baseColumnNames: media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_media_media_id + - createIndex: + tableName: ${cms.tablePrefix}blog_post_media + indexName: idx_${cms.tablePrefix}blog_post_media_blog_post_id_sort_order + columns: + - column: { name: blog_post_id } + - column: { name: sort_order } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_version + baseColumnNames: blog_post_id + referencedTableName: ${cms.tablePrefix}blog_post + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_version_blog_post_id + - createIndex: + tableName: ${cms.tablePrefix}blog_post_version + indexName: idx_${cms.tablePrefix}blog_post_version_blog_post_id_channel + columns: + - column: { name: blog_post_id } + - column: { name: channel } + - sql: + sql: ALTER TABLE ${cms.tablePrefix}blog_post_version ADD CONSTRAINT ck_${cms.tablePrefix}blog_post_version_channel CHECK (channel IN ('WEBSITE', 'LINKEDIN', 'MEDIUM', 'FACEBOOK', 'OTHER')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}blog_post_version ADD CONSTRAINT ck_${cms.tablePrefix}blog_post_version_content_format CHECK (content_format IN ('MARKDOWN', 'PLAIN_TEXT')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}blog_post_version ADD CONSTRAINT ck_${cms.tablePrefix}blog_post_version_status CHECK (status IN ('DRAFT', 'READY', 'PUBLISHED', 'ARCHIVED')) + + - changeSet: + id: 1.0.0-constraints-projects + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PROJECTS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project_category + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_category_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project_category + baseColumnNames: featured_media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_category_featured_media_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project + baseColumnNames: featured_media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_featured_media_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project + baseColumnNames: category_id + referencedTableName: ${cms.tablePrefix}project_category + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_category_id + - createIndex: + tableName: ${cms.tablePrefix}project + indexName: idx_${cms.tablePrefix}project_category_id_is_published_sort_order + columns: + - column: { name: category_id } + - column: { name: is_published } + - column: { name: sort_order } + - sql: + sql: ALTER TABLE ${cms.tablePrefix}project ADD CONSTRAINT ck_${cms.tablePrefix}project_project_status CHECK (project_status IN ('PLANNED', 'IN_PROGRESS', 'ACTIVE', 'ARCHIVED')) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}project ADD CONSTRAINT ck_${cms.tablePrefix}project_image_focal_x CHECK (image_focal_x BETWEEN 0 AND 100) + - sql: + sql: ALTER TABLE ${cms.tablePrefix}project ADD CONSTRAINT ck_${cms.tablePrefix}project_image_focal_y CHECK (image_focal_y BETWEEN 0 AND 100) + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project_update + baseColumnNames: project_id + referencedTableName: ${cms.tablePrefix}project + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_update_project_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}project_update + baseColumnNames: featured_media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}project_update_featured_media_id + - createIndex: + tableName: ${cms.tablePrefix}project_update + indexName: idx_${cms.tablePrefix}project_update_project_id_is_published_update_date + columns: + - column: { name: project_id } + - column: { name: is_published } + - column: { name: update_date } + + - changeSet: + id: 1.0.0-constraints-photos + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album_folder + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_folder_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album_folder + baseColumnNames: parent_id + referencedTableName: ${cms.tablePrefix}photo_album_folder + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_folder_parent_id + - createIndex: + tableName: ${cms.tablePrefix}photo_album_folder + indexName: idx_${cms.tablePrefix}photo_album_folder_parent_id + columns: + - column: { name: parent_id } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album + baseColumnNames: site_id + referencedTableName: ${cms.tablePrefix}site + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_site_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album + baseColumnNames: photo_album_folder_id + referencedTableName: ${cms.tablePrefix}photo_album_folder + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_photo_album_folder_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album + baseColumnNames: cover_photo_id + referencedTableName: ${cms.tablePrefix}photo + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_cover_photo_id + - createIndex: + tableName: ${cms.tablePrefix}photo_album + indexName: idx_${cms.tablePrefix}photo_album_photo_album_folder_id + columns: + - column: { name: photo_album_folder_id } + - createIndex: + tableName: ${cms.tablePrefix}photo_album + indexName: idx_${cms.tablePrefix}photo_album_is_published + columns: + - column: { name: is_published } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo + baseColumnNames: photo_album_id + referencedTableName: ${cms.tablePrefix}photo_album + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_photo_album_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo + baseColumnNames: media_id + referencedTableName: ${cms.tablePrefix}media + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_media_id + - createIndex: + tableName: ${cms.tablePrefix}photo + indexName: idx_${cms.tablePrefix}photo_photo_album_id_sort_order + columns: + - column: { name: photo_album_id } + - column: { name: sort_order } + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_tag_int + baseColumnNames: photo_id + referencedTableName: ${cms.tablePrefix}photo + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_tag_int_photo_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_tag_int + baseColumnNames: photo_tag_id + referencedTableName: ${cms.tablePrefix}photo_tag + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_tag_int_photo_tag_id + - createIndex: + tableName: ${cms.tablePrefix}photo_tag_int + indexName: idx_${cms.tablePrefix}photo_tag_int_photo_tag_id + columns: + - column: { name: photo_tag_id } + + # Links between two features: created when both are installed. + - changeSet: + id: 1.0.0-constraints-blog-projects + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PROJECTS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_version + baseColumnNames: project_id + referencedTableName: ${cms.tablePrefix}project + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_version_project_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}blog_post_version + baseColumnNames: project_update_id + referencedTableName: ${cms.tablePrefix}project_update + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}blog_post_version_project_update_id + + # Links between two features: created when both are installed. + - changeSet: + id: 1.0.0-constraints-photos-projects + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PHOTOS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',PROJECTS,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 THEN 1 ELSE 0 END + changes: + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album + baseColumnNames: project_id + referencedTableName: ${cms.tablePrefix}project + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_project_id + - addForeignKeyConstraint: + baseTableName: ${cms.tablePrefix}photo_album + baseColumnNames: project_update_id + referencedTableName: ${cms.tablePrefix}project_update + referencedColumnNames: id + constraintName: fk_${cms.tablePrefix}photo_album_project_update_id + - createIndex: + tableName: ${cms.tablePrefix}photo_album + indexName: idx_${cms.tablePrefix}photo_album_project_id + columns: + - column: { name: project_id } + - createIndex: + tableName: ${cms.tablePrefix}photo_album + indexName: idx_${cms.tablePrefix}photo_album_project_update_id + columns: + - column: { name: project_update_id } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-media_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}media_type + columns: + - column: { name: name, value: "Image" } + - column: { name: code, value: "IMAGE" } + - column: { name: description, value: "Image files (JPEG, PNG, GIF, etc.)" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: allowed_mime_types, value: "image/jpeg,image/png,image/heic,image/heif" } + - column: { name: allowed_extensions, value: "jpg,jpeg,png,heic,heif" } + - column: { name: max_file_size_mb, valueNumeric: 25 } + - column: { name: thumbnail_enabled, valueBoolean: true } + - column: { name: thumbnail_format, value: "JPEG" } + - column: { name: thumbnail_quality, valueNumeric: 85 } + - column: { name: gallery_enabled, valueBoolean: true } + - column: { name: gallery_format, value: "JPEG" } + - column: { name: gallery_quality, valueNumeric: 85 } + - column: { name: slideshow_enabled, valueBoolean: true } + - column: { name: slideshow_format, value: "JPEG" } + - column: { name: slideshow_quality, valueNumeric: 85 } + - column: { name: strip_metadata, valueBoolean: true } + - column: { name: require_alt_text, valueBoolean: false } + - column: { name: require_caption, valueBoolean: false } + - column: { name: cache_class, value: "MUTABLE" } + - column: { name: storage_prefix, value: "media" } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}media_type + columns: + - column: { name: name, value: "Video" } + - column: { name: code, value: "VIDEO" } + - column: { name: description, value: "Video files (MP4, WebM, etc.)" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: thumbnail_enabled, valueBoolean: true } + - column: { name: thumbnail_format, value: "JPEG" } + - column: { name: thumbnail_quality, valueNumeric: 85 } + - column: { name: gallery_enabled, valueBoolean: true } + - column: { name: gallery_format, value: "JPEG" } + - column: { name: gallery_quality, valueNumeric: 85 } + - column: { name: slideshow_enabled, valueBoolean: true } + - column: { name: slideshow_format, value: "JPEG" } + - column: { name: slideshow_quality, valueNumeric: 85 } + - column: { name: strip_metadata, valueBoolean: false } + - column: { name: require_alt_text, valueBoolean: false } + - column: { name: require_caption, valueBoolean: false } + - column: { name: cache_class, value: "MUTABLE" } + - column: { name: storage_prefix, value: "media" } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}media_type + columns: + - column: { name: name, value: "Audio" } + - column: { name: code, value: "AUDIO" } + - column: { name: description, value: "Audio files (MP3, WAV, etc.)" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 3 } + - column: { name: thumbnail_enabled, valueBoolean: true } + - column: { name: thumbnail_format, value: "JPEG" } + - column: { name: thumbnail_quality, valueNumeric: 85 } + - column: { name: gallery_enabled, valueBoolean: true } + - column: { name: gallery_format, value: "JPEG" } + - column: { name: gallery_quality, valueNumeric: 85 } + - column: { name: slideshow_enabled, valueBoolean: true } + - column: { name: slideshow_format, value: "JPEG" } + - column: { name: slideshow_quality, valueNumeric: 85 } + - column: { name: strip_metadata, valueBoolean: false } + - column: { name: require_alt_text, valueBoolean: false } + - column: { name: require_caption, valueBoolean: false } + - column: { name: cache_class, value: "MUTABLE" } + - column: { name: storage_prefix, value: "media" } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}media_type + columns: + - column: { name: name, value: "Document" } + - column: { name: code, value: "DOCUMENT" } + - column: { name: description, value: "Document files (PDF, DOCX, etc.)" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 4 } + - column: { name: thumbnail_enabled, valueBoolean: true } + - column: { name: thumbnail_format, value: "JPEG" } + - column: { name: thumbnail_quality, valueNumeric: 85 } + - column: { name: gallery_enabled, valueBoolean: true } + - column: { name: gallery_format, value: "JPEG" } + - column: { name: gallery_quality, valueNumeric: 85 } + - column: { name: slideshow_enabled, valueBoolean: true } + - column: { name: slideshow_format, value: "JPEG" } + - column: { name: slideshow_quality, valueNumeric: 85 } + - column: { name: strip_metadata, valueBoolean: false } + - column: { name: require_alt_text, valueBoolean: false } + - column: { name: require_caption, valueBoolean: false } + - column: { name: cache_class, value: "MUTABLE" } + - column: { name: storage_prefix, value: "media" } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}media_type + columns: + - column: { name: name, value: "Other" } + - column: { name: code, value: "OTHER" } + - column: { name: description, value: "Other file types" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 5 } + - column: { name: thumbnail_enabled, valueBoolean: true } + - column: { name: thumbnail_format, value: "JPEG" } + - column: { name: thumbnail_quality, valueNumeric: 85 } + - column: { name: gallery_enabled, valueBoolean: true } + - column: { name: gallery_format, value: "JPEG" } + - column: { name: gallery_quality, valueNumeric: 85 } + - column: { name: slideshow_enabled, valueBoolean: true } + - column: { name: slideshow_format, value: "JPEG" } + - column: { name: slideshow_quality, valueNumeric: 85 } + - column: { name: strip_metadata, valueBoolean: false } + - column: { name: require_alt_text, valueBoolean: false } + - column: { name: require_caption, valueBoolean: false } + - column: { name: cache_class, value: "MUTABLE" } + - column: { name: storage_prefix, value: "media" } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + + # Generic reference data (never content); off with cms.seedReferenceData=false. + - changeSet: + id: 1.0.0-seed-blog_type + author: qbit-cms + logicalFilePath: qbit-cms/changelog + preConditions: + - onFail: CONTINUE + - sqlCheck: + expectedResult: 1 + sql: SELECT CASE WHEN POSITION(',CORE,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',MEDIA,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND POSITION(',BLOG,' IN CONCAT(',', REPLACE('${cms.features}', ' ', ''), ',')) > 0 AND LOWER('${cms.seedReferenceData}') = 'true' THEN 1 ELSE 0 END + changes: + - insert: + tableName: ${cms.tablePrefix}blog_type + columns: + - column: { name: name, value: "Site Blog" } + - column: { name: code, value: "SITE_BLOG" } + - column: { name: description, value: "A general blog for the site" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 1 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP } + - insert: + tableName: ${cms.tablePrefix}blog_type + columns: + - column: { name: name, value: "Project Update Blog" } + - column: { name: code, value: "PROJECT_UPDATE_BLOG" } + - column: { name: description, value: "A blog for project updates" } + - column: { name: is_active, valueBoolean: true } + - column: { name: sort_order, valueNumeric: 2 } + - column: { name: create_date, valueComputed: CURRENT_TIMESTAMP } + - column: { name: modify_date, valueComputed: CURRENT_TIMESTAMP }