diff --git a/CHANGELOG.md b/CHANGELOG.md index 3201d41c8..4dfae121a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Consolidated 25 historical 2.x Doctrine migrations into a single end-of-2.8 schema migration; + upgraders run `doctrine:migrations:rollup` (see `UPGRADE.md` step 3). +- Restored three deprecated `Template` properties (`icon`, `resources`, `description`) as + write-only fields; scheduled for removal in 3.1. - Merged fixes from 2.7.0 into release/3.0.0. - Added `INSTANT_BOOK_BUSY_INTERVALS_SOURCE` to select between Graph and the slide's calendar feed as the source of busy intervals for InstantBook. diff --git a/UPGRADE.md b/UPGRADE.md index defd100b8..f9391135e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -73,12 +73,36 @@ Rename the following .env variables in `.env.local`: - From `APP_KEY_VAULT_SOURCE` to `KEY_VAULT_SOURCE` - From `APP_KEY_VAULT_JSON` to `KEY_VAULT_JSON` -#### 3 - Run doctrine migrate +#### 3 - Consolidate Doctrine migrations + +3.0 ships a single consolidated migration that represents the end-of-2.8 schema. The 25 historical +2.x migrations have been removed from the repository. + +Because every upgrading database already matches that consolidated schema (via the 25 migrations it +ran while on 2.x), there is nothing for `doctrine:migrations:migrate` to do — and running it would +fail because of the orphaned version entries. Use `doctrine:migrations:rollup` instead, which +truncates the `doctrine_migration_versions` table and inserts a single row marking the consolidated +migration as already executed: ```shell -docker compose exec phpfpm bin/console doctrine:migrations:migrate +# Confirm the database is at the latest 2.8.x state before rolling up. +# All 25 historical versions should appear as "migrated" / "available". +docker compose exec phpfpm bin/console doctrine:migrations:status + +# Replace the 25 historical version entries with the single consolidated entry. +# This does not run any SQL — it only rewrites the version-tracking table. +docker compose exec phpfpm bin/console doctrine:migrations:rollup --no-interaction ``` +> **Prerequisite:** the database must be on the final 2.8.x release with every 2.x migration +> applied. If `doctrine:migrations:status` (run while still on 2.8.x) reports any pending +> migrations, run `doctrine:migrations:migrate` on 2.8.x first, then upgrade to 3.0 and continue +> here. + +Fresh installs (no prior 2.x database) skip the rollup and run +`doctrine:migrations:migrate` instead — it executes the single consolidated migration and brings +the schema up in one step. + #### 4 - Run template list command to see status for installed templates ```shell diff --git a/config/api_platform/template.yaml b/config/api_platform/template.yaml index 718bbf9ff..70fa90520 100644 --- a/config/api_platform/template.yaml +++ b/config/api_platform/template.yaml @@ -32,7 +32,7 @@ resources: ApiPlatform\Metadata\GetCollection: filters: - - 'entity.search_filter' + - 'template.search_filter' - 'entity.blameable_filter' - 'created.at.order_filter' - 'modified.at.order_filter' diff --git a/config/services.yaml b/config/services.yaml index cc13a9e48..5c342f2bd 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -313,6 +313,19 @@ services: tags: ['api_platform.filter'] arguments: [{ title: 'partial', description: 'partial' }] + # Template-specific search filter — Template's `description` column is + # deprecated and slated for removal in 3.1, so it is intentionally not + # exposed as a queryable property here. (`#[ApiFilter]` and + # `#[ApiProperty]` attributes on the entity don't affect filter + # discovery while Template's resource is YAML-configured, so the + # exclusion has to live here.) + # TODO[3.1]: drop this and switch the GetCollection back to the shared + # `entity.search_filter` once the deprecated property is gone. + template.search_filter: + parent: 'api_platform.doctrine.orm.search_filter' + tags: ['api_platform.filter'] + arguments: [{ title: 'partial' }] + entity.blameable_filter: parent: 'api_platform.doctrine.orm.search_filter' tags: ['api_platform.filter'] diff --git a/migrations/Version20220309093909.php b/migrations/Version20220309093909.php deleted file mode 100644 index 078430634..000000000 --- a/migrations/Version20220309093909.php +++ /dev/null @@ -1,151 +0,0 @@ -addSql('CREATE TABLE feed (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', feed_source_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, configuration LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', INDEX IDX_234044AB9033212A (tenant_id), INDEX IDX_234044ABDDAEFFBD (feed_source_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE feed_source (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, feed_type VARCHAR(255) NOT NULL, secrets LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', configuration LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_9DA80F879033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE media (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, file_path VARCHAR(255) DEFAULT NULL, license VARCHAR(255) DEFAULT \'\', width INT DEFAULT 0 NOT NULL, height INT DEFAULT 0 NOT NULL, size INT DEFAULT 0 NOT NULL, mime_type VARCHAR(255) DEFAULT \'\' NOT NULL, sha VARCHAR(255) DEFAULT \'\' NOT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_6A2CA10C9033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE playlist (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, is_campaign TINYINT(1) NOT NULL, published_from DATETIME DEFAULT NULL, published_to DATETIME DEFAULT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_D782112D9033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE playlist_screen_region (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', playlist_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', region_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, weight INT DEFAULT 0 NOT NULL, INDEX IDX_6869486A9033212A (tenant_id), INDEX IDX_6869486A6BBD148 (playlist_id), INDEX IDX_6869486A41A67722 (screen_id), INDEX IDX_6869486A98260155 (region_id), UNIQUE INDEX unique_idx (playlist_id, screen_id, region_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE playlist_slide (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', playlist_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', slide_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, weight INT DEFAULT 0 NOT NULL, INDEX IDX_D1F3F7219033212A (tenant_id), INDEX IDX_D1F3F7216BBD148 (playlist_id), INDEX IDX_D1F3F721DD5AFB87 (slide_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE schedule (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', playlist_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, rrule VARCHAR(255) NOT NULL COMMENT \'(DC2Type:rrule)\', duration INT NOT NULL, INDEX IDX_5A3811FB9033212A (tenant_id), INDEX IDX_5A3811FB6BBD148 (playlist_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_layout_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, size INT DEFAULT 0 NOT NULL, resolution_width INT DEFAULT 0 NOT NULL, resolution_height INT DEFAULT 0 NOT NULL, location VARCHAR(255) DEFAULT \'\', title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_DF4C61309033212A (tenant_id), INDEX IDX_DF4C6130C1ECB8D6 (screen_layout_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_campaign (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', campaign_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_636686BD9033212A (tenant_id), INDEX IDX_636686BDF639F774 (campaign_id), INDEX IDX_636686BD41A67722 (screen_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_group (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_10C764819033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_group_screen (screen_group_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_905749ED82274D27 (screen_group_id), INDEX IDX_905749ED41A67722 (screen_id), PRIMARY KEY(screen_group_id, screen_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_group_campaign (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', campaign_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_group_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_1E364E6E9033212A (tenant_id), INDEX IDX_1E364E6EF639F774 (campaign_id), INDEX IDX_1E364E6E82274D27 (screen_group_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_layout (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, grid_rows INT DEFAULT 0 NOT NULL, grid_columns INT DEFAULT 0 NOT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_4BF6E94B9033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_layout_regions (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_layout_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, grid_area LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', INDEX IDX_D80836AD9033212A (tenant_id), INDEX IDX_D80836ADC1ECB8D6 (screen_layout_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_user (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', screen_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, username VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', UNIQUE INDEX UNIQ_8D2D23C6F85E0677 (username), INDEX IDX_8D2D23C69033212A (tenant_id), UNIQUE INDEX UNIQ_8D2D23C641A67722 (screen_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE slide (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', template_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', theme_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:ulid)\', feed_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, template_options LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', duration INT DEFAULT NULL, content LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', published_from DATETIME DEFAULT NULL, published_to DATETIME DEFAULT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_72EFEE629033212A (tenant_id), INDEX IDX_72EFEE625DA0FB8 (template_id), INDEX IDX_72EFEE6259027487 (theme_id), UNIQUE INDEX UNIQ_72EFEE6251A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE slide_media (slide_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', media_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_EBA5772FDD5AFB87 (slide_id), INDEX IDX_EBA5772FEA9FDD75 (media_id), PRIMARY KEY(slide_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE template (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, icon VARCHAR(255) DEFAULT \'\' NOT NULL, resources LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE tenant (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, tenant_key VARCHAR(25) NOT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, UNIQUE INDEX UNIQ_4E59C4623A6F39CD (tenant_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE theme (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, css_styles LONGTEXT NOT NULL, title VARCHAR(255) DEFAULT \'\' NOT NULL, description VARCHAR(255) DEFAULT \'\' NOT NULL, INDEX IDX_9775E7089033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, email VARCHAR(180) NOT NULL, full_name VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, provider VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user_role_tenant (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', user_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', INDEX IDX_4C64EC46A76ED395 (user_id), INDEX IDX_4C64EC469033212A (tenant_id), UNIQUE INDEX user_tenant_unique (user_id, tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE feed ADD CONSTRAINT FK_234044AB9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE feed ADD CONSTRAINT FK_234044ABDDAEFFBD FOREIGN KEY (feed_source_id) REFERENCES feed_source (id)'); - $this->addSql('ALTER TABLE feed_source ADD CONSTRAINT FK_9DA80F879033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE media ADD CONSTRAINT FK_6A2CA10C9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE playlist ADD CONSTRAINT FK_D782112D9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A6BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A98260155 FOREIGN KEY (region_id) REFERENCES screen_layout_regions (id)'); - $this->addSql('ALTER TABLE playlist_slide ADD CONSTRAINT FK_D1F3F7219033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE playlist_slide ADD CONSTRAINT FK_D1F3F7216BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE playlist_slide ADD CONSTRAINT FK_D1F3F721DD5AFB87 FOREIGN KEY (slide_id) REFERENCES slide (id)'); - $this->addSql('ALTER TABLE schedule ADD CONSTRAINT FK_5A3811FB9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE schedule ADD CONSTRAINT FK_5A3811FB6BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE screen ADD CONSTRAINT FK_DF4C61309033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen ADD CONSTRAINT FK_DF4C6130C1ECB8D6 FOREIGN KEY (screen_layout_id) REFERENCES screen_layout (id)'); - $this->addSql('ALTER TABLE screen_campaign ADD CONSTRAINT FK_636686BD9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen_campaign ADD CONSTRAINT FK_636686BDF639F774 FOREIGN KEY (campaign_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE screen_campaign ADD CONSTRAINT FK_636686BD41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id)'); - $this->addSql('ALTER TABLE screen_group ADD CONSTRAINT FK_10C764819033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen_group_screen ADD CONSTRAINT FK_905749ED82274D27 FOREIGN KEY (screen_group_id) REFERENCES screen_group (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE screen_group_screen ADD CONSTRAINT FK_905749ED41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE screen_group_campaign ADD CONSTRAINT FK_1E364E6E9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen_group_campaign ADD CONSTRAINT FK_1E364E6EF639F774 FOREIGN KEY (campaign_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE screen_group_campaign ADD CONSTRAINT FK_1E364E6E82274D27 FOREIGN KEY (screen_group_id) REFERENCES screen_group (id)'); - $this->addSql('ALTER TABLE screen_layout ADD CONSTRAINT FK_4BF6E94B9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen_layout_regions ADD CONSTRAINT FK_D80836AD9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen_layout_regions ADD CONSTRAINT FK_D80836ADC1ECB8D6 FOREIGN KEY (screen_layout_id) REFERENCES screen_layout (id)'); - $this->addSql('ALTER TABLE screen_user ADD CONSTRAINT FK_8D2D23C69033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE screen_user ADD CONSTRAINT FK_8D2D23C641A67722 FOREIGN KEY (screen_id) REFERENCES screen (id)'); - $this->addSql('ALTER TABLE slide ADD CONSTRAINT FK_72EFEE629033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE slide ADD CONSTRAINT FK_72EFEE625DA0FB8 FOREIGN KEY (template_id) REFERENCES template (id)'); - $this->addSql('ALTER TABLE slide ADD CONSTRAINT FK_72EFEE6259027487 FOREIGN KEY (theme_id) REFERENCES theme (id) ON DELETE SET NULL'); - $this->addSql('ALTER TABLE slide ADD CONSTRAINT FK_72EFEE6251A5BC03 FOREIGN KEY (feed_id) REFERENCES feed (id)'); - $this->addSql('ALTER TABLE slide_media ADD CONSTRAINT FK_EBA5772FDD5AFB87 FOREIGN KEY (slide_id) REFERENCES slide (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE slide_media ADD CONSTRAINT FK_EBA5772FEA9FDD75 FOREIGN KEY (media_id) REFERENCES media (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE theme ADD CONSTRAINT FK_9775E7089033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE user_role_tenant ADD CONSTRAINT FK_4C64EC46A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); - $this->addSql('ALTER TABLE user_role_tenant ADD CONSTRAINT FK_4C64EC469033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE6251A5BC03'); - $this->addSql('ALTER TABLE feed DROP FOREIGN KEY FK_234044ABDDAEFFBD'); - $this->addSql('ALTER TABLE slide_media DROP FOREIGN KEY FK_EBA5772FEA9FDD75'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A6BBD148'); - $this->addSql('ALTER TABLE playlist_slide DROP FOREIGN KEY FK_D1F3F7216BBD148'); - $this->addSql('ALTER TABLE schedule DROP FOREIGN KEY FK_5A3811FB6BBD148'); - $this->addSql('ALTER TABLE screen_campaign DROP FOREIGN KEY FK_636686BDF639F774'); - $this->addSql('ALTER TABLE screen_group_campaign DROP FOREIGN KEY FK_1E364E6EF639F774'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A41A67722'); - $this->addSql('ALTER TABLE screen_campaign DROP FOREIGN KEY FK_636686BD41A67722'); - $this->addSql('ALTER TABLE screen_group_screen DROP FOREIGN KEY FK_905749ED41A67722'); - $this->addSql('ALTER TABLE screen_user DROP FOREIGN KEY FK_8D2D23C641A67722'); - $this->addSql('ALTER TABLE screen_group_screen DROP FOREIGN KEY FK_905749ED82274D27'); - $this->addSql('ALTER TABLE screen_group_campaign DROP FOREIGN KEY FK_1E364E6E82274D27'); - $this->addSql('ALTER TABLE screen DROP FOREIGN KEY FK_DF4C6130C1ECB8D6'); - $this->addSql('ALTER TABLE screen_layout_regions DROP FOREIGN KEY FK_D80836ADC1ECB8D6'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A98260155'); - $this->addSql('ALTER TABLE playlist_slide DROP FOREIGN KEY FK_D1F3F721DD5AFB87'); - $this->addSql('ALTER TABLE slide_media DROP FOREIGN KEY FK_EBA5772FDD5AFB87'); - $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE625DA0FB8'); - $this->addSql('ALTER TABLE feed DROP FOREIGN KEY FK_234044AB9033212A'); - $this->addSql('ALTER TABLE feed_source DROP FOREIGN KEY FK_9DA80F879033212A'); - $this->addSql('ALTER TABLE media DROP FOREIGN KEY FK_6A2CA10C9033212A'); - $this->addSql('ALTER TABLE playlist DROP FOREIGN KEY FK_D782112D9033212A'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A9033212A'); - $this->addSql('ALTER TABLE playlist_slide DROP FOREIGN KEY FK_D1F3F7219033212A'); - $this->addSql('ALTER TABLE schedule DROP FOREIGN KEY FK_5A3811FB9033212A'); - $this->addSql('ALTER TABLE screen DROP FOREIGN KEY FK_DF4C61309033212A'); - $this->addSql('ALTER TABLE screen_campaign DROP FOREIGN KEY FK_636686BD9033212A'); - $this->addSql('ALTER TABLE screen_group DROP FOREIGN KEY FK_10C764819033212A'); - $this->addSql('ALTER TABLE screen_group_campaign DROP FOREIGN KEY FK_1E364E6E9033212A'); - $this->addSql('ALTER TABLE screen_layout DROP FOREIGN KEY FK_4BF6E94B9033212A'); - $this->addSql('ALTER TABLE screen_layout_regions DROP FOREIGN KEY FK_D80836AD9033212A'); - $this->addSql('ALTER TABLE screen_user DROP FOREIGN KEY FK_8D2D23C69033212A'); - $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE629033212A'); - $this->addSql('ALTER TABLE theme DROP FOREIGN KEY FK_9775E7089033212A'); - $this->addSql('ALTER TABLE user_role_tenant DROP FOREIGN KEY FK_4C64EC469033212A'); - $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE6259027487'); - $this->addSql('ALTER TABLE user_role_tenant DROP FOREIGN KEY FK_4C64EC46A76ED395'); - $this->addSql('DROP TABLE feed'); - $this->addSql('DROP TABLE feed_source'); - $this->addSql('DROP TABLE media'); - $this->addSql('DROP TABLE playlist'); - $this->addSql('DROP TABLE playlist_screen_region'); - $this->addSql('DROP TABLE playlist_slide'); - $this->addSql('DROP TABLE schedule'); - $this->addSql('DROP TABLE screen'); - $this->addSql('DROP TABLE screen_campaign'); - $this->addSql('DROP TABLE screen_group'); - $this->addSql('DROP TABLE screen_group_screen'); - $this->addSql('DROP TABLE screen_group_campaign'); - $this->addSql('DROP TABLE screen_layout'); - $this->addSql('DROP TABLE screen_layout_regions'); - $this->addSql('DROP TABLE screen_user'); - $this->addSql('DROP TABLE slide'); - $this->addSql('DROP TABLE slide_media'); - $this->addSql('DROP TABLE template'); - $this->addSql('DROP TABLE tenant'); - $this->addSql('DROP TABLE theme'); - $this->addSql('DROP TABLE user'); - $this->addSql('DROP TABLE user_role_tenant'); - } -} diff --git a/migrations/Version20220311112355.php b/migrations/Version20220311112355.php deleted file mode 100644 index bed681832..000000000 --- a/migrations/Version20220311112355.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE feed_source ADD supported_feed_output_type VARCHAR(255) NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE feed_source DROP supported_feed_output_type'); - } -} diff --git a/migrations/Version20220311120935.php b/migrations/Version20220311120935.php deleted file mode 100644 index 928fab63c..000000000 --- a/migrations/Version20220311120935.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE feed_source DROP configuration'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE feed_source ADD configuration LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\''); - } -} diff --git a/migrations/Version20220312224517.php b/migrations/Version20220312224517.php deleted file mode 100644 index ad831475d..000000000 --- a/migrations/Version20220312224517.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE refresh_tokens'); - } -} diff --git a/migrations/Version20220314103522.php b/migrations/Version20220314103522.php deleted file mode 100644 index 690772efc..000000000 --- a/migrations/Version20220314103522.php +++ /dev/null @@ -1,53 +0,0 @@ -addSql('CREATE TABLE screen_layout_tenant (screen_layout_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_4B4C32E9C1ECB8D6 (screen_layout_id), INDEX IDX_4B4C32E99033212A (tenant_id), PRIMARY KEY(screen_layout_id, tenant_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE screen_layout_regions_tenant (screen_layout_regions_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_90A5AF483026129C (screen_layout_regions_id), INDEX IDX_90A5AF489033212A (tenant_id), PRIMARY KEY(screen_layout_regions_id, tenant_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE template_tenant (template_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_45B1CD905DA0FB8 (template_id), INDEX IDX_45B1CD909033212A (tenant_id), PRIMARY KEY(template_id, tenant_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE screen_layout_tenant ADD CONSTRAINT FK_4B4C32E9C1ECB8D6 FOREIGN KEY (screen_layout_id) REFERENCES screen_layout (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE screen_layout_tenant ADD CONSTRAINT FK_4B4C32E99033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE screen_layout_regions_tenant ADD CONSTRAINT FK_90A5AF483026129C FOREIGN KEY (screen_layout_regions_id) REFERENCES screen_layout_regions (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE screen_layout_regions_tenant ADD CONSTRAINT FK_90A5AF489033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE template_tenant ADD CONSTRAINT FK_45B1CD905DA0FB8 FOREIGN KEY (template_id) REFERENCES template (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE template_tenant ADD CONSTRAINT FK_45B1CD909033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE screen_layout DROP FOREIGN KEY FK_4BF6E94B9033212A'); - $this->addSql('DROP INDEX IDX_4BF6E94B9033212A ON screen_layout'); - $this->addSql('ALTER TABLE screen_layout DROP tenant_id'); - $this->addSql('ALTER TABLE screen_layout_regions DROP FOREIGN KEY FK_D80836AD9033212A'); - $this->addSql('DROP INDEX IDX_D80836AD9033212A ON screen_layout_regions'); - $this->addSql('ALTER TABLE screen_layout_regions DROP tenant_id'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE screen_layout_tenant'); - $this->addSql('DROP TABLE screen_layout_regions_tenant'); - $this->addSql('DROP TABLE template_tenant'); - $this->addSql('ALTER TABLE screen_layout ADD tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\''); - $this->addSql('ALTER TABLE screen_layout ADD CONSTRAINT FK_4BF6E94B9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('CREATE INDEX IDX_4BF6E94B9033212A ON screen_layout (tenant_id)'); - $this->addSql('ALTER TABLE screen_layout_regions ADD tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\''); - $this->addSql('ALTER TABLE screen_layout_regions ADD CONSTRAINT FK_D80836AD9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('CREATE INDEX IDX_D80836AD9033212A ON screen_layout_regions (tenant_id)'); - } -} diff --git a/migrations/Version20220315133038.php b/migrations/Version20220315133038.php deleted file mode 100644 index e3f089816..000000000 --- a/migrations/Version20220315133038.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('CREATE TABLE playlist_tenant (playlist_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_A12FC8516BBD148 (playlist_id), INDEX IDX_A12FC8519033212A (tenant_id), PRIMARY KEY(playlist_id, tenant_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE playlist_tenant ADD CONSTRAINT FK_A12FC8516BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE playlist_tenant ADD CONSTRAINT FK_A12FC8519033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE playlist_tenant'); - } -} diff --git a/migrations/Version20220405093535.php b/migrations/Version20220405093535.php deleted file mode 100644 index d83295782..000000000 --- a/migrations/Version20220405093535.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE screen_layout_regions ADD type VARCHAR(255) DEFAULT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE screen_layout_regions DROP type'); - } -} diff --git a/migrations/Version20220427060919.php b/migrations/Version20220427060919.php deleted file mode 100644 index a399343aa..000000000 --- a/migrations/Version20220427060919.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE screen ADD enable_color_scheme_change TINYINT(1) DEFAULT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE screen DROP enable_color_scheme_change'); - } -} diff --git a/migrations/Version20220510124916.php b/migrations/Version20220510124916.php deleted file mode 100644 index 8d37071ba..000000000 --- a/migrations/Version20220510124916.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE tenant ADD fallback_image_url VARCHAR(255) DEFAULT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE tenant DROP fallback_image_url'); - } -} diff --git a/migrations/Version20220706144147.php b/migrations/Version20220706144147.php deleted file mode 100644 index 1bf1782c2..000000000 --- a/migrations/Version20220706144147.php +++ /dev/null @@ -1,35 +0,0 @@ -addSql('ALTER TABLE theme ADD logo_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:ulid)\''); - $this->addSql('ALTER TABLE theme ADD CONSTRAINT FK_9775E708F98F144A FOREIGN KEY (logo_id) REFERENCES media (id)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_9775E708F98F144A ON theme (logo_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE theme DROP FOREIGN KEY FK_9775E708F98F144A'); - $this->addSql('DROP INDEX UNIQ_9775E708F98F144A ON theme'); - $this->addSql('ALTER TABLE theme DROP logo_id'); - } -} diff --git a/migrations/Version20220831111531.php b/migrations/Version20220831111531.php deleted file mode 100644 index ba7931a94..000000000 --- a/migrations/Version20220831111531.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE screen ADD resolution VARCHAR(255) DEFAULT \'\' NOT NULL, ADD orientation VARCHAR(255) DEFAULT \'\' NOT NULL, DROP resolution_width, DROP resolution_height'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE screen ADD resolution_width INT DEFAULT 0 NOT NULL, ADD resolution_height INT DEFAULT 0 NOT NULL, DROP resolution, DROP orientation'); - } -} diff --git a/migrations/Version20221128121323.php b/migrations/Version20221128121323.php deleted file mode 100644 index 16472a542..000000000 --- a/migrations/Version20221128121323.php +++ /dev/null @@ -1,45 +0,0 @@ -addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A6BBD148'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A98260155'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A41A67722'); - $this->addSql('DROP INDEX unique_idx ON playlist_screen_region'); - $this->addSql('CREATE UNIQUE INDEX unique_playlist_screen_region ON playlist_screen_region (playlist_id, screen_id, region_id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A6BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A98260155 FOREIGN KEY (region_id) REFERENCES screen_layout_regions (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A6BBD148'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A41A67722'); - $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A98260155'); - $this->addSql('DROP INDEX unique_playlist_screen_region ON playlist_screen_region'); - $this->addSql('CREATE UNIQUE INDEX unique_idx ON playlist_screen_region (playlist_id, screen_id, region_id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A6BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD CONSTRAINT FK_6869486A98260155 FOREIGN KEY (region_id) REFERENCES screen_layout_regions (id)'); - } -} diff --git a/migrations/Version20231003195603.php b/migrations/Version20231003195603.php deleted file mode 100644 index 83bd3ae42..000000000 --- a/migrations/Version20231003195603.php +++ /dev/null @@ -1,41 +0,0 @@ -addSql('CREATE TABLE user_activation_code (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, code VARCHAR(255) NOT NULL, code_expire DATETIME NOT NULL, username VARCHAR(255) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', INDEX IDX_E88B20159033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE user_activation_code ADD CONSTRAINT FK_E88B20159033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - $this->addSql('ALTER TABLE user ADD provider_id VARCHAR(255) NOT NULL, ADD user_type VARCHAR(255) NOT NULL'); - $this->addSql('UPDATE user SET provider_id = email'); - $this->addSql('UPDATE user SET user_type = \''.UserTypeEnum::USERNAME_PASSWORD->value.'\' WHERE created_by = \'CLI\''); - $this->addSql('UPDATE user SET user_type = \''.UserTypeEnum::OIDC_INTERNAL->value.'\' WHERE created_by = \'OIDC\''); - $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649A53A8AA ON user (provider_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE user_activation_code DROP FOREIGN KEY FK_E88B20159033212A'); - $this->addSql('DROP TABLE user_activation_code'); - $this->addSql('DROP INDEX UNIQ_8D93D649A53A8AA ON user'); - $this->addSql('ALTER TABLE user DROP provider_id, DROP user_type'); - } -} diff --git a/migrations/Version20231006120901.php b/migrations/Version20231006120901.php deleted file mode 100644 index a9e32190f..000000000 --- a/migrations/Version20231006120901.php +++ /dev/null @@ -1,50 +0,0 @@ -addSql('ALTER TABLE feed CHANGE configuration configuration JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE feed_source CHANGE secrets secrets JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE screen_user CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE slide CHANGE content content JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE feed CHANGE configuration configuration JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE feed_source CHANGE secrets secrets JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE screen_user CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE slide CHANGE content content JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - } -} diff --git a/migrations/Version20231124120211.php b/migrations/Version20231124120211.php deleted file mode 100644 index 8661ea9c8..000000000 --- a/migrations/Version20231124120211.php +++ /dev/null @@ -1,88 +0,0 @@ -convertDbValues('screen_layout_regions', 'grid_area'); - $this->addSql('ALTER TABLE screen_layout_regions CHANGE grid_area grid_area JSON NOT NULL COMMENT \'(DC2Type:json)\''); - - $this->convertDbValues('slide', 'template_options'); - $this->addSql('ALTER TABLE slide CHANGE template_options template_options JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - - $this->convertDbValues('template', 'resources'); - $this->addSql('ALTER TABLE template CHANGE resources resources JSON NOT NULL COMMENT \'(DC2Type:json)\''); - - $this->convertDbValues('user_role_tenant', 'roles'); - $this->addSql('ALTER TABLE user_role_tenant CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE template CHANGE resources resources LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\''); - $this->addSql('ALTER TABLE slide CHANGE template_options template_options LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\''); - $this->addSql('ALTER TABLE screen_layout_regions CHANGE grid_area grid_area LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\''); - $this->addSql('ALTER TABLE user_role_tenant CHANGE roles roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\''); - } - - /** - * Convert data in columns of type "Array" (SQL: Long text) to type JSON (SQL: Long text). - * - * These columns contain serialized data and cannot be converted in plain SQL. We have to load - * the data and re-serialize as JSON. - * - * @see https://stackoverflow.com/questions/76525126/how-to-convert-doctrine-type-array-to-doctrine-type-json-in-a-mysql-database - * - * @param string $table - * @param string $column - * - * @return void - * - * @throws \Doctrine\DBAL\Exception - */ - private function convertDbValues(string $table, string $column): void - { - $connection = $this->connection; - - $querySql = sprintf('SELECT id, %s FROM %s', $column, $table); - $updateSql = sprintf('UPDATE %s SET %s = :encodedData WHERE id = :id', $table, $column); - - // Fetch the existing rows from the table - $rows = $connection->fetchAllAssociative($querySql); - - // Iterate over each row - foreach ($rows as $row) { - $id = $row['id']; - $data = $row[$column]; - - // Unserialize data first since type array is serialize data - $encodedData = unserialize($data); - - // Update the row with the new encoded data - $encodedData = json_encode($encodedData); // Encode the data using json_encode - - $connection->executeStatement($updateSql, [ - 'encodedData' => $encodedData, - 'id' => $id, - ]); - } - } -} diff --git a/migrations/Version20231207112313.php b/migrations/Version20231207112313.php deleted file mode 100644 index 7734355c3..000000000 --- a/migrations/Version20231207112313.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE user_activation_code CHANGE code_expire code_expire DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE user_activation_code CHANGE code_expire code_expire DATETIME NOT NULL, CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''); - } -} diff --git a/migrations/Version20231220130825.php b/migrations/Version20231220130825.php deleted file mode 100644 index ceca7c7df..000000000 --- a/migrations/Version20231220130825.php +++ /dev/null @@ -1,307 +0,0 @@ -addSql('ALTER TABLE feed ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON feed (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON feed (modified_at)'); - $this->addSql('ALTER TABLE playlist ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON playlist (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON playlist (modified_at)'); - $this->addSql('ALTER TABLE playlist_screen_region ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON playlist_screen_region (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON playlist_screen_region (modified_at)'); - $this->addSql('ALTER TABLE playlist_slide ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON playlist_slide (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON playlist_slide (modified_at)'); - $this->addSql('ALTER TABLE screen ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen (modified_at)'); - $this->addSql('ALTER TABLE screen_campaign ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen_campaign (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen_campaign (modified_at)'); - $this->addSql('ALTER TABLE screen_group ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen_group (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen_group (modified_at)'); - $this->addSql('ALTER TABLE screen_group_campaign ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen_group_campaign (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen_group_campaign (modified_at)'); - $this->addSql('ALTER TABLE screen_layout ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE screen_layout_regions ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('ALTER TABLE slide ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON slide (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON slide (modified_at)'); - $this->addSql('ALTER TABLE theme ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON theme (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON theme (modified_at)'); - - // Populate newly created 'relations_modified_at' and 'relations_modified' fields with correct data. - // Copy of the UPDATE queries defined in the doctrine listener but without a WHERE clause. - // Duplication ensures that the queries match the schema for this migration even if the schema and - // queries are refactored. - $sqlQueries = self::getUpdateRelationsAtQueries(withWhereClause: false); - foreach ($sqlQueries as $sqlQuery) { - $this->addSql($sqlQuery); - } - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX relations_modified_at_idx ON screen_group'); - $this->addSql('DROP INDEX modified_at_idx ON screen_group'); - $this->addSql('ALTER TABLE screen_group DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON playlist'); - $this->addSql('DROP INDEX modified_at_idx ON playlist'); - $this->addSql('ALTER TABLE playlist DROP relations_modified_at, DROP relations_modified'); - $this->addSql('ALTER TABLE screen_layout DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen'); - $this->addSql('DROP INDEX modified_at_idx ON screen'); - $this->addSql('ALTER TABLE screen DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON playlist_slide'); - $this->addSql('DROP INDEX modified_at_idx ON playlist_slide'); - $this->addSql('ALTER TABLE playlist_slide DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON theme'); - $this->addSql('DROP INDEX modified_at_idx ON theme'); - $this->addSql('ALTER TABLE theme DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON slide'); - $this->addSql('DROP INDEX modified_at_idx ON slide'); - $this->addSql('ALTER TABLE slide DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen_group_campaign'); - $this->addSql('DROP INDEX modified_at_idx ON screen_group_campaign'); - $this->addSql('ALTER TABLE screen_group_campaign DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen_campaign'); - $this->addSql('DROP INDEX modified_at_idx ON screen_campaign'); - $this->addSql('ALTER TABLE screen_campaign DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON feed'); - $this->addSql('DROP INDEX modified_at_idx ON feed'); - $this->addSql('ALTER TABLE feed DROP relations_modified_at, DROP relations_modified'); - $this->addSql('ALTER TABLE screen_layout_regions DROP relations_modified_at, DROP relations_modified'); - $this->addSql('DROP INDEX relations_modified_at_idx ON playlist_screen_region'); - $this->addSql('DROP INDEX modified_at_idx ON playlist_screen_region'); - $this->addSql('ALTER TABLE playlist_screen_region DROP relations_modified_at, DROP relations_modified'); - } - - /** - * Get an array of SQL update statements to update the relationsModified fields. - * - * @param bool $withWhereClause - * Should the statements include a where clause to limit the statement - * - * @return string[] - * Array of SQL statements - */ - public static function getUpdateRelationsAtQueries(bool $withWhereClause = true): array - { - // Set SQL update queries for the "relations modified" fields on the parent (p), child (c) relationships up through the entity tree - $sqlQueries = []; - - // Feed - $sqlQueries[] = self::getToOneQuery(jsonKey: 'feedSource', parentTable: 'feed', childTable: 'feed_source', childHasRelations: false, withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'slide', parentTable: 'feed', childTable: 'slide', parentTableId: 'id', childTableId: 'feed_id', childHasRelations: false, withWhereClause: $withWhereClause); - - // Slide - $sqlQueries[] = self::getToManyQuery(jsonKey: 'media', parentTable: 'slide', pivotTable: 'slide_media', childTable: 'media', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'theme', parentTable: 'slide', childTable: 'theme', childHasRelations: false, withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'templateInfo', parentTable: 'slide', childTable: 'template', childHasRelations: false, withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'feed', parentTable: 'slide', childTable: 'feed', withWhereClause: $withWhereClause); - - // PlaylistSlide - $sqlQueries[] = self::getToOneQuery(jsonKey: 'slide', parentTable: 'playlist_slide', childTable: 'slide', withWhereClause: $withWhereClause); - - // Playlist - $sqlQueries[] = self::getToOneQuery(jsonKey: 'slides', parentTable: 'playlist', childTable: 'playlist_slide', parentTableId: 'id', childTableId: 'playlist_id', withWhereClause: $withWhereClause); - - // ScreenCampaign - $sqlQueries[] = self::getToOneQuery(jsonKey: 'campaign', parentTable: 'screen_campaign', childTable: 'playlist', parentTableId: 'campaign_id', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'screen', parentTable: 'screen_campaign', childTable: 'screen', childHasRelations: false, withWhereClause: $withWhereClause); - - // ScreenGroupCampaign - campaign - $sqlQueries[] = self::getToOneQuery(jsonKey: 'campaign', parentTable: 'screen_group_campaign', childTable: 'playlist', parentTableId: 'campaign_id', withWhereClause: $withWhereClause); - - // ScreenGroup - $sqlQueries[] = self::getToManyQuery(jsonKey: 'screens', parentTable: 'screen_group', pivotTable: 'screen_group_screen', childTable: 'screen', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'screenGroupCampaigns', parentTable: 'screen_group', childTable: 'screen_group_campaign', parentTableId: 'id', childTableId: 'screen_group_id', withWhereClause: $withWhereClause); - - // ScreenGroupCampaign - screenGroup - $sqlQueries[] = self::getToOneQuery(jsonKey: 'screenGroup', parentTable: 'screen_group_campaign', childTable: 'screen_group', withWhereClause: $withWhereClause); - - // PlaylistScreenRegion - $sqlQueries[] = self::getToOneQuery(jsonKey: 'playlist', parentTable: 'playlist_screen_region', childTable: 'playlist', withWhereClause: $withWhereClause); - - // ScreenLayoutRegions - $sqlQueries[] = self::getToOneQuery(jsonKey: 'regions', parentTable: 'screen_layout_regions', childTable: 'playlist_screen_region', parentTableId: 'id', childTableId: 'region_id', withWhereClause: $withWhereClause); - - // ScreenLayout - $sqlQueries[] = self::getToOneQuery(jsonKey: 'regions', parentTable: 'screen_layout', childTable: 'screen_layout_regions', parentTableId: 'id', childTableId: 'screen_layout_id', withWhereClause: $withWhereClause); - - // Screen - $sqlQueries[] = self::getToOneQuery(jsonKey: 'campaigns', parentTable: 'screen', childTable: 'screen_campaign', parentTableId: 'id', childTableId: 'screen_id', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'layout', parentTable: 'screen', childTable: 'screen_layout', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'regions', parentTable: 'screen', childTable: 'playlist_screen_region', parentTableId: 'id', childTableId: 'screen_id', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToManyQuery(jsonKey: 'inScreenGroups', parentTable: 'screen', pivotTable: 'screen_group_screen', childTable: 'screen_group', withWhereClause: $withWhereClause); - - return $sqlQueries; - } - - /** - * Get "to one" query. - * - * For a table (parent) that has a relation to another table (child) where we need to update the "relations_modified_at" - * and "relations_modified" fields on the parent with values from the child we need to join the tables and set the values. - * - * Basically we do: "Update parent, join child, set parent values = child values" - * - * Example: - * UPDATE - * slide p - * INNER JOIN - * theme c - * ON - * p.theme_id = c.id - * SET - * p.relations_modified_at = DATE_FORMAT(GREATEST(COALESCE(p.relations_modified_at, '1970-01-01 00:00:00'), c.modified_at, COALESCE(c.relations_modified_at, '1970-01-01 00:00:00')), '%Y-%m-%d %H:%i:%s'), - * p.relations_modified = JSON_SET(p.relations_modified, "$.theme", DATE_FORMAT(GREATEST(COALESCE(c.relations_modified_at, '1970-01-01 00:00:00'), c.modified_at), '%Y-%m-%d %H:%i:%s')) - * WHERE - * p.modified_at >= :modified_at OR c.modified_at >= :modified_at OR c.relations_modified_at >= :modified_at - * - * Explanation: - * UPDATE parent table p, INNER JOIN child table c - * - use INNER JOIN because the query only makes sense for result where both parent and child tables have rows - * SET p.relations_modified_at to be the GREATEST (latest) value of either p.relations_modified_at, c.modified_at and c.relations_modified_at - * SET the value for the relevant json key on the json object in p.relations_modified to the GREATEST (latest) value of either c.modified_at and c.relations_modified_at - * - Because "relations_modified_at" can be null and GREATEST() will return null if the given parameter list contains null we need to COALESCE() null values to a date we know to be in the past - * - Because GREATEST() will return a date in numeric format we need to use DATE_FORMAT() to ensure consistent date formats - * WHERE either p.modified_at or c.modified_at is greater than a given timestamp - * - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the modified_at timestamps as clause in WHERE to limit to only update the rows just modified. - * - * @param string $jsonKey - * @param string $parentTable - * @param string $childTable - * @param string|null $parentTableId - * @param string $childTableId - * @param bool $childHasRelations - * @param bool $withWhereClause - * - * @return string - */ - private static function getToOneQuery(string $jsonKey, string $parentTable, string $childTable, ?string $parentTableId = null, string $childTableId = 'id', bool $childHasRelations = true, bool $withWhereClause = true): string - { - // Set the column name to use for "ON" in the Join clause. By default, the child table name with "_id" appended. - // E.g. "UPDATE feed p INNER JOIN feed_source c ON p.feed_source_id = c.id" - $parentTableId = (null === $parentTableId) ? $childTable.'_id' : $parentTableId; - - // The base UPDATE query. - // - Use INNER JON to only select rows that have a match in both parent and child tables - // - Use DATE_FORMAT() to ensure proper date format because we can be in either string or numeric context. - // - Use GREATEST() to select the greatest (latest) timestamp from the joined rows from the parent and child table - // - Use COALESCE() to convert null values to and (old) timestamp because GREATEST considers null to be greater than actual values - // - Use JSON_SET to only INSERT/UPDATE the relevant key in the json object, not the whole field. - $queryFormat = 'UPDATE %s p INNER JOIN %s c ON p.%s = c.%s - SET p.relations_modified_at = DATE_FORMAT(GREATEST(COALESCE(p.relations_modified_at, \'1970-01-01 00:00:00\'), %s), \'%s\'), p.relations_modified = JSON_SET(p.relations_modified, "$.%s", %s)'; - - // Set parameter list for GREATEST() - if the child table has relations of its own we need to select the greatest value of "relations_modified_at" and "modified_at". - $childGreatest = $childHasRelations ? 'c.modified_at, COALESCE(c.relations_modified_at, \'1970-01-01 00:00:00\')' : 'c.modified_at'; - // As above - $jsonGreatest = $childHasRelations ? 'DATE_FORMAT(GREATEST(COALESCE(c.relations_modified_at, \'1970-01-01 00:00:00\'), c.modified_at), \'%Y-%m-%d %H:%i:%s\')' : 'c.modified_at'; - $sqlDateFormat = '%Y-%m-%d %H:%i:%s'; - - $query = sprintf($queryFormat, $parentTable, $childTable, $parentTableId, $childTableId, $childGreatest, $sqlDateFormat, $jsonKey, $jsonGreatest); - - // Add WHERE clause to only update rows that have been modified since ":modified_at" - if ($withWhereClause) { - $query .= ' WHERE p.modified_at >= :modified_at OR c.modified_at >= :modified_at'; - - if ($childHasRelations) { - $query .= ' OR c.relations_modified_at >= :modified_at'; - } - } - - return $query; - } - - /** - * Get "to many" query. - * - * For a table (parent) that has a relation to another table (child) through a pivot table where we need to update the "relations_modified_at" - * and "relations_modified" fields on the parent with values from the child we need to join the tables and set the values. - * - * Basically we do: - * "Update parent, join temp (SELECT id and c.modified_at from the child row with the MAX (latest) modified_at), set parent values = child values" - * - * Example: - * UPDATE - * slide p - * INNER JOIN ( - * SELECT - * pivot.slide_id, max(c.modified_at) as max_modified_at - * FROM - * slide_media pivot - * INNER JOIN - * media c ON pivot.media_id=c.id - * GROUP BY - * pivot.slide_id - * ) temp - * ON - * p.id = temp.slide_id - * SET - * p.relations_modified_at = DATE_FORMAT(GREATEST(COALESCE(p.relations_modified_at, '1970-01-01 00:00:00'), temp.max_modified_at), '%Y-%m-%d %H:%i:%s'), - * p.relations_modified = JSON_SET(p.relations_modified, "$.media", max_modified_at) - * WHERE - * p.modified_at >= :modified_at OR max_modified_at >= :modified_at - * - * Explanation: - * Because this is a "to many" relation we need to SELECT the MAX (latest) modified_at timestamp from the child relations. This is done in a temporary table - * with SELECT max() and GROUP BY parent id in the pivot table. This gives us just one child row for each parent row with the latest timestamp. - * - * This temp table is then joined to the parent table to allow us to SET the p.relations_modified_at and p.relations_modified values on the parent. - * - Because "relations_modified_at" can be null and GREATEST() will return null if the given parameter list contains null we need to COALESCE() null values to a date we know to be in the past - * - Because GREATEST() will return a date in numeric format we need to use DATE_FORMAT() to ensure consistent date formats - * WHERE either p.modified_at or (child) max_modified_at is greater than a given timestamp - * - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the modified_at timestamps as clause in WHERE to limit to only update the rows just modified. - * - * @param string $jsonKey - * @param string $parentTable - * @param string $pivotTable - * @param string $childTable - * @param bool $withWhereClause - * - * @return string - */ - private static function getToManyQuery(string $jsonKey, string $parentTable, string $pivotTable, string $childTable, bool $withWhereClause = true): string - { - $parentTableId = $parentTable.'_id'; - $childTableId = $childTable.'_id'; - $dbDateFormat = '%Y-%m-%d %H:%i:%s'; - - $queryFormat = 'UPDATE %s p INNER JOIN (SELECT pivot.%s, max(c.modified_at) as max_modified_at - FROM %s pivot INNER JOIN %s c ON pivot.%s=c.id GROUP BY pivot.%s) temp ON p.id = temp.%s - SET p.relations_modified_at = DATE_FORMAT(GREATEST(COALESCE(p.relations_modified_at, \'1970-01-01 00:00:00\'), temp.max_modified_at), \'%s\'), - p.relations_modified = JSON_SET(p.relations_modified, "$.%s", max_modified_at)'; - - $query = sprintf($queryFormat, $parentTable, $parentTableId, $pivotTable, $childTable, $childTableId, $parentTableId, $parentTableId, $dbDateFormat, $jsonKey); - if ($withWhereClause) { - $query .= ' WHERE p.modified_at >= :modified_at OR max_modified_at >= :modified_at'; - } - - return $query; - } -} diff --git a/migrations/Version20240110091802.php b/migrations/Version20240110091802.php deleted file mode 100644 index 81fb3b00f..000000000 --- a/migrations/Version20240110091802.php +++ /dev/null @@ -1,35 +0,0 @@ -addSql('DROP INDEX relations_modified_at_idx ON theme'); - $this->addSql('DROP INDEX modified_at_idx ON theme'); - $this->addSql('ALTER TABLE theme DROP relations_modified_at, DROP relations_modified'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE theme ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON theme (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON theme (modified_at)'); - } -} diff --git a/migrations/Version20240116162235.php b/migrations/Version20240116162235.php deleted file mode 100644 index 018ea9e2c..000000000 --- a/migrations/Version20240116162235.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE UNIQUE INDEX UNIQ_E88B201577153098 ON user_activation_code (code)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX UNIQ_E88B201577153098 ON user_activation_code'); - } -} diff --git a/migrations/Version20240221142818.php b/migrations/Version20240221142818.php deleted file mode 100644 index 5df96c057..000000000 --- a/migrations/Version20240221142818.php +++ /dev/null @@ -1,441 +0,0 @@ -addSql('DROP INDEX relations_modified_at_idx ON feed'); - $this->addSql('DROP INDEX modified_at_idx ON feed'); - $this->addSql('ALTER TABLE feed ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON feed (changed)'); - $this->addSql('ALTER TABLE feed_source ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, ADD relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON feed_source (changed)'); - $this->addSql('ALTER TABLE media ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, ADD relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON media (changed)'); - $this->addSql('DROP INDEX modified_at_idx ON playlist'); - $this->addSql('DROP INDEX relations_modified_at_idx ON playlist'); - $this->addSql('ALTER TABLE playlist ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON playlist (changed)'); - $this->addSql('DROP INDEX relations_modified_at_idx ON playlist_screen_region'); - $this->addSql('DROP INDEX modified_at_idx ON playlist_screen_region'); - $this->addSql('ALTER TABLE playlist_screen_region ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON playlist_screen_region (changed)'); - $this->addSql('DROP INDEX relations_modified_at_idx ON playlist_slide'); - $this->addSql('DROP INDEX modified_at_idx ON playlist_slide'); - $this->addSql('ALTER TABLE playlist_slide ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON playlist_slide (changed)'); - $this->addSql('ALTER TABLE schedule ADD version INT DEFAULT 1 NOT NULL'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen'); - $this->addSql('DROP INDEX modified_at_idx ON screen'); - $this->addSql('ALTER TABLE screen ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON screen (changed)'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen_campaign'); - $this->addSql('DROP INDEX modified_at_idx ON screen_campaign'); - $this->addSql('ALTER TABLE screen_campaign ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON screen_campaign (changed)'); - $this->addSql('DROP INDEX modified_at_idx ON screen_group'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen_group'); - $this->addSql('ALTER TABLE screen_group ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON screen_group (changed)'); - $this->addSql('DROP INDEX relations_modified_at_idx ON screen_group_campaign'); - $this->addSql('DROP INDEX modified_at_idx ON screen_group_campaign'); - $this->addSql('ALTER TABLE screen_group_campaign ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON screen_group_campaign (changed)'); - $this->addSql('ALTER TABLE screen_layout ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON screen_layout (changed)'); - $this->addSql('ALTER TABLE screen_layout_regions ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON screen_layout_regions (changed)'); - $this->addSql('ALTER TABLE screen_user ADD version INT DEFAULT 1 NOT NULL'); - $this->addSql('DROP INDEX modified_at_idx ON slide'); - $this->addSql('DROP INDEX relations_modified_at_idx ON slide'); - $this->addSql('ALTER TABLE slide ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, DROP relations_modified_at, CHANGE relations_modified relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON slide (changed)'); - $this->addSql('ALTER TABLE template ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, ADD relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON template (changed)'); - $this->addSql('ALTER TABLE tenant ADD version INT DEFAULT 1 NOT NULL'); - $this->addSql('ALTER TABLE theme ADD version INT DEFAULT 1 NOT NULL, ADD changed TINYINT(1) NOT NULL, ADD relations_checksum JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX changed_idx ON theme (changed)'); - $this->addSql('ALTER TABLE user ADD version INT DEFAULT 1 NOT NULL'); - $this->addSql('ALTER TABLE user_role_tenant ADD version INT DEFAULT 1 NOT NULL'); - - // Populate newly created 'changed' and 'relations_modified' fields with correct data. - // Copy of the UPDATE queries defined in the doctrine listener but without a WHERE clause. - // Duplication ensures that the queries match the schema for this migration even if the schema and - // queries are refactored. - $sqlQueries = self::getUpdateRelationsAtQueries(withWhereClause: false); - foreach ($sqlQueries as $sqlQuery) { - $this->addSql($sqlQuery); - } - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX changed_idx ON template'); - $this->addSql('ALTER TABLE template DROP version, DROP changed, DROP relations_checksum'); - $this->addSql('DROP INDEX changed_idx ON slide'); - $this->addSql('ALTER TABLE slide ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX modified_at_idx ON slide (modified_at)'); - $this->addSql('CREATE INDEX relations_modified_at_idx ON slide (relations_modified_at)'); - $this->addSql('ALTER TABLE user DROP version'); - $this->addSql('ALTER TABLE schedule DROP version'); - $this->addSql('DROP INDEX changed_idx ON screen_group'); - $this->addSql('ALTER TABLE screen_group ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX modified_at_idx ON screen_group (modified_at)'); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen_group (relations_modified_at)'); - $this->addSql('ALTER TABLE tenant DROP version'); - $this->addSql('DROP INDEX changed_idx ON feed_source'); - $this->addSql('ALTER TABLE feed_source DROP version, DROP changed, DROP relations_checksum'); - $this->addSql('DROP INDEX changed_idx ON screen_group_campaign'); - $this->addSql('ALTER TABLE screen_group_campaign ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen_group_campaign (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen_group_campaign (modified_at)'); - $this->addSql('DROP INDEX changed_idx ON screen_layout_regions'); - $this->addSql('ALTER TABLE screen_layout_regions ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('DROP INDEX changed_idx ON playlist_slide'); - $this->addSql('ALTER TABLE playlist_slide ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON playlist_slide (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON playlist_slide (modified_at)'); - $this->addSql('DROP INDEX changed_idx ON theme'); - $this->addSql('ALTER TABLE theme DROP version, DROP changed, DROP relations_checksum'); - $this->addSql('DROP INDEX changed_idx ON playlist'); - $this->addSql('ALTER TABLE playlist ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX modified_at_idx ON playlist (modified_at)'); - $this->addSql('CREATE INDEX relations_modified_at_idx ON playlist (relations_modified_at)'); - $this->addSql('DROP INDEX changed_idx ON feed'); - $this->addSql('ALTER TABLE feed ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON feed (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON feed (modified_at)'); - $this->addSql('DROP INDEX changed_idx ON playlist_screen_region'); - $this->addSql('ALTER TABLE playlist_screen_region ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON playlist_screen_region (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON playlist_screen_region (modified_at)'); - $this->addSql('ALTER TABLE screen_user DROP version'); - $this->addSql('DROP INDEX changed_idx ON screen_campaign'); - $this->addSql('ALTER TABLE screen_campaign ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen_campaign (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen_campaign (modified_at)'); - $this->addSql('ALTER TABLE user_role_tenant DROP version'); - $this->addSql('DROP INDEX changed_idx ON screen_layout'); - $this->addSql('ALTER TABLE screen_layout ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('DROP INDEX changed_idx ON media'); - $this->addSql('ALTER TABLE media DROP version, DROP changed, DROP relations_checksum'); - $this->addSql('DROP INDEX changed_idx ON screen'); - $this->addSql('ALTER TABLE screen ADD relations_modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP version, DROP changed, CHANGE relations_checksum relations_modified JSON DEFAULT \'{}\' NOT NULL COMMENT \'(DC2Type:json)\''); - $this->addSql('CREATE INDEX relations_modified_at_idx ON screen (relations_modified_at)'); - $this->addSql('CREATE INDEX modified_at_idx ON screen (modified_at)'); - } - - /** - * Get an array of SQL update statements to update the changed and relationsModified fields. - * - * @param bool $withWhereClause - * Should the statements include a where clause to limit the statement - * - * @return string[] - * Array of SQL statements - */ - public static function getUpdateRelationsAtQueries(bool $withWhereClause = true): array - { - // Set SQL update queries for the "relations checksum" fields on the parent (p), child (c) relationships up through the entity tree - $sqlQueries = []; - - // Feed - $sqlQueries[] = self::getToOneQuery(jsonKey: 'feedSource', parentTable: 'feed', childTable: 'feed_source', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'slide', parentTable: 'feed', childTable: 'slide', parentTableId: 'id', childTableId: 'feed_id', withWhereClause: $withWhereClause); - - // Slide - $sqlQueries[] = self::getManyToManyQuery(jsonKey: 'media', parentTable: 'slide', pivotTable: 'slide_media', childTable: 'media', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'theme', parentTable: 'slide', childTable: 'theme', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'templateInfo', parentTable: 'slide', childTable: 'template', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'feed', parentTable: 'slide', childTable: 'feed', withWhereClause: $withWhereClause); - - // PlaylistSlide - $sqlQueries[] = self::getToOneQuery(jsonKey: 'slide', parentTable: 'playlist_slide', childTable: 'slide', withWhereClause: $withWhereClause); - - // Playlist - $sqlQueries[] = self::getOneToManyQuery(jsonKey: 'slides', parentTable: 'playlist', childTable: 'playlist_slide', withWhereClause: $withWhereClause); - - // ScreenCampaign - $sqlQueries[] = self::getToOneQuery(jsonKey: 'campaign', parentTable: 'screen_campaign', childTable: 'playlist', parentTableId: 'campaign_id', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'screen', parentTable: 'screen_campaign', childTable: 'screen', withWhereClause: $withWhereClause); - - // ScreenGroupCampaign - campaign - $sqlQueries[] = self::getToOneQuery(jsonKey: 'campaign', parentTable: 'screen_group_campaign', childTable: 'playlist', parentTableId: 'campaign_id', withWhereClause: $withWhereClause); - - // ScreenGroup - $sqlQueries[] = self::getManyToManyQuery(jsonKey: 'screens', parentTable: 'screen_group', pivotTable: 'screen_group_screen', childTable: 'screen', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getOneToManyQuery(jsonKey: 'screenGroupCampaigns', parentTable: 'screen_group', childTable: 'screen_group_campaign', withWhereClause: $withWhereClause); - - // ScreenGroupCampaign - screenGroup - $sqlQueries[] = self::getToOneQuery(jsonKey: 'screenGroup', parentTable: 'screen_group_campaign', childTable: 'screen_group', withWhereClause: $withWhereClause); - - // PlaylistScreenRegion - $sqlQueries[] = self::getToOneQuery(jsonKey: 'playlist', parentTable: 'playlist_screen_region', childTable: 'playlist', withWhereClause: $withWhereClause); - - // ScreenLayoutRegions - $sqlQueries[] = self::getToOneQuery(jsonKey: 'regions', parentTable: 'screen_layout_regions', childTable: 'playlist_screen_region', parentTableId: 'id', childTableId: 'region_id', withWhereClause: $withWhereClause); - - // ScreenLayout - $sqlQueries[] = self::getOneToManyQuery(jsonKey: 'regions', parentTable: 'screen_layout', childTable: 'screen_layout_regions', withWhereClause: $withWhereClause); - - // Screen - $sqlQueries[] = self::getOneToManyQuery(jsonKey: 'campaigns', parentTable: 'screen', childTable: 'screen_campaign', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getToOneQuery(jsonKey: 'layout', parentTable: 'screen', childTable: 'screen_layout', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getOneToManyQuery(jsonKey: 'regions', parentTable: 'screen', childTable: 'playlist_screen_region', withWhereClause: $withWhereClause); - $sqlQueries[] = self::getManyToManyQuery(jsonKey: 'inScreenGroups', parentTable: 'screen', pivotTable: 'screen_group_screen', childTable: 'screen_group', withWhereClause: $withWhereClause); - - // Add reset 'changed' fields queries - $sqlQueries = array_merge($sqlQueries, self::getResetChangedQueries()); - - return $sqlQueries; - } - - /** - * Get "One/ManyToOne" query. - * - * For a table (parent) that has a relation to another table (child) where we need to update the "relations_checksum" - * field on the parent with a checksum of values from the child we need to join the tables and set the values. - * - * Basically we do: "Update parent, join child, set parent value = SHA(child values)" - * - * Example: - * UPDATE slide p - * INNER JOIN theme c ON p.theme_id = c.id - * SET p.changed = 1, - * p.relations_checksum = JSON_SET(p.relations_checksum, "$.theme", SHA1(CONCAT(c.id, c.version, c.relations_checksum))) - * WHERE - * p.changed = 1 - * OR c.changed = 1 - * - * Explanation: - * UPDATE parent table p, INNER JOIN child table c - * - use INNER JOIN because the query only makes sense for result where both parent and child tables have rows - * SET changed to 1 (true) to enable propagation up the tree. - * SET the value for the relevant json key on the json object in p.relations_checksum to the checksum of the child id, version and relations checksum - * WHERE either p.changed or c.changed is true - * - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the bool "changed" as clause in WHERE to limit to only update the rows just modified. - * - * @param string $jsonKey - * @param string $parentTable - * @param string $childTable - * @param string|null $parentTableId - * @param string $childTableId - * @param bool $withWhereClause - * - * @return string - */ - private static function getToOneQuery(string $jsonKey, string $parentTable, string $childTable, ?string $parentTableId = null, string $childTableId = 'id', bool $withWhereClause = true): string - { - // Set the column name to use for "ON" in the Join clause. By default, the child table name with "_id" appended. - // E.g. "UPDATE feed p INNER JOIN feed_source c ON p.feed_source_id = c.id" - $parentTableId = (null === $parentTableId) ? $childTable.'_id' : $parentTableId; - - // The base UPDATE query. - // - Use INNER JON to only select rows that have a match in both parent and child tables - // - Use JSON_SET to only INSERT/UPDATE the relevant key in the json object, not the whole field. - $queryFormat = ' - UPDATE %s p - INNER JOIN %s c ON p.%s = c.%s - SET p.changed = 1, - p.relations_checksum = JSON_SET(p.relations_checksum, "$.%s", SHA1(CONCAT(c.id, c.version, c.relations_checksum))) - '; - - $query = sprintf($queryFormat, $parentTable, $childTable, $parentTableId, $childTableId, $jsonKey); - - // Add WHERE clause to only update rows that have been modified since ":modified_at" - if ($withWhereClause) { - $query .= ' WHERE p.changed = 1 OR c.changed = 1'; - } - - return $query; - } - - /** - * Get "OnetoMany" query. - * - * For a table (parent) that has a toMany relationship to another table (child) where we need to update the "relations_checksum" - * field on the parent with a checksum of values from the child we need to join the tables and set the values. - * - * Example: - * UPDATE - * playlist p - * INNER JOIN ( - * SELECT - * c.playlist_id, - * CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed, - * SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum - * FROM - * playlist_slide c - * GROUP BY - * c.playlist_id - * ) temp ON p.id = temp.playlist_id - * SET p.changed = 1, - * p.relations_checksum = JSON_SET(p.relations_checksum, "$.slides", temp.checksum) - * WHERE p.changed = 1 OR temp.changed = 1 - * - * Explanation: - * Because this is a "to many" relation we need to GROUP_CONCAT values from the child relations. This is done in a temporary table - * with GROUP BY parent id in the child table. This gives us just one child row for each parent row with a checksum from the relevant - * fields across all child rows. - * - * This temp table is then joined to the parent table to allow us to SET the p.changed and p.relations_checksum values on the parent. - * - Because GROUP_CONCAT will give us all child rows "changed" as one, e.g. "00010001" we need "> 0" to ecaluate to true/false - * and then CAST that to "unsigned" to get a TINYINT (bool) - * WHERE either p.changed or c.changed is true - * - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the bool "changed" as clause in - * WHERE to limit to only update the rows just modified. - * - * @param string $jsonKey - * @param string $parentTable - * @param string $childTable - * @param bool $withWhereClause - * - * @return string - */ - private static function getOneToManyQuery(string $jsonKey, string $parentTable, string $childTable, bool $withWhereClause = true): string - { - $parentTableId = $parentTable.'_id'; - - $queryFormat = ' - UPDATE - %s p - INNER JOIN ( - SELECT - c.%s, - CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed, - SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum - FROM - %s c - GROUP BY - c.%s - ) temp ON p.id = temp.%s - SET p.changed = 1, - p.relations_checksum = JSON_SET(p.relations_checksum, "$.%s", temp.checksum) - '; - - $query = sprintf($queryFormat, $parentTable, $parentTableId, $childTable, $parentTableId, $parentTableId, $jsonKey); - - if ($withWhereClause) { - $query .= ' WHERE p.changed = 1 OR temp.changed = 1'; - } - - return $query; - } - - /** - * Get "many to many" query. - * - * For a table (parent) that has a relation to another table (child) through a pivot table where we need to update the "changed" - * and "relations_checksum" fields on the parent with values from the child we need to join the tables and set the values. - * - * Basically we do: - * "Update parent, join temp (SELECT checksum of c.id, c.version, c.relations_checksum from the child rows with GROUP_CONCAT), set parent values = child values" - * - * Example: - * UPDATE - * slide p - * INNER JOIN ( - * SELECT - * pivot.slide_id, - * CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed, - * SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum - * FROM - * slide_media pivot - * INNER JOIN media c ON pivot.media_id = c.id - * GROUP BY - * pivot.slide_id - * ) temp ON p.id = temp.slide_id - * SET p.changed = 1, - * p.relations_checksum = JSON_SET(p.relations_checksum, "$.media", temp.checksum) - * WHERE p.changed = 1 OR temp.changed = 1 - * - * Explanation: - * Because this is a "to many" relation we need to GROUP_CONCAT values from the child relations. This is done in a temporary table - * with GROUP BY parent id in the child table. This gives us just one child row for each parent row with a checksum from the relevant - * fields across all child rows. - * - * This temp table is then joined to the parent table to allow us to SET the p.changed and p.relations_checksum values on the parent. - * - Because GROUP_CONCAT will give us all child rows "changed" as one, e.g. "00010001" we need "> 0" to ecaluate to true/false - * and then CAST that to "unsigned" to get a TINYINT (bool) - * WHERE either p.changed or c.changed is true - * - Because we can't easily get a list of ID's of affected rows as we work up the tree we use the bool "changed" as clause in - * WHERE to limit to only update the rows just modified. - * - * @param string $jsonKey - * @param string $parentTable - * @param string $pivotTable - * @param string $childTable - * @param bool $withWhereClause - * - * @return string - */ - private static function getManyToManyQuery(string $jsonKey, string $parentTable, string $pivotTable, string $childTable, bool $withWhereClause = true): string - { - $parentTableId = $parentTable.'_id'; - $childTableId = $childTable.'_id'; - - $queryFormat = ' - UPDATE - %s p - INNER JOIN ( - SELECT - pivot.%s, - CAST(GROUP_CONCAT(c.changed SEPARATOR "") > 0 AS UNSIGNED) changed, - SHA1(GROUP_CONCAT(c.id, c.version, c.relations_checksum)) checksum - FROM - %s pivot - INNER JOIN %s c ON pivot.%s = c.id - GROUP BY - pivot.%s - ) temp ON p.id = temp.%s - SET p.changed = 1, - p.relations_checksum = JSON_SET(p.relations_checksum, "$.%s", temp.checksum) - '; - - $query = sprintf($queryFormat, $parentTable, $parentTableId, $pivotTable, $childTable, $childTableId, $parentTableId, $parentTableId, $jsonKey); - if ($withWhereClause) { - $query .= ' WHERE p.changed = 1 OR temp.changed = 1'; - } - - return $query; - } - - /** - * Get an array of queries to reset all "changed" fields to 0. - * - * Example: - * UPDATE screen SET screen.changed = 0 WHERE screen.changed = 1; - * - * @return array - */ - private static function getResetChangedQueries(): array - { - $queries = []; - foreach (self::CHECKSUM_TABLES as $table) { - $queries[] = sprintf('UPDATE %s SET changed = 0 WHERE changed = 1', $table); - } - - return $queries; - } -} diff --git a/migrations/Version20240225055224.php b/migrations/Version20240225055224.php deleted file mode 100644 index 2a0b0347e..000000000 --- a/migrations/Version20240225055224.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE user_activation_code ADD version INT DEFAULT 1 NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE user_activation_code DROP version'); - } -} diff --git a/migrations/Version20240403043527.php b/migrations/Version20240403043527.php deleted file mode 100644 index b93cd0d7a..000000000 --- a/migrations/Version20240403043527.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('CREATE TABLE interactive_slide (id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', tenant_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', version INT DEFAULT 1 NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_by VARCHAR(255) DEFAULT \'\' NOT NULL, modified_by VARCHAR(255) DEFAULT \'\' NOT NULL, configuration JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', implementation_class VARCHAR(255) NOT NULL, INDEX IDX_138E544D9033212A (tenant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE interactive_slide ADD CONSTRAINT FK_138E544D9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE interactive_slide DROP FOREIGN KEY FK_138E544D9033212A'); - $this->addSql('DROP TABLE interactive_slide'); - } -} diff --git a/migrations/Version20240405092445.php b/migrations/Version20240405092445.php deleted file mode 100644 index d055d90f6..000000000 --- a/migrations/Version20240405092445.php +++ /dev/null @@ -1,29 +0,0 @@ -addSql('UPDATE slide SET content = REPLACE(content, \'\\\/v1\\\/media\\\/\', \'\\\/v2\\\/media\\\/\')'); - } - - public function down(Schema $schema): void - { - $this->addSql('UPDATE slide SET content = REPLACE(content, \'\\\/v2\\\/media\\\/\', \'\\\/v1\\\/media\\\/\')'); - } -} diff --git a/migrations/Version20240506084815.php b/migrations/Version20240506084815.php deleted file mode 100644 index 67a04e37c..000000000 --- a/migrations/Version20240506084815.php +++ /dev/null @@ -1,29 +0,0 @@ -addSql('ALTER TABLE screen_user ADD release_timestamp INT DEFAULT NULL, ADD release_version VARCHAR(255) DEFAULT NULL, ADD latest_request DATETIME DEFAULT NULL, ADD client_meta JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE screen_user DROP release_timestamp, DROP release_version, DROP latest_request, DROP client_meta'); - } -} diff --git a/migrations/Version20250815092648.php b/migrations/Version20250815092648.php deleted file mode 100644 index e6833738d..000000000 --- a/migrations/Version20250815092648.php +++ /dev/null @@ -1,28 +0,0 @@ -addSql('ALTER TABLE template DROP icon, DROP resources, DROP description'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE template ADD icon VARCHAR(255) DEFAULT \'\' NOT NULL, ADD resources JSON NOT NULL COMMENT \'(DC2Type:json)\', ADD description VARCHAR(255) DEFAULT \'\' NOT NULL'); - } -} diff --git a/migrations/Version20250828084617.php b/migrations/Version20250828084617.php deleted file mode 100644 index 6c526f84a..000000000 --- a/migrations/Version20250828084617.php +++ /dev/null @@ -1,28 +0,0 @@ -addSql('RENAME TABLE interactive_slide TO interactive_slide_config;'); - $this->addSql('ALTER TABLE interactive_slide_config RENAME INDEX idx_138e544d9033212a TO IDX_D30060259033212A'); - } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE interactive_slide_config RENAME INDEX idx_d30060259033212a TO IDX_138E544D9033212A'); - $this->addSql('RENAME TABLE interactive_slide_config TO interactive_slide;'); - } -} diff --git a/migrations/Version20260506215847.php b/migrations/Version20260506215847.php new file mode 100644 index 000000000..1d9e41d5b --- /dev/null +++ b/migrations/Version20260506215847.php @@ -0,0 +1,920 @@ +addSql(<<<'SQL' + CREATE TABLE feed ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + feed_source_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + configuration JSON DEFAULT NULL COMMENT '(DC2Type:json)', + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_234044AB9033212A (tenant_id), + INDEX IDX_234044ABDDAEFFBD (feed_source_id), + INDEX feed_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE feed_source ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + feed_type VARCHAR(255) NOT NULL, + secrets JSON DEFAULT NULL COMMENT '(DC2Type:json)', + supported_feed_output_type VARCHAR(255) NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_9DA80F879033212A (tenant_id), + INDEX feed_source_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE interactive_slide_config ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + configuration JSON DEFAULT NULL COMMENT '(DC2Type:json)', + implementation_class VARCHAR(255) NOT NULL, + INDEX IDX_D30060259033212A (tenant_id), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE media ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + file_path VARCHAR(255) DEFAULT NULL, + license VARCHAR(255) DEFAULT '', + width INT DEFAULT 0 NOT NULL, + height INT DEFAULT 0 NOT NULL, + size INT DEFAULT 0 NOT NULL, + mime_type VARCHAR(255) DEFAULT '' NOT NULL, + sha VARCHAR(255) DEFAULT '' NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_6A2CA10C9033212A (tenant_id), + INDEX media_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE playlist ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + is_campaign TINYINT(1) NOT NULL, + published_from DATETIME DEFAULT NULL, + published_to DATETIME DEFAULT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_D782112D9033212A (tenant_id), + INDEX playlist_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE playlist_tenant ( + playlist_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + INDEX IDX_A12FC8516BBD148 (playlist_id), + INDEX IDX_A12FC8519033212A (tenant_id), + PRIMARY KEY(playlist_id, tenant_id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE playlist_screen_region ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + playlist_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + region_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + weight INT DEFAULT 0 NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_6869486A9033212A (tenant_id), + INDEX IDX_6869486A6BBD148 (playlist_id), + INDEX IDX_6869486A41A67722 (screen_id), + INDEX IDX_6869486A98260155 (region_id), + INDEX playlist_screen_region_changed_idx (changed), + UNIQUE INDEX unique_playlist_screen_region ( + playlist_id, screen_id, region_id + ), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE playlist_slide ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + playlist_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + slide_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + weight INT DEFAULT 0 NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_D1F3F7219033212A (tenant_id), + INDEX IDX_D1F3F7216BBD148 (playlist_id), + INDEX IDX_D1F3F721DD5AFB87 (slide_id), + INDEX playlist_slide_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE refresh_tokens ( + id INT AUTO_INCREMENT NOT NULL, + refresh_token VARCHAR(128) NOT NULL, + username VARCHAR(255) NOT NULL, + valid DATETIME NOT NULL, + UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE schedule ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + playlist_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + rrule VARCHAR(255) NOT NULL COMMENT '(DC2Type:rrule)', + duration INT NOT NULL, + INDEX IDX_5A3811FB9033212A (tenant_id), + INDEX IDX_5A3811FB6BBD148 (playlist_id), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_layout_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + size INT DEFAULT 0 NOT NULL, + resolution VARCHAR(255) DEFAULT '' NOT NULL, + orientation VARCHAR(255) DEFAULT '' NOT NULL, + location VARCHAR(255) DEFAULT '', + enable_color_scheme_change TINYINT(1) DEFAULT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_DF4C61309033212A (tenant_id), + INDEX IDX_DF4C6130C1ECB8D6 (screen_layout_id), + INDEX screen_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_campaign ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + campaign_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_636686BD9033212A (tenant_id), + INDEX IDX_636686BDF639F774 (campaign_id), + INDEX IDX_636686BD41A67722 (screen_id), + INDEX screen_campaign_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_group ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_10C764819033212A (tenant_id), + INDEX screen_group_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_group_screen ( + screen_group_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + INDEX IDX_905749ED82274D27 (screen_group_id), + INDEX IDX_905749ED41A67722 (screen_id), + PRIMARY KEY(screen_group_id, screen_id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_group_campaign ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + campaign_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_group_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_1E364E6E9033212A (tenant_id), + INDEX IDX_1E364E6EF639F774 (campaign_id), + INDEX IDX_1E364E6E82274D27 (screen_group_id), + INDEX screen_group_campaign_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_layout ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + grid_rows INT DEFAULT 0 NOT NULL, + grid_columns INT DEFAULT 0 NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX screen_layout_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_layout_tenant ( + screen_layout_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + INDEX IDX_4B4C32E9C1ECB8D6 (screen_layout_id), + INDEX IDX_4B4C32E99033212A (tenant_id), + PRIMARY KEY(screen_layout_id, tenant_id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_layout_regions ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_layout_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + grid_area JSON NOT NULL COMMENT '(DC2Type:json)', + type VARCHAR(255) DEFAULT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_D80836ADC1ECB8D6 (screen_layout_id), + INDEX screen_layout_regions_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_layout_regions_tenant ( + screen_layout_regions_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + INDEX IDX_90A5AF483026129C (screen_layout_regions_id), + INDEX IDX_90A5AF489033212A (tenant_id), + PRIMARY KEY( + screen_layout_regions_id, tenant_id + ) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE screen_user ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + screen_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + username VARCHAR(180) NOT NULL, + roles JSON NOT NULL COMMENT '(DC2Type:json)', + release_timestamp INT DEFAULT NULL, + release_version VARCHAR(255) DEFAULT NULL, + latest_request DATETIME DEFAULT NULL, + client_meta JSON DEFAULT NULL COMMENT '(DC2Type:json)', + UNIQUE INDEX UNIQ_8D2D23C6F85E0677 (username), + INDEX IDX_8D2D23C69033212A (tenant_id), + UNIQUE INDEX UNIQ_8D2D23C641A67722 (screen_id), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE slide ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + template_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + theme_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:ulid)', + feed_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + duration INT DEFAULT NULL, + content JSON DEFAULT NULL COMMENT '(DC2Type:json)', + template_options JSON DEFAULT NULL COMMENT '(DC2Type:json)', + published_from DATETIME DEFAULT NULL, + published_to DATETIME DEFAULT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_72EFEE629033212A (tenant_id), + INDEX IDX_72EFEE625DA0FB8 (template_id), + INDEX IDX_72EFEE6259027487 (theme_id), + UNIQUE INDEX UNIQ_72EFEE6251A5BC03 (feed_id), + INDEX slide_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE slide_media ( + slide_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + media_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + INDEX IDX_EBA5772FDD5AFB87 (slide_id), + INDEX IDX_EBA5772FEA9FDD75 (media_id), + PRIMARY KEY(slide_id, media_id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE template ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + icon VARCHAR(255) DEFAULT '' NOT NULL, + resources JSON NOT NULL COMMENT '(DC2Type:json)', + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX template_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE template_tenant ( + template_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + INDEX IDX_45B1CD905DA0FB8 (template_id), + INDEX IDX_45B1CD909033212A (tenant_id), + PRIMARY KEY(template_id, tenant_id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE tenant ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + tenant_key VARCHAR(25) NOT NULL, + fallback_image_url VARCHAR(255) DEFAULT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + UNIQUE INDEX UNIQ_4E59C4623A6F39CD (tenant_key), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE theme ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + logo_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + css_styles LONGTEXT NOT NULL, + title VARCHAR(255) DEFAULT '' NOT NULL, + description VARCHAR(255) DEFAULT '' NOT NULL, + changed TINYINT(1) NOT NULL, + relations_checksum JSON DEFAULT '{}' NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_9775E7089033212A (tenant_id), + UNIQUE INDEX UNIQ_9775E708F98F144A (logo_id), + INDEX theme_changed_idx (changed), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE `user` ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + provider_id VARCHAR(255) NOT NULL, + email VARCHAR(180) NOT NULL, + full_name VARCHAR(255) NOT NULL, + password VARCHAR(255) NOT NULL, + provider VARCHAR(255) NOT NULL, + user_type VARCHAR(255) NOT NULL, + UNIQUE INDEX UNIQ_8D93D649A53A8AA (provider_id), + UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE user_activation_code ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + code VARCHAR(255) NOT NULL, + code_expire DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + username VARCHAR(255) NOT NULL, + roles JSON NOT NULL COMMENT '(DC2Type:json)', + UNIQUE INDEX UNIQ_E88B201577153098 (code), + INDEX IDX_E88B20159033212A (tenant_id), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE user_role_tenant ( + id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + user_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + tenant_id BINARY(16) NOT NULL COMMENT '(DC2Type:ulid)', + version INT DEFAULT 1 NOT NULL, + created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + modified_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', + created_by VARCHAR(255) DEFAULT '' NOT NULL, + modified_by VARCHAR(255) DEFAULT '' NOT NULL, + roles JSON NOT NULL COMMENT '(DC2Type:json)', + INDEX IDX_4C64EC46A76ED395 (user_id), + INDEX IDX_4C64EC469033212A (tenant_id), + UNIQUE INDEX user_tenant_unique (user_id, tenant_id), + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + feed + ADD + CONSTRAINT FK_234044AB9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + feed + ADD + CONSTRAINT FK_234044ABDDAEFFBD FOREIGN KEY (feed_source_id) REFERENCES feed_source (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + feed_source + ADD + CONSTRAINT FK_9DA80F879033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + interactive_slide_config + ADD + CONSTRAINT FK_D30060259033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + media + ADD + CONSTRAINT FK_6A2CA10C9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist + ADD + CONSTRAINT FK_D782112D9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_tenant + ADD + CONSTRAINT FK_A12FC8516BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_tenant + ADD + CONSTRAINT FK_A12FC8519033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_screen_region + ADD + CONSTRAINT FK_6869486A9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_screen_region + ADD + CONSTRAINT FK_6869486A6BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_screen_region + ADD + CONSTRAINT FK_6869486A41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_screen_region + ADD + CONSTRAINT FK_6869486A98260155 FOREIGN KEY (region_id) REFERENCES screen_layout_regions (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_slide + ADD + CONSTRAINT FK_D1F3F7219033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_slide + ADD + CONSTRAINT FK_D1F3F7216BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + playlist_slide + ADD + CONSTRAINT FK_D1F3F721DD5AFB87 FOREIGN KEY (slide_id) REFERENCES slide (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + schedule + ADD + CONSTRAINT FK_5A3811FB9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + schedule + ADD + CONSTRAINT FK_5A3811FB6BBD148 FOREIGN KEY (playlist_id) REFERENCES playlist (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen + ADD + CONSTRAINT FK_DF4C61309033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen + ADD + CONSTRAINT FK_DF4C6130C1ECB8D6 FOREIGN KEY (screen_layout_id) REFERENCES screen_layout (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_campaign + ADD + CONSTRAINT FK_636686BD9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_campaign + ADD + CONSTRAINT FK_636686BDF639F774 FOREIGN KEY (campaign_id) REFERENCES playlist (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_campaign + ADD + CONSTRAINT FK_636686BD41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_group + ADD + CONSTRAINT FK_10C764819033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_group_screen + ADD + CONSTRAINT FK_905749ED82274D27 FOREIGN KEY (screen_group_id) REFERENCES screen_group (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_group_screen + ADD + CONSTRAINT FK_905749ED41A67722 FOREIGN KEY (screen_id) REFERENCES screen (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_group_campaign + ADD + CONSTRAINT FK_1E364E6E9033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_group_campaign + ADD + CONSTRAINT FK_1E364E6EF639F774 FOREIGN KEY (campaign_id) REFERENCES playlist (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_group_campaign + ADD + CONSTRAINT FK_1E364E6E82274D27 FOREIGN KEY (screen_group_id) REFERENCES screen_group (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_layout_tenant + ADD + CONSTRAINT FK_4B4C32E9C1ECB8D6 FOREIGN KEY (screen_layout_id) REFERENCES screen_layout (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_layout_tenant + ADD + CONSTRAINT FK_4B4C32E99033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_layout_regions + ADD + CONSTRAINT FK_D80836ADC1ECB8D6 FOREIGN KEY (screen_layout_id) REFERENCES screen_layout (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_layout_regions_tenant + ADD + CONSTRAINT FK_90A5AF483026129C FOREIGN KEY (screen_layout_regions_id) REFERENCES screen_layout_regions (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_layout_regions_tenant + ADD + CONSTRAINT FK_90A5AF489033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_user + ADD + CONSTRAINT FK_8D2D23C69033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + screen_user + ADD + CONSTRAINT FK_8D2D23C641A67722 FOREIGN KEY (screen_id) REFERENCES screen (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + slide + ADD + CONSTRAINT FK_72EFEE629033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + slide + ADD + CONSTRAINT FK_72EFEE625DA0FB8 FOREIGN KEY (template_id) REFERENCES template (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + slide + ADD + CONSTRAINT FK_72EFEE6259027487 FOREIGN KEY (theme_id) REFERENCES theme (id) ON DELETE + SET + NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + slide + ADD + CONSTRAINT FK_72EFEE6251A5BC03 FOREIGN KEY (feed_id) REFERENCES feed (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + slide_media + ADD + CONSTRAINT FK_EBA5772FDD5AFB87 FOREIGN KEY (slide_id) REFERENCES slide (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + slide_media + ADD + CONSTRAINT FK_EBA5772FEA9FDD75 FOREIGN KEY (media_id) REFERENCES media (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + template_tenant + ADD + CONSTRAINT FK_45B1CD905DA0FB8 FOREIGN KEY (template_id) REFERENCES template (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + template_tenant + ADD + CONSTRAINT FK_45B1CD909033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) ON DELETE CASCADE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + theme + ADD + CONSTRAINT FK_9775E7089033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + theme + ADD + CONSTRAINT FK_9775E708F98F144A FOREIGN KEY (logo_id) REFERENCES media (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + user_activation_code + ADD + CONSTRAINT FK_E88B20159033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + user_role_tenant + ADD + CONSTRAINT FK_4C64EC46A76ED395 FOREIGN KEY (user_id) REFERENCES `user` (id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE + user_role_tenant + ADD + CONSTRAINT FK_4C64EC469033212A FOREIGN KEY (tenant_id) REFERENCES tenant (id) + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE feed DROP FOREIGN KEY FK_234044AB9033212A'); + $this->addSql('ALTER TABLE feed DROP FOREIGN KEY FK_234044ABDDAEFFBD'); + $this->addSql('ALTER TABLE feed_source DROP FOREIGN KEY FK_9DA80F879033212A'); + $this->addSql('ALTER TABLE interactive_slide_config DROP FOREIGN KEY FK_D30060259033212A'); + $this->addSql('ALTER TABLE media DROP FOREIGN KEY FK_6A2CA10C9033212A'); + $this->addSql('ALTER TABLE playlist DROP FOREIGN KEY FK_D782112D9033212A'); + $this->addSql('ALTER TABLE playlist_tenant DROP FOREIGN KEY FK_A12FC8516BBD148'); + $this->addSql('ALTER TABLE playlist_tenant DROP FOREIGN KEY FK_A12FC8519033212A'); + $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A9033212A'); + $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A6BBD148'); + $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A41A67722'); + $this->addSql('ALTER TABLE playlist_screen_region DROP FOREIGN KEY FK_6869486A98260155'); + $this->addSql('ALTER TABLE playlist_slide DROP FOREIGN KEY FK_D1F3F7219033212A'); + $this->addSql('ALTER TABLE playlist_slide DROP FOREIGN KEY FK_D1F3F7216BBD148'); + $this->addSql('ALTER TABLE playlist_slide DROP FOREIGN KEY FK_D1F3F721DD5AFB87'); + $this->addSql('ALTER TABLE schedule DROP FOREIGN KEY FK_5A3811FB9033212A'); + $this->addSql('ALTER TABLE schedule DROP FOREIGN KEY FK_5A3811FB6BBD148'); + $this->addSql('ALTER TABLE screen DROP FOREIGN KEY FK_DF4C61309033212A'); + $this->addSql('ALTER TABLE screen DROP FOREIGN KEY FK_DF4C6130C1ECB8D6'); + $this->addSql('ALTER TABLE screen_campaign DROP FOREIGN KEY FK_636686BD9033212A'); + $this->addSql('ALTER TABLE screen_campaign DROP FOREIGN KEY FK_636686BDF639F774'); + $this->addSql('ALTER TABLE screen_campaign DROP FOREIGN KEY FK_636686BD41A67722'); + $this->addSql('ALTER TABLE screen_group DROP FOREIGN KEY FK_10C764819033212A'); + $this->addSql('ALTER TABLE screen_group_screen DROP FOREIGN KEY FK_905749ED82274D27'); + $this->addSql('ALTER TABLE screen_group_screen DROP FOREIGN KEY FK_905749ED41A67722'); + $this->addSql('ALTER TABLE screen_group_campaign DROP FOREIGN KEY FK_1E364E6E9033212A'); + $this->addSql('ALTER TABLE screen_group_campaign DROP FOREIGN KEY FK_1E364E6EF639F774'); + $this->addSql('ALTER TABLE screen_group_campaign DROP FOREIGN KEY FK_1E364E6E82274D27'); + $this->addSql('ALTER TABLE screen_layout_tenant DROP FOREIGN KEY FK_4B4C32E9C1ECB8D6'); + $this->addSql('ALTER TABLE screen_layout_tenant DROP FOREIGN KEY FK_4B4C32E99033212A'); + $this->addSql('ALTER TABLE screen_layout_regions DROP FOREIGN KEY FK_D80836ADC1ECB8D6'); + $this->addSql('ALTER TABLE screen_layout_regions_tenant DROP FOREIGN KEY FK_90A5AF483026129C'); + $this->addSql('ALTER TABLE screen_layout_regions_tenant DROP FOREIGN KEY FK_90A5AF489033212A'); + $this->addSql('ALTER TABLE screen_user DROP FOREIGN KEY FK_8D2D23C69033212A'); + $this->addSql('ALTER TABLE screen_user DROP FOREIGN KEY FK_8D2D23C641A67722'); + $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE629033212A'); + $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE625DA0FB8'); + $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE6259027487'); + $this->addSql('ALTER TABLE slide DROP FOREIGN KEY FK_72EFEE6251A5BC03'); + $this->addSql('ALTER TABLE slide_media DROP FOREIGN KEY FK_EBA5772FDD5AFB87'); + $this->addSql('ALTER TABLE slide_media DROP FOREIGN KEY FK_EBA5772FEA9FDD75'); + $this->addSql('ALTER TABLE template_tenant DROP FOREIGN KEY FK_45B1CD905DA0FB8'); + $this->addSql('ALTER TABLE template_tenant DROP FOREIGN KEY FK_45B1CD909033212A'); + $this->addSql('ALTER TABLE theme DROP FOREIGN KEY FK_9775E7089033212A'); + $this->addSql('ALTER TABLE theme DROP FOREIGN KEY FK_9775E708F98F144A'); + $this->addSql('ALTER TABLE user_activation_code DROP FOREIGN KEY FK_E88B20159033212A'); + $this->addSql('ALTER TABLE user_role_tenant DROP FOREIGN KEY FK_4C64EC46A76ED395'); + $this->addSql('ALTER TABLE user_role_tenant DROP FOREIGN KEY FK_4C64EC469033212A'); + $this->addSql('DROP TABLE feed'); + $this->addSql('DROP TABLE feed_source'); + $this->addSql('DROP TABLE interactive_slide_config'); + $this->addSql('DROP TABLE media'); + $this->addSql('DROP TABLE playlist'); + $this->addSql('DROP TABLE playlist_tenant'); + $this->addSql('DROP TABLE playlist_screen_region'); + $this->addSql('DROP TABLE playlist_slide'); + $this->addSql('DROP TABLE refresh_tokens'); + $this->addSql('DROP TABLE schedule'); + $this->addSql('DROP TABLE screen'); + $this->addSql('DROP TABLE screen_campaign'); + $this->addSql('DROP TABLE screen_group'); + $this->addSql('DROP TABLE screen_group_screen'); + $this->addSql('DROP TABLE screen_group_campaign'); + $this->addSql('DROP TABLE screen_layout'); + $this->addSql('DROP TABLE screen_layout_tenant'); + $this->addSql('DROP TABLE screen_layout_regions'); + $this->addSql('DROP TABLE screen_layout_regions_tenant'); + $this->addSql('DROP TABLE screen_user'); + $this->addSql('DROP TABLE slide'); + $this->addSql('DROP TABLE slide_media'); + $this->addSql('DROP TABLE template'); + $this->addSql('DROP TABLE template_tenant'); + $this->addSql('DROP TABLE tenant'); + $this->addSql('DROP TABLE theme'); + $this->addSql('DROP TABLE `user`'); + $this->addSql('DROP TABLE user_activation_code'); + $this->addSql('DROP TABLE user_role_tenant'); + } +} diff --git a/src/Entity/ScreenLayout.php b/src/Entity/ScreenLayout.php index 5a8b4c136..c8ba97a07 100644 --- a/src/Entity/ScreenLayout.php +++ b/src/Entity/ScreenLayout.php @@ -17,7 +17,7 @@ #[ORM\Entity(repositoryClass: ScreenLayoutRepository::class)] #[ORM\EntityListeners([\App\EventListener\ScreenLayoutDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'screen_layout_changed_idx')] class ScreenLayout extends AbstractBaseEntity implements MultiTenantInterface, RelationsChecksumInterface { use MultiTenantTrait; diff --git a/src/Entity/ScreenLayoutRegions.php b/src/Entity/ScreenLayoutRegions.php index 0bfc414ae..2d967f94b 100644 --- a/src/Entity/ScreenLayoutRegions.php +++ b/src/Entity/ScreenLayoutRegions.php @@ -17,7 +17,7 @@ #[ORM\Entity(repositoryClass: ScreenLayoutRegionsRepository::class)] #[ORM\EntityListeners([\App\EventListener\ScreenLayoutRegionsDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'screen_layout_regions_changed_idx')] class ScreenLayoutRegions extends AbstractBaseEntity implements MultiTenantInterface, RelationsChecksumInterface { use MultiTenantTrait; diff --git a/src/Entity/Template.php b/src/Entity/Template.php index 6867fb3d6..d1a65c834 100644 --- a/src/Entity/Template.php +++ b/src/Entity/Template.php @@ -18,7 +18,7 @@ #[ORM\Entity(repositoryClass: TemplateRepository::class)] #[ORM\EntityListeners([TemplateDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'template_changed_idx')] class Template extends AbstractBaseEntity implements MultiTenantInterface, RelationsChecksumInterface { use MultiTenantTrait; @@ -27,6 +27,38 @@ class Template extends AbstractBaseEntity implements MultiTenantInterface, Relat #[ORM\Column(type: Types::STRING, length: 255, nullable: false, options: ['default' => ''])] private string $title = ''; + /* + * The three properties below ($icon, $resources, $description) are + * carried over from 2.7 with their original mapping and PHP-level + * defaults so the consolidated end-of-2.8 schema matches both fresh + * installs and 2.x → 3.0 upgraders, and so Doctrine emits a value + * for each on every INSERT (the columns are NOT NULL with no DB + * default). They are intentionally write-only here — no getters, + * no setters, no API exposure (`description` is filtered out of the + * GetCollection search filter via `template.search_filter` in + * `config/services.yaml`). + * + * TODO[3.1]: delete these three properties together with the deferred + * column-drop migration. Both must land in the same change so the + * entity and the schema stay in sync. + */ + + /** @deprecated TODO[3.1]: drop together with the column. */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: false, options: ['default' => ''])] + private string $icon = ''; + + /** + * @deprecated TODO[3.1]: drop together with the column. + * + * @var array + */ + #[ORM\Column(type: Types::JSON)] + private array $resources = []; + + /** @deprecated TODO[3.1]: drop together with the column. */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: false, options: ['default' => ''])] + private string $description = ''; + /** * @var Collection */ diff --git a/src/Entity/Tenant/Feed.php b/src/Entity/Tenant/Feed.php index 4c7ed2cd6..70cc438e5 100644 --- a/src/Entity/Tenant/Feed.php +++ b/src/Entity/Tenant/Feed.php @@ -11,7 +11,7 @@ #[ORM\Entity(repositoryClass: FeedRepository::class)] #[ORM\EntityListeners([\App\EventListener\FeedDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'feed_changed_idx')] class Feed extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use RelationsChecksumTrait; diff --git a/src/Entity/Tenant/FeedSource.php b/src/Entity/Tenant/FeedSource.php index 18b98c5d6..4c7641905 100644 --- a/src/Entity/Tenant/FeedSource.php +++ b/src/Entity/Tenant/FeedSource.php @@ -14,7 +14,7 @@ #[ORM\Entity(repositoryClass: FeedSourceRepository::class)] #[ORM\EntityListeners([\App\EventListener\FeedSourceDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'feed_source_changed_idx')] class FeedSource extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use EntityTitleDescriptionTrait; diff --git a/src/Entity/Tenant/Media.php b/src/Entity/Tenant/Media.php index bb63672ab..14d8fe9d4 100644 --- a/src/Entity/Tenant/Media.php +++ b/src/Entity/Tenant/Media.php @@ -18,7 +18,7 @@ #[Vich\Uploadable] #[ORM\Entity(repositoryClass: MediaRepository::class)] #[ORM\EntityListeners([\App\EventListener\MediaDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'media_changed_idx')] class Media extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use EntityTitleDescriptionTrait; diff --git a/src/Entity/Tenant/Playlist.php b/src/Entity/Tenant/Playlist.php index 93519bbfa..5eeab5e1c 100644 --- a/src/Entity/Tenant/Playlist.php +++ b/src/Entity/Tenant/Playlist.php @@ -17,7 +17,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: PlaylistRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'playlist_changed_idx')] class Playlist extends AbstractTenantScopedEntity implements MultiTenantInterface, RelationsChecksumInterface { use EntityPublishedTrait; diff --git a/src/Entity/Tenant/PlaylistScreenRegion.php b/src/Entity/Tenant/PlaylistScreenRegion.php index 97a7a92b8..59cc1282c 100644 --- a/src/Entity/Tenant/PlaylistScreenRegion.php +++ b/src/Entity/Tenant/PlaylistScreenRegion.php @@ -12,7 +12,7 @@ #[ORM\UniqueConstraint(name: 'unique_playlist_screen_region', columns: ['playlist_id', 'screen_id', 'region_id'])] #[ORM\Entity(repositoryClass: PlaylistScreenRegionRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'playlist_screen_region_changed_idx')] class PlaylistScreenRegion extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use RelationsChecksumTrait; diff --git a/src/Entity/Tenant/PlaylistSlide.php b/src/Entity/Tenant/PlaylistSlide.php index ae8f0a1da..a3a444909 100644 --- a/src/Entity/Tenant/PlaylistSlide.php +++ b/src/Entity/Tenant/PlaylistSlide.php @@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: PlaylistSlideRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'playlist_slide_changed_idx')] class PlaylistSlide extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use RelationsChecksumTrait; diff --git a/src/Entity/Tenant/Screen.php b/src/Entity/Tenant/Screen.php index 56b2f2cd4..7c0c0f3ce 100644 --- a/src/Entity/Tenant/Screen.php +++ b/src/Entity/Tenant/Screen.php @@ -15,7 +15,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: ScreenRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'screen_changed_idx')] class Screen extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use EntityTitleDescriptionTrait; diff --git a/src/Entity/Tenant/ScreenCampaign.php b/src/Entity/Tenant/ScreenCampaign.php index 1101cbf31..599f8ac91 100644 --- a/src/Entity/Tenant/ScreenCampaign.php +++ b/src/Entity/Tenant/ScreenCampaign.php @@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: ScreenCampaignRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'screen_campaign_changed_idx')] class ScreenCampaign extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use RelationsChecksumTrait; diff --git a/src/Entity/Tenant/ScreenGroup.php b/src/Entity/Tenant/ScreenGroup.php index 9357c764f..5732d14f9 100644 --- a/src/Entity/Tenant/ScreenGroup.php +++ b/src/Entity/Tenant/ScreenGroup.php @@ -13,7 +13,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: ScreenGroupRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'screen_group_changed_idx')] class ScreenGroup extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use EntityTitleDescriptionTrait; diff --git a/src/Entity/Tenant/ScreenGroupCampaign.php b/src/Entity/Tenant/ScreenGroupCampaign.php index 8337d3795..8d530575b 100644 --- a/src/Entity/Tenant/ScreenGroupCampaign.php +++ b/src/Entity/Tenant/ScreenGroupCampaign.php @@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: ScreenGroupCampaignRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'screen_group_campaign_changed_idx')] class ScreenGroupCampaign extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use RelationsChecksumTrait; diff --git a/src/Entity/Tenant/Slide.php b/src/Entity/Tenant/Slide.php index e1102bded..4755b3927 100644 --- a/src/Entity/Tenant/Slide.php +++ b/src/Entity/Tenant/Slide.php @@ -15,7 +15,7 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: SlideRepository::class)] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'slide_changed_idx')] class Slide extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use EntityPublishedTrait; diff --git a/src/Entity/Tenant/Theme.php b/src/Entity/Tenant/Theme.php index 8164baaad..1b84fa9dc 100644 --- a/src/Entity/Tenant/Theme.php +++ b/src/Entity/Tenant/Theme.php @@ -14,7 +14,7 @@ #[ORM\Entity(repositoryClass: ThemeRepository::class)] #[ORM\EntityListeners([\App\EventListener\ThemeDoctrineEventListener::class])] -#[ORM\Index(fields: ['changed'], name: 'changed_idx')] +#[ORM\Index(fields: ['changed'], name: 'theme_changed_idx')] class Theme extends AbstractTenantScopedEntity implements RelationsChecksumInterface { use EntityTitleDescriptionTrait; diff --git a/src/Entity/User.php b/src/Entity/User.php index 53b6fdba7..4a04bec70 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -18,6 +18,7 @@ use Symfony\Component\Validator\Constraints as Assert; #[ORM\Entity(repositoryClass: UserRepository::class)] +#[ORM\Table(name: '`user`')] class User extends AbstractBaseEntity implements UserInterface, PasswordAuthenticatedUserInterface, \JsonSerializable, TenantScopedUserInterface { #[Assert\NotBlank]