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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
4c1e6fd0
Commit
4c1e6fd0
authored
Mar 14, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify migration and add NOT NULL to project_id.
parent
539bdf73
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
20 deletions
+4
-20
db/migrate/20180305095250_create_internal_ids_table.rb
db/migrate/20180305095250_create_internal_ids_table.rb
+2
-18
db/schema.rb
db/schema.rb
+2
-2
No files found.
db/migrate/20180305095250_create_internal_ids_table.rb
View file @
4c1e6fd0
...
@@ -3,33 +3,17 @@ class CreateInternalIdsTable < ActiveRecord::Migration
...
@@ -3,33 +3,17 @@ class CreateInternalIdsTable < ActiveRecord::Migration
DOWNTIME
=
false
DOWNTIME
=
false
disable_ddl_transaction!
def
up
def
up
create_table
:internal_ids
,
id: :bigserial
do
|
t
|
create_table
:internal_ids
,
id: :bigserial
do
|
t
|
t
.
references
:project
t
.
references
:project
,
null:
false
,
foreign_key:
{
on_delete: :cascade
}
t
.
integer
:usage
,
null:
false
t
.
integer
:usage
,
null:
false
t
.
integer
:last_value
,
null:
false
t
.
integer
:last_value
,
null:
false
end
unless
index_exists?
(
:internal_ids
,
[
:usage
,
:project_id
])
add_index
:internal_ids
,
[
:usage
,
:project_id
],
unique:
true
end
unless
foreign_key_exists?
(
:internal_ids
,
:project_id
)
t
.
index
[
:usage
,
:project_id
],
unique:
true
add_concurrent_foreign_key
:internal_ids
,
:projects
,
column: :project_id
,
on_delete: :cascade
end
end
end
end
def
down
def
down
drop_table
:internal_ids
drop_table
:internal_ids
end
end
private
def
foreign_key_exists?
(
table
,
column
)
foreign_keys
(
table
).
any?
do
|
key
|
key
.
options
[
:column
]
==
column
.
to_s
end
end
end
end
db/schema.rb
View file @
4c1e6fd0
...
@@ -867,7 +867,7 @@ ActiveRecord::Schema.define(version: 20180309160427) do
...
@@ -867,7 +867,7 @@ ActiveRecord::Schema.define(version: 20180309160427) do
add_index
"identities"
,
[
"user_id"
],
name:
"index_identities_on_user_id"
,
using: :btree
add_index
"identities"
,
[
"user_id"
],
name:
"index_identities_on_user_id"
,
using: :btree
create_table
"internal_ids"
,
id: :bigserial
,
force: :cascade
do
|
t
|
create_table
"internal_ids"
,
id: :bigserial
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
,
null:
false
t
.
integer
"usage"
,
null:
false
t
.
integer
"usage"
,
null:
false
t
.
integer
"last_value"
,
null:
false
t
.
integer
"last_value"
,
null:
false
end
end
...
@@ -2066,7 +2066,7 @@ ActiveRecord::Schema.define(version: 20180309160427) do
...
@@ -2066,7 +2066,7 @@ ActiveRecord::Schema.define(version: 20180309160427) do
add_foreign_key
"gpg_signatures"
,
"gpg_keys"
,
on_delete: :nullify
add_foreign_key
"gpg_signatures"
,
"gpg_keys"
,
on_delete: :nullify
add_foreign_key
"gpg_signatures"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"gpg_signatures"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"group_custom_attributes"
,
"namespaces"
,
column:
"group_id"
,
on_delete: :cascade
add_foreign_key
"group_custom_attributes"
,
"namespaces"
,
column:
"group_id"
,
on_delete: :cascade
add_foreign_key
"internal_ids"
,
"projects"
,
name:
"fk_f7d46b66c6"
,
on_delete: :cascade
add_foreign_key
"internal_ids"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"issues"
,
name:
"fk_b7d881734a"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"issues"
,
name:
"fk_b7d881734a"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"users"
,
name:
"fk_5e0c8d9154"
,
on_delete: :cascade
add_foreign_key
"issue_assignees"
,
"users"
,
name:
"fk_5e0c8d9154"
,
on_delete: :cascade
add_foreign_key
"issue_metrics"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"issue_metrics"
,
"issues"
,
on_delete: :cascade
...
...
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