Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0bf3c56d
Commit
0bf3c56d
authored
Mar 05, 2020
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create terraform state model
This model will be used as part of GitLab's terraform state backend
parent
46ac35f4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
0 deletions
+64
-0
app/models/terraform_state.rb
app/models/terraform_state.rb
+7
-0
changelogs/unreleased/207401-encrypt-decrypt-object-storage-to-support-terraform-state-backend.yml
...ypt-object-storage-to-support-terraform-state-backend.yml
+5
-0
db/migrate/20200305200641_create_terraform_states.rb
db/migrate/20200305200641_create_terraform_states.rb
+14
-0
db/structure.sql
db/structure.sql
+29
-0
spec/models/terraform_state_spec.rb
spec/models/terraform_state_spec.rb
+9
-0
No files found.
app/models/terraform_state.rb
0 → 100644
View file @
0bf3c56d
# frozen_string_literal: true
class
TerraformState
<
ApplicationRecord
belongs_to
:project
validates
:project_id
,
presence:
true
end
changelogs/unreleased/207401-encrypt-decrypt-object-storage-to-support-terraform-state-backend.yml
0 → 100644
View file @
0bf3c56d
---
title
:
Create model to store Terraform state files
merge_request
:
26619
author
:
type
:
added
db/migrate/20200305200641_create_terraform_states.rb
0 → 100644
View file @
0bf3c56d
# frozen_string_literal: true
class
CreateTerraformStates
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
change
create_table
:terraform_states
do
|
t
|
t
.
references
:project
,
index:
true
,
foreign_key:
{
on_delete: :cascade
},
null:
false
t
.
timestamps_with_timezone
null:
false
t
.
integer
:file_store
,
limit:
2
t
.
string
:file
,
limit:
255
end
end
end
db/structure.sql
View file @
0bf3c56d
...
...
@@ -5975,6 +5975,24 @@ CREATE SEQUENCE public.term_agreements_id_seq
ALTER
SEQUENCE
public
.
term_agreements_id_seq
OWNED
BY
public
.
term_agreements
.
id
;
CREATE
TABLE
public
.
terraform_states
(
id
bigint
NOT
NULL
,
project_id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
updated_at
timestamp
with
time
zone
NOT
NULL
,
file_store
smallint
,
file
character
varying
(
255
)
);
CREATE
SEQUENCE
public
.
terraform_states_id_seq
START
WITH
1
INCREMENT
BY
1
NO
MINVALUE
NO
MAXVALUE
CACHE
1
;
ALTER
SEQUENCE
public
.
terraform_states_id_seq
OWNED
BY
public
.
terraform_states
.
id
;
CREATE
TABLE
public
.
timelogs
(
id
integer
NOT
NULL
,
time_spent
integer
NOT
NULL
,
...
...
@@ -7327,6 +7345,8 @@ ALTER TABLE ONLY public.tags ALTER COLUMN id SET DEFAULT nextval('public.tags_id
ALTER
TABLE
ONLY
public
.
term_agreements
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.term_agreements_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
public
.
terraform_states
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.terraform_states_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
public
.
timelogs
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.timelogs_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
public
.
todos
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'public.todos_id_seq'
::
regclass
);
...
...
@@ -8228,6 +8248,9 @@ ALTER TABLE ONLY public.tags
ALTER
TABLE
ONLY
public
.
term_agreements
ADD
CONSTRAINT
term_agreements_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
public
.
terraform_states
ADD
CONSTRAINT
terraform_states_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
public
.
timelogs
ADD
CONSTRAINT
timelogs_pkey
PRIMARY
KEY
(
id
);
...
...
@@ -9966,6 +9989,8 @@ CREATE INDEX index_term_agreements_on_term_id ON public.term_agreements USING bt
CREATE
INDEX
index_term_agreements_on_user_id
ON
public
.
term_agreements
USING
btree
(
user_id
);
CREATE
INDEX
index_terraform_states_on_project_id
ON
public
.
terraform_states
USING
btree
(
project_id
);
CREATE
INDEX
index_timelogs_on_issue_id
ON
public
.
timelogs
USING
btree
(
issue_id
);
CREATE
INDEX
index_timelogs_on_merge_request_id
ON
public
.
timelogs
USING
btree
(
merge_request_id
);
...
...
@@ -11271,6 +11296,9 @@ ALTER TABLE ONLY public.pages_domain_acme_orders
ALTER
TABLE
ONLY
public
.
ci_subscriptions_projects
ADD
CONSTRAINT
fk_rails_7871f9a97b
FOREIGN
KEY
(
upstream_project_id
)
REFERENCES
public
.
projects
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
public
.
terraform_states
ADD
CONSTRAINT
fk_rails_78f54ca485
FOREIGN
KEY
(
project_id
)
REFERENCES
public
.
projects
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
public
.
software_license_policies
ADD
CONSTRAINT
fk_rails_7a7a2a92de
FOREIGN
KEY
(
software_license_id
)
REFERENCES
public
.
software_licenses
(
id
)
ON
DELETE
CASCADE
;
...
...
@@ -12742,6 +12770,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200304211738
20200305121159
20200305151736
20200305200641
20200306095654
20200306160521
20200306170211
...
...
spec/models/terraform_state_spec.rb
0 → 100644
View file @
0bf3c56d
# frozen_string_literal: true
require
'spec_helper'
describe
TerraformState
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_id
)
}
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment