summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-04-06 09:30:21 -0500
committerMayra Cabrera <mcabrera@gitlab.com>2018-04-06 21:20:17 -0500
commit29913816309c6f6387b20c8702bcc8e90ef3a984 (patch)
tree6dbd8f3367d423a72c0d058d5e1a29296873c1f6 /db
parentca35c65b026e57307a13f25ebc11f11c978ed697 (diff)
downloadgitlab-ce-29913816309c6f6387b20c8702bcc8e90ef3a984.tar.gz
Addresses database comments
- Adds a default on expires_at datetime - Modifies deploy tokens views to handle default expires at value - Use datetime_with_timezone where possible - Remove unused scopes
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180319190020_create_deploy_tokens.rb6
-rw-r--r--db/migrate/20180405142733_create_project_deploy_tokens.rb4
-rw-r--r--db/schema.rb9
3 files changed, 9 insertions, 10 deletions
diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb
index 6a681ba79d6..b8f77f5ae17 100644
--- a/db/migrate/20180319190020_create_deploy_tokens.rb
+++ b/db/migrate/20180319190020_create_deploy_tokens.rb
@@ -7,11 +7,13 @@ class CreateDeployTokens < ActiveRecord::Migration
t.boolean :read_repository, null: false, default: false
t.boolean :read_registry, null: false, default: false
- t.datetime :expires_at
- t.timestamps null: false
+ t.datetime_with_timezone :expires_at, null: false, default: '3000-01-01'
+ t.datetime_with_timezone :created_at, null: false
t.string :name, null: false
t.string :token, index: { unique: true }, null: false
+
+ t.index [:token, :expires_at], where: "(revoked IS FALSE)"
end
end
end
diff --git a/db/migrate/20180405142733_create_project_deploy_tokens.rb b/db/migrate/20180405142733_create_project_deploy_tokens.rb
index adc4c526c9b..9d8f89243a8 100644
--- a/db/migrate/20180405142733_create_project_deploy_tokens.rb
+++ b/db/migrate/20180405142733_create_project_deploy_tokens.rb
@@ -1,13 +1,11 @@
class CreateProjectDeployTokens < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
DOWNTIME = false
def change
create_table :project_deploy_tokens do |t|
t.integer :project_id, null: false
t.integer :deploy_token_id, null: false
- t.timestamps null: false
+ t.datetime_with_timezone :created_at, null: false
t.foreign_key :deploy_tokens, column: :deploy_token_id, on_delete: :cascade
t.foreign_key :projects, column: :project_id, on_delete: :cascade
diff --git a/db/schema.rb b/db/schema.rb
index 0c8938b015d..b0174a4ed46 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -687,13 +687,13 @@ ActiveRecord::Schema.define(version: 20180405142733) do
t.boolean "revoked", default: false
t.boolean "read_repository", default: false, null: false
t.boolean "read_registry", default: false, null: false
- t.datetime "expires_at"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime_with_timezone "expires_at", default: '3000-01-01 00:00:00', null: false
+ t.datetime_with_timezone "created_at", null: false
t.string "name", null: false
t.string "token", null: false
end
+ add_index "deploy_tokens", ["token", "expires_at"], name: "index_deploy_tokens_on_token_and_expires_at", where: "(revoked IS FALSE)", using: :btree
add_index "deploy_tokens", ["token"], name: "index_deploy_tokens_on_token", unique: true, using: :btree
create_table "deployments", force: :cascade do |t|
@@ -1446,8 +1446,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do
create_table "project_deploy_tokens", force: :cascade do |t|
t.integer "project_id", null: false
t.integer "deploy_token_id", null: false
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime_with_timezone "created_at", null: false
end
add_index "project_deploy_tokens", ["project_id", "deploy_token_id"], name: "index_project_deploy_tokens_on_project_id_and_deploy_token_id", unique: true, using: :btree