| 1 | class CreateIssues < ActiveRecord::Migration[8.1] |
| 2 | def change |
| 3 | create_table :issues do |t| |
| 4 | t.references :repository, null: false, foreign_key: true |
| 5 | t.references :user, null: false, foreign_key: true # author |
| 6 | t.integer :number, null: false |
| 7 | t.string :title, null: false |
| 8 | t.text :body |
| 9 | t.string :state, null: false, default: "open" |
| 10 | t.datetime :closed_at |
| 11 | |
| 12 | t.timestamps |
| 13 | end |
| 14 | |
| 15 | add_index :issues, [ :repository_id, :number ], unique: true |
| 16 | end |
| 17 | end |