aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-01 16:41:28 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-01 18:47:00 +0100
commit03b1ffc1a0576f707b323f821597770d66eaae1e (patch)
tree88401a141e48f6d16a36ab3863063a31a9694d14
parent57825439e68e62fc6844bee6c666ac7ad2f01bca (diff)
downloadgovuk-mini-environment-admin-03b1ffc1a0576f707b323f821597770d66eaae1e.tar
govuk-mini-environment-admin-03b1ffc1a0576f707b323f821597770d66eaae1e.tar.gz
Add an optional association to backends for data snapshots
I'm a bit unsure about this, but it feels like generating snapshots remotely is useful, but if that is supported, then a remote snapshot won't be available locally to use. Adding the option of making them backend specific is one way of working around this.
-rw-r--r--app/models/govuk_guix/data_snapshot.rb3
-rw-r--r--db/migrate/20180601153537_add_backend_to_govuk_guix_data_snapshot.rb5
-rw-r--r--db/structure.sql14
3 files changed, 20 insertions, 2 deletions
diff --git a/app/models/govuk_guix/data_snapshot.rb b/app/models/govuk_guix/data_snapshot.rb
index 4cec33a..ec40cc4 100644
--- a/app/models/govuk_guix/data_snapshot.rb
+++ b/app/models/govuk_guix/data_snapshot.rb
@@ -29,6 +29,8 @@
# created_at :datetime not null
# updated_at :datetime not null
# govuk_guix_revision_commit_hash :string not null
+# backend_type :string
+# backend_id :integer
#
class GovukGuix::DataSnapshot < ApplicationRecord
@@ -37,4 +39,5 @@ class GovukGuix::DataSnapshot < ApplicationRecord
class_name: 'GovukGuix::Revision',
foreign_key: 'govuk_guix_revision_commit_hash'
)
+ belongs_to :backend, polymorphic: true, optional: true
end
diff --git a/db/migrate/20180601153537_add_backend_to_govuk_guix_data_snapshot.rb b/db/migrate/20180601153537_add_backend_to_govuk_guix_data_snapshot.rb
new file mode 100644
index 0000000..9f6f7cc
--- /dev/null
+++ b/db/migrate/20180601153537_add_backend_to_govuk_guix_data_snapshot.rb
@@ -0,0 +1,5 @@
+class AddBackendToGovukGuixDataSnapshot < ActiveRecord::Migration[5.1]
+ def change
+ add_reference :govuk_guix_data_snapshots, :backend, polymorphic: true
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 500c09d..7b5d81f 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -81,7 +81,9 @@ CREATE TABLE public.govuk_guix_data_snapshots (
manifest json NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
- govuk_guix_revision_commit_hash character varying NOT NULL
+ govuk_guix_revision_commit_hash character varying NOT NULL,
+ backend_type character varying,
+ backend_id bigint
);
@@ -538,6 +540,13 @@ ALTER TABLE ONLY public.users
--
+-- Name: index_govuk_guix_data_snapshots_on_backend_type_and_backend_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_govuk_guix_data_snapshots_on_backend_type_and_backend_id ON public.govuk_guix_data_snapshots USING btree (backend_type, backend_id);
+
+
+--
-- Name: index_govuk_guix_data_snapshots_on_store_path; Type: INDEX; Schema: public; Owner: -
--
@@ -633,6 +642,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20180523062426'),
('20180527183740'),
('20180530191341'),
-('20180530192706');
+('20180530192706'),
+('20180601153537');