summaryrefslogtreecommitdiff
path: root/db/migrate/20230420132910_create_ci_ai_conversation.rb
blob: 7676a2b0ae1ef7320a05f74faca4154fab82c83e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

class CreateCiAiConversation < Gitlab::Database::Migration[2.1]
  def up
    create_table :ci_editor_ai_conversation_messages do |t|
      t.bigint :user_id,
        null: false
      t.bigint :project_id,
        null: false
      t.timestamps_with_timezone null: false
      t.text :role, limit: 100,
        null: false
      t.text :content, limit: 16384,
        null: true
      t.text :async_errors, array: true, null: false, default: []

      t.index [:user_id, :project_id, :created_at],
        name: :index_ci_editor_ai_messages_on_user_project_and_created_at

      t.index :project_id,
        name: :index_ci_editor_ai_messages_project_id

      t.index :created_at,
        name: :index_ci_editor_ai_messages_created_at
    end
  end

  def down
    drop_table :ci_editor_ai_conversation_messages
  end
end