aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-05-30 20:36:03 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-01 18:23:11 +0100
commite043d884e9dc077f1ab366d956ee7dd9df4c7460 (patch)
tree8679f60e84b1e690f5b44bc8c7cdea040a3127c7
parent8b1ae33144bc4d496980ffc16cd304c8f107aff4 (diff)
downloadgovuk-mini-environment-admin-e043d884e9dc077f1ab366d956ee7dd9df4c7460.tar
govuk-mini-environment-admin-e043d884e9dc077f1ab366d956ee7dd9df4c7460.tar.gz
Add the GovukGuix::Revision commit_hash to the DataSnapshot model
This is to record the revision of govuk-guix used to create the snapshot.
-rw-r--r--app/models/govuk_guix/data_snapshot.rb18
-rw-r--r--db/migrate/20180530192706_add_govuk_guix_revision_to_govuk_guix_data_snapshot.rb16
-rw-r--r--db/structure.sql14
3 files changed, 40 insertions, 8 deletions
diff --git a/app/models/govuk_guix/data_snapshot.rb b/app/models/govuk_guix/data_snapshot.rb
index 743bdbc..4cec33a 100644
--- a/app/models/govuk_guix/data_snapshot.rb
+++ b/app/models/govuk_guix/data_snapshot.rb
@@ -22,13 +22,19 @@
#
# Table name: govuk_guix_data_snapshots
#
-# id :integer not null, primary key
-# store_path :string not null
-# archived :boolean default(FALSE), not null
-# manifest :json not null
-# created_at :datetime not null
-# updated_at :datetime not null
+# id :integer not null, primary key
+# store_path :string not null
+# archived :boolean default(FALSE), not null
+# manifest :json not null
+# created_at :datetime not null
+# updated_at :datetime not null
+# govuk_guix_revision_commit_hash :string not null
#
class GovukGuix::DataSnapshot < ApplicationRecord
+ belongs_to(
+ :govuk_guix_revision,
+ class_name: 'GovukGuix::Revision',
+ foreign_key: 'govuk_guix_revision_commit_hash'
+ )
end
diff --git a/db/migrate/20180530192706_add_govuk_guix_revision_to_govuk_guix_data_snapshot.rb b/db/migrate/20180530192706_add_govuk_guix_revision_to_govuk_guix_data_snapshot.rb
new file mode 100644
index 0000000..5a735dc
--- /dev/null
+++ b/db/migrate/20180530192706_add_govuk_guix_revision_to_govuk_guix_data_snapshot.rb
@@ -0,0 +1,16 @@
+class AddGovukGuixRevisionToGovukGuixDataSnapshot < ActiveRecord::Migration[5.1]
+ def change
+ add_column(
+ :govuk_guix_data_snapshots,
+ :govuk_guix_revision_commit_hash,
+ :string,
+ null: false
+ )
+ add_foreign_key(
+ :govuk_guix_data_snapshots,
+ :govuk_guix_revisions,
+ column: :govuk_guix_revision_commit_hash,
+ primary_key: :commit_hash
+ )
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 08cfe22..500c09d 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -80,7 +80,8 @@ CREATE TABLE public.govuk_guix_data_snapshots (
archived boolean DEFAULT false NOT NULL,
manifest json NOT NULL,
created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
+ updated_at timestamp without time zone NOT NULL,
+ govuk_guix_revision_commit_hash character varying NOT NULL
);
@@ -588,6 +589,14 @@ ALTER TABLE ONLY public.mini_environment_services
--
+-- Name: govuk_guix_data_snapshots fk_rails_59b1facc61; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.govuk_guix_data_snapshots
+ ADD CONSTRAINT fk_rails_59b1facc61 FOREIGN KEY (govuk_guix_revision_commit_hash) REFERENCES public.govuk_guix_revisions(commit_hash);
+
+
+--
-- PostgreSQL database dump complete
--
@@ -623,6 +632,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20180417195307'),
('20180523062426'),
('20180527183740'),
-('20180530191341');
+('20180530191341'),
+('20180530192706');