summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170608152748_create_push_events_tables.rb35
-rw-r--r--db/post_migrate/20170627101016_schedule_event_migrations.rb27
-rw-r--r--db/schema.rb20
3 files changed, 81 insertions, 1 deletions
diff --git a/db/migrate/20170608152748_create_push_events_tables.rb b/db/migrate/20170608152748_create_push_events_tables.rb
new file mode 100644
index 00000000000..9439a90b84c
--- /dev/null
+++ b/db/migrate/20170608152748_create_push_events_tables.rb
@@ -0,0 +1,35 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class CreatePushEventsTables < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ def change
+ create_table :push_events, id: false do |t|
+ t.datetime_with_timezone :created_at, null: false
+
+ t.references :user,
+ null: false, foreign_key: { on_delete: :cascade }
+
+ t.references :project,
+ null: false, foreign_key: { on_delete: :cascade }
+
+ t.bigint :commit_count, null: false
+
+ t.integer :action, null: false, limit: 2
+ t.integer :ref_type, null: false, limit: 2
+
+ t.binary :first_commit
+ t.binary :last_commit
+
+ t.text :ref
+ t.string :commit_message, limit: 70
+
+ t.index [:project_id, :created_at]
+ t.index [:user_id, :created_at]
+ end
+ end
+end
diff --git a/db/post_migrate/20170627101016_schedule_event_migrations.rb b/db/post_migrate/20170627101016_schedule_event_migrations.rb
new file mode 100644
index 00000000000..b63088e5e62
--- /dev/null
+++ b/db/post_migrate/20170627101016_schedule_event_migrations.rb
@@ -0,0 +1,27 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class ScheduleEventMigrations < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ class Event < ActiveRecord::Base
+ self.table_name = 'events'
+ end
+
+ def up
+ Event.where(action: 5).in_batches do |relation|
+ jobs = relation.pluck(:id).map do |id|
+ ['MigrateEventsToPushEvents', [id]]
+ end
+
+ BackgroundMigrationWorker.perform_bulk(*jobs)
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 028556bdccf..dd048f7cc17 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170621102400) do
+ActiveRecord::Schema.define(version: 20170627101016) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -1150,6 +1150,22 @@ ActiveRecord::Schema.define(version: 20170621102400) do
add_index "protected_tags", ["project_id"], name: "index_protected_tags_on_project_id", using: :btree
+ create_table "push_events", id: false, force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.integer "user_id", null: false
+ t.integer "project_id", null: false
+ t.integer "commit_count", limit: 8, null: false
+ t.integer "action", limit: 2, null: false
+ t.integer "ref_type", limit: 2, null: false
+ t.binary "first_commit"
+ t.binary "last_commit"
+ t.text "ref"
+ t.string "commit_message", limit: 70
+ end
+
+ add_index "push_events", ["project_id", "created_at"], name: "index_push_events_on_project_id_and_created_at", using: :btree
+ add_index "push_events", ["user_id", "created_at"], name: "index_push_events_on_user_id_and_created_at", using: :btree
+
create_table "redirect_routes", force: :cascade do |t|
t.integer "source_id", null: false
t.string "source_type", null: false
@@ -1562,6 +1578,8 @@ ActiveRecord::Schema.define(version: 20170621102400) do
add_foreign_key "protected_tag_create_access_levels", "namespaces", column: "group_id"
add_foreign_key "protected_tag_create_access_levels", "protected_tags"
add_foreign_key "protected_tag_create_access_levels", "users"
+ add_foreign_key "push_events", "projects", on_delete: :cascade
+ add_foreign_key "push_events", "users", on_delete: :cascade
add_foreign_key "subscriptions", "projects", on_delete: :cascade
add_foreign_key "system_note_metadata", "notes", name: "fk_d83a918cb1", on_delete: :cascade
add_foreign_key "timelogs", "issues", name: "fk_timelogs_issues_issue_id", on_delete: :cascade