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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
3b77a078
Commit
3b77a078
authored
Apr 10, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix more SQL migrations to use raw commands
gitlab-org/gitlab-development-kit#109
parent
0631a1e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
12 deletions
+18
-12
db/migrate/20130315124931_user_color_scheme.rb
db/migrate/20130315124931_user_color_scheme.rb
+3
-1
db/migrate/20131112220935_add_visibility_level_to_projects.rb
...igrate/20131112220935_add_visibility_level_to_projects.rb
+4
-2
db/migrate/20140313092127_migrate_already_imported_projects.rb
...grate/20140313092127_migrate_already_imported_projects.rb
+5
-3
db/migrate/20141007100818_add_visibility_level_to_snippet.rb
db/migrate/20141007100818_add_visibility_level_to_snippet.rb
+6
-6
No files found.
db/migrate/20130315124931_user_color_scheme.rb
View file @
3b77a078
class
UserColorScheme
<
ActiveRecord
::
Migration
class
UserColorScheme
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
up
def
up
add_column
:users
,
:color_scheme_id
,
:integer
,
null:
false
,
default:
1
add_column
:users
,
:color_scheme_id
,
:integer
,
null:
false
,
default:
1
User
.
where
(
dark_scheme:
true
).
update_all
(
color_scheme_id:
2
)
execute
(
"UPDATE users SET color_scheme_id = 2 WHERE dark_scheme =
#{
true_value
}
"
)
remove_column
:users
,
:dark_scheme
remove_column
:users
,
:dark_scheme
end
end
...
...
db/migrate/20131112220935_add_visibility_level_to_projects.rb
View file @
3b77a078
class
AddVisibilityLevelToProjects
<
ActiveRecord
::
Migration
class
AddVisibilityLevelToProjects
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
self
.
up
def
self
.
up
add_column
:projects
,
:visibility_level
,
:integer
,
:default
=>
0
,
:null
=>
false
add_column
:projects
,
:visibility_level
,
:integer
,
:default
=>
0
,
:null
=>
false
Project
.
where
(
public:
true
).
update_all
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
execute
(
"UPDATE projects SET visibility_level =
#{
Gitlab
::
VisibilityLevel
::
PUBLIC
}
WHERE public =
#{
true_value
}
"
)
remove_column
:projects
,
:public
remove_column
:projects
,
:public
end
end
def
self
.
down
def
self
.
down
add_column
:projects
,
:public
,
:boolean
,
:default
=>
false
,
:null
=>
false
add_column
:projects
,
:public
,
:boolean
,
:default
=>
false
,
:null
=>
false
Project
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
).
update_all
(
public:
true
)
execute
(
"UPDATE projects SET public =
#{
true_value
}
WHERE visibility_level =
#{
Gitlab
::
VisibilityLevel
::
PUBLIC
}
"
)
remove_column
:projects
,
:visibility_level
remove_column
:projects
,
:visibility_level
end
end
end
end
db/migrate/20140313092127_migrate_already_imported_projects.rb
View file @
3b77a078
class
MigrateAlreadyImportedProjects
<
ActiveRecord
::
Migration
class
MigrateAlreadyImportedProjects
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
def
up
def
up
Project
.
where
(
imported:
true
).
update_all
(
import_status:
"finished
"
)
execute
(
"UPDATE projects SET import_status = 'finished' WHERE imported =
#{
true_value
}
"
)
Project
.
where
(
imported:
false
).
update_all
(
import_status:
"none
"
)
execute
(
"UPDATE projects SET import_status = 'none' WHERE imported =
#{
false_value
}
"
)
remove_column
:projects
,
:imported
remove_column
:projects
,
:imported
end
end
def
down
def
down
add_column
:projects
,
:imported
,
:boolean
,
default:
false
add_column
:projects
,
:imported
,
:boolean
,
default:
false
Project
.
where
(
import_status:
'finished'
).
update_all
(
imported:
true
)
execute
(
"UPDATE projects SET imported =
#{
true_value
}
WHERE import_status = 'finished'"
)
end
end
end
end
db/migrate/20141007100818_add_visibility_level_to_snippet.rb
View file @
3b77a078
...
@@ -2,8 +2,8 @@ class AddVisibilityLevelToSnippet < ActiveRecord::Migration
...
@@ -2,8 +2,8 @@ class AddVisibilityLevelToSnippet < ActiveRecord::Migration
def
up
def
up
add_column
:snippets
,
:visibility_level
,
:integer
,
:default
=>
0
,
:null
=>
false
add_column
:snippets
,
:visibility_level
,
:integer
,
:default
=>
0
,
:null
=>
false
Snippet
.
where
(
private:
true
).
update_all
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
execute
(
"UPDATE snippets SET visibility_level =
#{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
WHERE private = true"
)
Snippet
.
where
(
private:
false
).
update_all
(
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
execute
(
"UPDATE snippets SET visibility_level =
#{
Gitlab
::
VisibilityLevel
::
INTERNAL
}
WHERE private = false"
)
add_index
:snippets
,
:visibility_level
add_index
:snippets
,
:visibility_level
...
@@ -12,10 +12,10 @@ class AddVisibilityLevelToSnippet < ActiveRecord::Migration
...
@@ -12,10 +12,10 @@ class AddVisibilityLevelToSnippet < ActiveRecord::Migration
def
down
def
down
add_column
:snippets
,
:private
,
:boolean
,
:default
=>
false
,
:null
=>
false
add_column
:snippets
,
:private
,
:boolean
,
:default
=>
false
,
:null
=>
false
Snippet
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
).
update_all
(
private:
false
)
execute
(
"UPDATE snippets SET private = false WHERE visibility_level =
#{
Gitlab
::
VisibilityLevel
::
INTERNAL
}
"
)
Snippet
.
where
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
).
update_all
(
private:
true
)
execute
(
"UPDATE snippets SET private = true WHERE visibility_level =
#{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
"
)
remove_column
:snippets
,
:visibility_level
remove_column
:snippets
,
:visibility_level
end
end
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