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
85e83813
Commit
85e83813
authored
Aug 09, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add WikiAccessLevel migration from `NULL` to `20`
parent
fd9377fa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
...migrate/20180809195358_migrate_null_wiki_access_levels.rb
+23
-0
db/schema.rb
db/schema.rb
+1
-1
spec/migrations/migrate_null_wiki_access_levels_spec.rb
spec/migrations/migrate_null_wiki_access_levels_spec.rb
+29
-0
No files found.
db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
0 → 100644
View file @
85e83813
# frozen_string_literal: true
class
MigrateNullWikiAccessLevels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
class
ProjectFeature
<
ActiveRecord
::
Base
include
EachBatch
self
.
table_name
=
'project_features'
end
def
up
ProjectFeature
.
where
(
wiki_access_level:
nil
).
each_batch
do
|
relation
|
relation
.
update_all
(
wiki_access_level:
20
)
end
end
def
down
# there is no way to rollback this change, there are no downsides in keeping migrated data.
end
end
db/schema.rb
View file @
85e83813
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2018080
8162000
)
do
ActiveRecord
::
Schema
.
define
(
version:
2018080
9195358
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
...
spec/migrations/migrate_null_wiki_access_levels_spec.rb
0 → 100644
View file @
85e83813
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20180809195358_migrate_null_wiki_access_levels.rb'
)
describe
MigrateNullWikiAccessLevels
,
:migration
do
let
(
:namespaces
)
{
table
(
'namespaces'
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:project_features
)
{
table
(
:project_features
)
}
let
(
:migration
)
{
described_class
.
new
}
before
do
namespace
=
namespaces
.
create
(
name:
'foo'
,
path:
'foo'
)
projects
.
create!
(
id:
1
,
name:
'gitlab1'
,
path:
'gitlab1'
,
namespace_id:
namespace
.
id
)
projects
.
create!
(
id:
2
,
name:
'gitlab2'
,
path:
'gitlab2'
,
namespace_id:
namespace
.
id
)
projects
.
create!
(
id:
3
,
name:
'gitlab3'
,
path:
'gitlab3'
,
namespace_id:
namespace
.
id
)
project_features
.
create!
(
id:
1
,
project_id:
1
,
wiki_access_level:
nil
)
project_features
.
create!
(
id:
2
,
project_id:
2
,
wiki_access_level:
10
)
project_features
.
create!
(
id:
3
,
project_id:
3
,
wiki_access_level:
20
)
end
describe
'#up'
do
it
'migrates existing project_features with wiki_access_level NULL to 20'
do
expect
{
migration
.
up
}.
to
change
{
project_features
.
where
(
wiki_access_level:
20
).
count
}.
by
(
1
)
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