2023-10-19 16:37:34 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-19 09:10:31 -07:00
|
|
|
class CreateGroups < ActiveRecord::Migration[4.2]
|
2015-01-08 04:16:13 -08:00
|
|
|
def change
|
|
|
|
create_table :groups do |t|
|
|
|
|
t.integer :user_id, null: false
|
|
|
|
t.string :name
|
|
|
|
t.string :display_name
|
2015-01-10 14:29:04 -08:00
|
|
|
t.boolean :private, default: true
|
2015-01-08 04:16:13 -08:00
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
add_index :groups, :user_id
|
|
|
|
add_index :groups, :name
|
2023-10-19 16:37:34 -07:00
|
|
|
add_index :groups, %i[user_id name], unique: true
|
2015-01-10 14:29:04 -08:00
|
|
|
|
|
|
|
create_table :group_members do |t|
|
|
|
|
t.integer :group_id, null: false
|
|
|
|
t.integer :user_id, null: false
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
add_index :group_members, :group_id
|
|
|
|
add_index :group_members, :user_id
|
2023-10-19 16:37:34 -07:00
|
|
|
add_index :group_members, %i[group_id user_id], unique: true
|
2015-01-08 04:16:13 -08:00
|
|
|
end
|
|
|
|
end
|