diff options
author | Dave Arter <davea@mysociety.org> | 2020-01-28 09:15:59 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-02-14 10:35:37 +0000 |
commit | 7a40c15ea58b9475b40171f50a896fb79b470a94 (patch) | |
tree | 4f6b5a33018ff38ac776959dd6e13aaf77024761 | |
parent | a494edfb9b8b971ef825782123d4422c73288b75 (diff) |
Add ManifestTheme model for customising web manifest
-rwxr-xr-x | bin/update-schema | 1 | ||||
-rw-r--r-- | db/downgrade_0071---0070.sql | 18 | ||||
-rw-r--r-- | db/schema.sql | 11 | ||||
-rw-r--r-- | db/schema_0071-add-manifest-theme.sql | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/ManifestTheme.pm | 47 |
5 files changed, 105 insertions, 0 deletions
diff --git a/bin/update-schema b/bin/update-schema index 807e144eb..7941bc542 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -212,6 +212,7 @@ else { # (assuming schema change files are never half-applied, which should be the case) sub get_db_version { return 'EMPTY' if ! table_exists('problem'); + return '0071' if table_exists('manifest_theme'); return '0070' if column_like('alert_type', "ref='new_problems'", 'head_title', '{{SITE_NAME}}'); return '0069' if constraint_contains('admin_log_object_type_check', 'template'); return '0068' if column_exists('users', 'oidc_ids'); diff --git a/db/downgrade_0071---0070.sql b/db/downgrade_0071---0070.sql new file mode 100644 index 000000000..ebf206624 --- /dev/null +++ b/db/downgrade_0071---0070.sql @@ -0,0 +1,18 @@ +BEGIN; + +DROP TABLE manifest_theme; + +ALTER TABLE admin_log DROP CONSTRAINT admin_log_object_type_check; + +ALTER TABLE admin_log ADD CONSTRAINT admin_log_object_type_check CHECK ( + object_type = 'problem' + OR object_type = 'update' + OR object_type = 'user' + OR object_type = 'moderation' + OR object_type = 'template' + OR object_type = 'body' + OR object_type = 'category' + OR object_type = 'role' +); + +COMMIT; diff --git a/db/schema.sql b/db/schema.sql index cf2914467..0e38ad862 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -449,6 +449,7 @@ create table admin_log ( or object_type = 'body' or object_type = 'category' or object_type = 'role' + or object_type = 'manifesttheme' ), object_id integer not null, action text not null, @@ -562,3 +563,13 @@ CREATE TABLE state ( type text not null check (type = 'open' OR type = 'closed' OR type = 'fixed'), name text not null unique ); + +CREATE TABLE manifest_theme ( + id serial not null primary key, + cobrand text not null unique, + name text not null, + short_name text not null, + background_colour text, + theme_colour text, + images text ARRAY +); diff --git a/db/schema_0071-add-manifest-theme.sql b/db/schema_0071-add-manifest-theme.sql new file mode 100644 index 000000000..308d345f5 --- /dev/null +++ b/db/schema_0071-add-manifest-theme.sql @@ -0,0 +1,28 @@ +BEGIN; + +CREATE TABLE manifest_theme ( + id serial not null primary key, + cobrand text not null unique, + name text not null, + short_name text not null, + background_colour text, + theme_colour text, + images text ARRAY +); + +ALTER TABLE admin_log DROP CONSTRAINT admin_log_object_type_check; + +ALTER TABLE admin_log ADD CONSTRAINT admin_log_object_type_check CHECK ( + object_type = 'problem' + OR object_type = 'update' + OR object_type = 'user' + OR object_type = 'moderation' + OR object_type = 'template' + OR object_type = 'body' + OR object_type = 'category' + OR object_type = 'role' + OR object_type = 'manifesttheme' +); + + +COMMIT; diff --git a/perllib/FixMyStreet/DB/Result/ManifestTheme.pm b/perllib/FixMyStreet/DB/Result/ManifestTheme.pm new file mode 100644 index 000000000..a2f49eacb --- /dev/null +++ b/perllib/FixMyStreet/DB/Result/ManifestTheme.pm @@ -0,0 +1,47 @@ +use utf8; +package FixMyStreet::DB::Result::ManifestTheme; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; +__PACKAGE__->load_components( + "FilterColumn", + "FixMyStreet::InflateColumn::DateTime", + "FixMyStreet::EncodedColumn", +); +__PACKAGE__->table("manifest_theme"); +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + sequence => "manifest_theme_id_seq", + }, + "cobrand", + { data_type => "text", is_nullable => 0 }, + "name", + { data_type => "text", is_nullable => 0 }, + "short_name", + { data_type => "text", is_nullable => 0 }, + "background_colour", + { data_type => "text", is_nullable => 1 }, + "theme_colour", + { data_type => "text", is_nullable => 1 }, + "images", + { data_type => "text[]", is_nullable => 1 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("manifest_theme_cobrand_key", ["cobrand"]); + + +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2020-01-30 14:30:42 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Sgbva7nEVkjqG/+lQL/ryw + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; |