Sha256: cd433ba6586eb40269c214331e051d3d5dff630ce0db421e6041adaae29133ae

Contents?: true

Size: 1.26 KB

Versions: 17

Compression:

Stored size: 1.26 KB

Contents

class CreatePermissionsChain < ActiveRecord::Migration[7.0]
  def change
    # Predicates
    create_table :predicates, if_not_exists: true do |t|
      t.string :name
      t.bigint :lock_version

      t.timestamps
    end
    add_index :predicates, :name, unique: true, if_not_exists: true
    
    # Actions
    create_table :actions, if_not_exists: true do |t|
      t.string :name
      t.bigint :lock_version

      t.timestamps
    end
    add_index :actions, :name, unique: true, if_not_exists: true
    
    # Targets
    create_table :targets, if_not_exists: true do |t|
      t.string :name
      t.bigint :lock_version

      t.timestamps
    end
    add_index :targets, :name, unique: true, if_not_exists: true

    create_table :permissions, if_not_exists: true do |t|
      t.references :predicate, null: false, foreign_key: true
      t.references :action, null: false, foreign_key: true
      t.references :target, null: false, foreign_key: true
      t.bigint :lock_version

      t.timestamps
    end
    # Association table
    create_table :permission_roles, if_not_exists: true do |t|
      t.references :role, null: false, foreign_key: true
      t.references :permission, null: false, foreign_key: true
      t.bigint :lock_version

      t.timestamps
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thecore_auth_commons-3.2.2 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.2.1 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.7 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.5 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.4 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.3 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.2 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.1 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.1.0 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.13 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.12 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.11 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.10 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.9 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.8 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.7 db/migrate/20160209153816_create_permissions_chain.rb
thecore_auth_commons-3.0.6 db/migrate/20160209153816_create_permissions_chain.rb