Sha256: c8952429c3f96fa15b7360678353f48f79436ba2325121d4498b82de0400daf4

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

class CreateTables < ActiveRecord::Migration
  def self.up

    create_table :users do |t|
      t.string :name, nil: false, index: true
      t.string :api_code
    end

    create_table :urls do |t|
      t.string :url_pattern
      t.string :name
      t.string :http_method
    end

    create_table :user_groups do |t|
      t.string :name, nil: false, index: true
    end

    create_table :users_groups do |t|
      t.integer :user_group_id
      t.integer :user_id
    end

    create_table :users_urls do |t|
      t.integer :users_group_id
      t.integer :url_id
    end

    User.create :name => "guest", :id => 1
    Url.create :url_pattern => "^/login", :name => "Login page", :http_method => "GET", :id => 1
    Url.create :url_pattern => "^/oauth/.*", :name => "AuthCallback page", :http_method => "GET", :id => 2
    UserGroup.create :id => 1, :name => "Guest"
    UsersGroup.create :id => 1, :user_id => 1, :user_group_id => 1
    UsersUrl.create :id => 1, :url_id => 1, :users_group_id => 1
    UsersUrl.create :id => 2, :url_id => 2, :users_group_id => 1
  end

  def self.down
    drop_table :users_urls
    drop_table :users_groups
    drop_table :user_groups
    drop_table :users
    drop_table :urls
  end
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
oauth_service-0.0.1 lib/generators/templates/migrations/create_tables.rb
oauth_service-0.0.1 test/dummy/db/migrate/20160514163909_create_tables.rb