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
93e72d5d
Commit
93e72d5d
authored
Jan 16, 2020
by
celdem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update timestamp values for software license policies
parent
7fdfd9c1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
3 deletions
+70
-3
db/migrate/20200116175538_update_timestamp_softwarelicensespolicy.rb
...20200116175538_update_timestamp_softwarelicensespolicy.rb
+28
-0
db/migrate/20200121132641_update_timestamp_softwarelicensespolicy_not_null.rb
...32641_update_timestamp_softwarelicensespolicy_not_null.rb
+15
-0
db/schema.rb
db/schema.rb
+3
-3
spec/migrations/update_timestamp_softwarelicensespolicy_spec.rb
...igrations/update_timestamp_softwarelicensespolicy_spec.rb
+24
-0
No files found.
db/migrate/20200116175538_update_timestamp_softwarelicensespolicy.rb
0 → 100644
View file @
93e72d5d
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
UpdateTimestampSoftwarelicensespolicy
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
time
=
Time
.
zone
.
now
update_column_in_batches
(
:software_license_policies
,
:created_at
,
time
)
do
|
table
,
query
|
query
.
where
(
table
[
:created_at
].
eq
(
nil
))
end
update_column_in_batches
(
:software_license_policies
,
:updated_at
,
time
)
do
|
table
,
query
|
query
.
where
(
table
[
:updated_at
].
eq
(
nil
))
end
end
def
down
# no-op
end
end
db/migrate/20200121132641_update_timestamp_softwarelicensespolicy_not_null.rb
0 → 100644
View file @
93e72d5d
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
UpdateTimestampSoftwarelicensespolicyNotNull
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
change_column_null
(
:software_license_policies
,
:created_at
,
false
)
change_column_null
(
:software_license_policies
,
:updated_at
,
false
)
end
end
db/schema.rb
View file @
93e72d5d
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2020_01_
17_112554
)
do
ActiveRecord
::
Schema
.
define
(
version:
2020_01_
21_132641
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"pg_trgm"
...
...
@@ -3857,8 +3857,8 @@ ActiveRecord::Schema.define(version: 2020_01_17_112554) do
t
.
integer
"project_id"
,
null:
false
t
.
integer
"software_license_id"
,
null:
false
t
.
integer
"classification"
,
default:
0
,
null:
false
t
.
datetime_with_timezone
"created_at"
t
.
datetime_with_timezone
"updated_at"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
index
[
"project_id"
,
"software_license_id"
],
name:
"index_software_license_policies_unique_per_project"
,
unique:
true
t
.
index
[
"software_license_id"
],
name:
"index_software_license_policies_on_software_license_id"
end
...
...
spec/migrations/update_timestamp_softwarelicensespolicy_spec.rb
0 → 100644
View file @
93e72d5d
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20200116175538_update_timestamp_softwarelicensespolicy.rb'
)
describe
UpdateTimestampSoftwarelicensespolicy
,
:migration
do
let
(
:software_licenses_policy
)
{
table
(
:software_license_policies
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:licenses
)
{
table
(
:software_licenses
)
}
before
do
projects
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org/gitlab-ce'
,
namespace_id:
1
)
licenses
.
create!
(
name:
'MIT'
)
software_licenses_policy
.
create!
(
project_id:
projects
.
first
.
id
,
software_license_id:
licenses
.
first
.
id
,
created_at:
nil
,
updated_at:
nil
)
end
it
'creates timestamps'
do
migrate!
expect
(
software_licenses_policy
.
first
.
created_at
).
to
be_present
expect
(
software_licenses_policy
.
first
.
updated_at
).
to
be_present
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