Sha256: db42b714aaa77d3d6d56d074d8e57282284517ac85ed9470348a18a364afdde0

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

class CreateSaucyTables < ActiveRecord::Migration
  def self.up
    create_table :account_memberships do |table|
      table.integer  :account_id
      table.integer  :user_id
      table.boolean  :admin
      table.datetime :created_at
      table.datetime :updated_at
    end

    add_index :account_memberships, [:account_id, :user_id], :unique => true

    create_table :accounts do |table|
      table.belongs_to :plan
      table.string   :name
      table.string   :url
      table.datetime :created_at
      table.datetime :updated_at
    end
    add_index :accounts, :plan_id

    create_table :invitations do |table|
      table.string   :email
      table.integer  :account_id
      table.boolean  :admin
      table.datetime :created_at
      table.datetime :updated_at
    end

    add_index :invitations, [:account_id]

    create_table :project_memberships do |table|
      table.integer  :user_id
      table.integer  :project_id
      table.datetime :created_at
      table.datetime :updated_at
    end

    add_index :project_memberships, [:user_id, :project_id]

    create_table :projects do |table|
      table.string   :name
      table.integer  :account_id
      table.datetime :created_at
      table.datetime :updated_at
    end

    alter_table :users do |table|
      table.string :name, :default => ""
    end

    create_table :plans do |t|
      t.string :name
      t.integer :price

      t.timestamps
    end

    add_index :plans, :name
  end

  def self.down
    remove_column :users, :name
    drop_table :plans
    drop_table :projects
    drop_table :project_memberships
    drop_table :invitations
    drop_table :accounts
    drop_table :account_memberships
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
saucy-0.1.3 lib/generators/saucy/install/templates/create_saucy_tables.rb
saucy-0.1.2 lib/generators/saucy/install/templates/create_saucy_tables.rb
saucy-0.1.1 lib/generators/saucy/install/templates/create_saucy_tables.rb