aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/govuk_guix/data_snapshot.rb34
-rw-r--r--db/migrate/20180530191341_create_govuk_guix_data_snapshots.rb13
-rw-r--r--db/structure.sql58
3 files changed, 104 insertions, 1 deletions
diff --git a/app/models/govuk_guix/data_snapshot.rb b/app/models/govuk_guix/data_snapshot.rb
new file mode 100644
index 0000000..743bdbc
--- /dev/null
+++ b/app/models/govuk_guix/data_snapshot.rb
@@ -0,0 +1,34 @@
+# GOV.UK Mini Environment Admin
+# Copyright © 2018 Christopher Baines <mail@cbaines.net>
+#
+# This file is part of the GOV.UK Mini Environment Admin.
+#
+# The GOV.UK Mini Environment Admin is free software: you can
+# redistribute it and/or modify it under the terms of the GNU Affero
+# General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later
+# version.
+#
+# The GOV.UK Mini Environment Admin is distributed in the hope that it
+# will be useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with the GOV.UK Mini Environment Admin. If not, see
+# <http://www.gnu.org/licenses/>.
+
+# == Schema Information
+#
+# 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
+#
+
+class GovukGuix::DataSnapshot < ApplicationRecord
+end
diff --git a/db/migrate/20180530191341_create_govuk_guix_data_snapshots.rb b/db/migrate/20180530191341_create_govuk_guix_data_snapshots.rb
new file mode 100644
index 0000000..3327127
--- /dev/null
+++ b/db/migrate/20180530191341_create_govuk_guix_data_snapshots.rb
@@ -0,0 +1,13 @@
+class CreateGovukGuixDataSnapshots < ActiveRecord::Migration[5.1]
+ def change
+ create_table :govuk_guix_data_snapshots do |t|
+ t.string :store_path, null: false
+ t.boolean :archived, default: false, null: false
+ t.json :manifest, null: false
+
+ t.timestamps
+ end
+
+ add_index :govuk_guix_data_snapshots, :store_path, unique: true
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index cd71ee3..08cfe22 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -71,6 +71,39 @@ ALTER SEQUENCE public.finished_terraform_jobs_id_seq OWNED BY public.finished_te
--
+-- Name: govuk_guix_data_snapshots; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.govuk_guix_data_snapshots (
+ id bigint NOT NULL,
+ store_path character varying NOT NULL,
+ 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
+);
+
+
+--
+-- Name: govuk_guix_data_snapshots_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE public.govuk_guix_data_snapshots_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: govuk_guix_data_snapshots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE public.govuk_guix_data_snapshots_id_seq OWNED BY public.govuk_guix_data_snapshots.id;
+
+
+--
-- Name: govuk_guix_revisions; Type: TABLE; Schema: public; Owner: -
--
@@ -352,6 +385,13 @@ ALTER TABLE ONLY public.finished_terraform_jobs ALTER COLUMN id SET DEFAULT next
--
+-- Name: govuk_guix_data_snapshots id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.govuk_guix_data_snapshots ALTER COLUMN id SET DEFAULT nextval('public.govuk_guix_data_snapshots_id_seq'::regclass);
+
+
+--
-- Name: mini_environment_services id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -417,6 +457,14 @@ ALTER TABLE ONLY public.finished_terraform_jobs
--
+-- Name: govuk_guix_data_snapshots govuk_guix_data_snapshots_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.govuk_guix_data_snapshots
+ ADD CONSTRAINT govuk_guix_data_snapshots_pkey PRIMARY KEY (id);
+
+
+--
-- Name: govuk_guix_revisions govuk_guix_revisions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -489,6 +537,13 @@ ALTER TABLE ONLY public.users
--
+-- Name: index_govuk_guix_data_snapshots_on_store_path; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE UNIQUE INDEX index_govuk_guix_data_snapshots_on_store_path ON public.govuk_guix_data_snapshots USING btree (store_path);
+
+
+--
-- Name: index_govuk_guix_revisions_on_commit_hash; Type: INDEX; Schema: public; Owner: -
--
@@ -567,6 +622,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20180410192412'),
('20180417195307'),
('20180523062426'),
-('20180527183740');
+('20180527183740'),
+('20180530191341');