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
5f7bd5b1
Commit
5f7bd5b1
authored
Nov 27, 2019
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Clusters::ServerlessDomain model
To store the association between a serverless domain and a cluster
parent
fcea0e21
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
0 deletions
+77
-0
app/models/serverless/domain_cluster.rb
app/models/serverless/domain_cluster.rb
+14
-0
db/migrate/20191127030005_create_serverless_domain_cluster.rb
...igrate/20191127030005_create_serverless_domain_cluster.rb
+17
-0
db/schema.rb
db/schema.rb
+14
-0
spec/factories/serverless/domain_cluster.rb
spec/factories/serverless/domain_cluster.rb
+10
-0
spec/models/serverless/domain_cluster_spec.rb
spec/models/serverless/domain_cluster_spec.rb
+22
-0
No files found.
app/models/serverless/domain_cluster.rb
0 → 100644
View file @
5f7bd5b1
# frozen_string_literal: true
module
Serverless
class
DomainCluster
<
ApplicationRecord
self
.
table_name
=
'serverless_domain_cluster'
belongs_to
:pages_domain
belongs_to
:knative
,
class_name:
'Clusters::Applications::Knative'
,
foreign_key:
'clusters_applications_knative_id'
belongs_to
:creator
,
class_name:
'User'
,
optional:
true
validates
:pages_domain
,
:knative
,
:uuid
,
presence:
true
validates
:uuid
,
uniqueness:
true
,
length:
{
is:
14
}
end
end
db/migrate/20191127030005_create_serverless_domain_cluster.rb
0 → 100644
View file @
5f7bd5b1
# frozen_string_literal: true
class
CreateServerlessDomainCluster
<
ActiveRecord
::
Migration
[
5.2
]
DOWNTIME
=
false
def
change
create_table
:serverless_domain_cluster
,
id:
false
,
primary_key: :uuid
do
|
t
|
t
.
references
:pages_domain
,
null:
false
,
foreign_key:
{
on_delete: :cascade
}
t
.
references
:clusters_applications_knative
,
null:
false
,
foreign_key:
{
to_table: :clusters_applications_knative
,
on_delete: :cascade
},
index:
{
name: :idx_serverless_domain_cluster_on_clusters_applications_knative
,
unique:
true
}
t
.
references
:creator
,
name: :created_by
,
foreign_key:
{
to_table: :users
,
on_delete: :nullify
}
t
.
timestamps_with_timezone
null:
false
t
.
string
:uuid
,
null:
false
,
limit:
14
,
primary_key:
true
end
end
end
db/schema.rb
View file @
5f7bd5b1
...
@@ -3632,6 +3632,17 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) do
...
@@ -3632,6 +3632,17 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) do
t
.
index
[
"issue_id"
],
name:
"index_sentry_issues_on_issue_id"
,
unique:
true
t
.
index
[
"issue_id"
],
name:
"index_sentry_issues_on_issue_id"
,
unique:
true
end
end
create_table
"serverless_domain_cluster"
,
primary_key:
"uuid"
,
id: :string
,
limit:
14
,
force: :cascade
do
|
t
|
t
.
bigint
"pages_domain_id"
,
null:
false
t
.
bigint
"clusters_applications_knative_id"
,
null:
false
t
.
bigint
"creator_id"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
index
[
"clusters_applications_knative_id"
],
name:
"idx_serverless_domain_cluster_on_clusters_applications_knative"
,
unique:
true
t
.
index
[
"creator_id"
],
name:
"index_serverless_domain_cluster_on_creator_id"
t
.
index
[
"pages_domain_id"
],
name:
"index_serverless_domain_cluster_on_pages_domain_id"
end
create_table
"service_desk_settings"
,
primary_key:
"project_id"
,
id: :bigint
,
default:
nil
,
force: :cascade
do
|
t
|
create_table
"service_desk_settings"
,
primary_key:
"project_id"
,
id: :bigint
,
default:
nil
,
force: :cascade
do
|
t
|
t
.
string
"issue_template_key"
,
limit:
255
t
.
string
"issue_template_key"
,
limit:
255
end
end
...
@@ -4688,6 +4699,9 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) do
...
@@ -4688,6 +4699,9 @@ ActiveRecord::Schema.define(version: 2019_12_08_071112) do
add_foreign_key
"self_managed_prometheus_alert_events"
,
"environments"
,
on_delete: :cascade
add_foreign_key
"self_managed_prometheus_alert_events"
,
"environments"
,
on_delete: :cascade
add_foreign_key
"self_managed_prometheus_alert_events"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"self_managed_prometheus_alert_events"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"sentry_issues"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"sentry_issues"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"serverless_domain_cluster"
,
"clusters_applications_knative"
,
on_delete: :cascade
add_foreign_key
"serverless_domain_cluster"
,
"pages_domains"
,
on_delete: :cascade
add_foreign_key
"serverless_domain_cluster"
,
"users"
,
column:
"creator_id"
,
on_delete: :nullify
add_foreign_key
"service_desk_settings"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"service_desk_settings"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"services"
,
"projects"
,
name:
"fk_71cce407f9"
,
on_delete: :cascade
add_foreign_key
"services"
,
"projects"
,
name:
"fk_71cce407f9"
,
on_delete: :cascade
add_foreign_key
"slack_integrations"
,
"services"
,
on_delete: :cascade
add_foreign_key
"slack_integrations"
,
"services"
,
on_delete: :cascade
...
...
spec/factories/serverless/domain_cluster.rb
0 → 100644
View file @
5f7bd5b1
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:serverless_domain_cluster
,
class:
Serverless
::
DomainCluster
do
pages_domain
{
create
(
:pages_domain
)
}
knative
{
create
(
:clusters_applications_knative
)
}
creator
{
create
(
:user
)
}
uuid
{
SecureRandom
.
hex
(
7
)
}
end
end
spec/models/serverless/domain_cluster_spec.rb
0 → 100644
View file @
5f7bd5b1
# frozen_string_literal: true
require
'spec_helper'
describe
Serverless
::
DomainCluster
do
subject
{
create
(
:serverless_domain_cluster
)
}
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:pages_domain
)
}
it
{
is_expected
.
to
validate_presence_of
(
:knative
)
}
it
{
is_expected
.
to
validate_presence_of
(
:uuid
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:uuid
)
}
it
{
is_expected
.
to
validate_length_of
(
:uuid
).
is_equal_to
(
14
)
}
end
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:pages_domain
)
}
it
{
is_expected
.
to
belong_to
(
:knative
)
}
it
{
is_expected
.
to
belong_to
(
:creator
).
optional
}
end
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