Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20230905234948_create_projects_visits_tables.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b67615b6a225f86e9f05cda563e76782f76fb6da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class CreateProjectsVisitsTables < Gitlab::Database::Migration[2.1]
  def up
    create_table :projects_visits, primary_key: [:id, :visited_at],
      options: 'PARTITION BY RANGE (visited_at)' do |t|
      t.bigserial :id, null: false
      t.bigint :entity_id, null: false, index: true
      t.bigint :user_id, null: false
      t.datetime_with_timezone :visited_at, null: false
    end

    add_index(:projects_visits, [:user_id, :entity_id, :visited_at])
  end

  def down
    drop_table :projects_visits
  end
end