Skip to content

Commit 5500a95

Browse files
committed
adding migration
1 parent ced09a2 commit 5500a95

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class CreateTeam < ActiveRecord::Migration[7.1]
2+
def self.up
3+
create_table :teams, primary_key: :id do |t|
4+
t.integer :id
5+
t.string :name
6+
end
7+
8+
add_index :teams, :name, unique: true
9+
10+
create_table :team_user do |t|
11+
t.integer :team_id, null: false
12+
t.integer :user_id, null: false
13+
end
14+
15+
add_index :team_user, [:team_id, :user_id], unique: true
16+
add_foreign_key :team_user, :teams, column: :team_id
17+
add_foreign_key :team_user, :users, column: :user_id
18+
end
19+
20+
def self.down
21+
drop_table :team_user
22+
drop_table :teams
23+
end
24+
end

0 commit comments

Comments
 (0)