Sha256: 1d8e72ca987470ce815c05ace6d84d7d03faea9512447e2d118e89d20e2565a4

Contents?: true

Size: 973 Bytes

Versions: 10

Compression:

Stored size: 973 Bytes

Contents

class CreateTeams < ActiveRecord::Migration
  def up
    create_table :teams do |t|
      t.string :name
      t.jsonb :props, default: {}
    end

    # Each project belongs to only one team
    add_column :projects, :team_id, :integer

    # Each user can belong to many teams
    # and can have 0 or several roles on each team
    create_table :teams_users do |t|
      t.references :team, :user
      t.string :roles, array: true

      t.timestamps
      t.index [:team_id, :user_id], unique: true
    end
    # rename_table :roles, :project_roles

    # create_table :roles do |t|
    #   t.references :user
    #   t.references :team
    #   t.string :name, false
    #
    #   t.timestamps
    #   t.index [:user_id, :team_id]
    #   t.index [:user_id, :team_id, :name]
    # end
  end

  def down
    drop_table :teams
    # drop_table :roles
    drop_table :teams_users

    remove_column :projects, :team_id

    # rename_table :project_roles, :roles
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
houston-core-0.9.2 db/migrate/20160813001242_create_teams.rb
houston-core-0.9.1 db/migrate/20160813001242_create_teams.rb
houston-core-0.9.0 db/migrate/20160813001242_create_teams.rb
houston-core-0.9.0.rc1 db/migrate/20160813001242_create_teams.rb
houston-core-0.8.4 db/migrate/20160813001242_create_teams.rb
houston-core-0.8.3 db/migrate/20160813001242_create_teams.rb
houston-core-0.8.2 db/migrate/20160813001242_create_teams.rb
houston-core-0.8.1 db/migrate/20160813001242_create_teams.rb
houston-core-0.8.0 db/migrate/20160813001242_create_teams.rb
houston-core-0.8.0.pre2 db/migrate/20160813001242_create_teams.rb