Class: ModSpox::Migrations::AuthRestructureModeFix

Inherits:
Sequel::Migration
  • Object
show all
Defined in:
lib/mod_spox/migrations/003_auth_restructure.rb

Instance Method Summary collapse

Instance Method Details

#downObject



24
25
26
27
28
# File 'lib/mod_spox/migrations/003_auth_restructure.rb', line 24

def down
    Database.db.drop_table(:auth_masks_group)
    Database.db.drop_table(:auth_masks_nicks)
    Database.db.drop_table(:auth_masks)
end

#upObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mod_spox/migrations/003_auth_restructure.rb', line 5

def up
    Database.db.drop_column :auths, :mask
    Database.db.create_table(:auth_masks) do
        primary_key :id, :null => false
        varchar :mask, :null => false, :unique => true
    end
    Database.db.create_table(:auth_masks_groups) do
        foreign_key :auth_mask_id, :table => :auth_masks, :null => false
        foreign_key :group_id, :null => false
        primary_key [:auth_mask_id, :group_id]
    end
    Database.db.create_table(:auth_masks_nicks) do
        foreign_key :auth_mask_id, :table => :auth_masks, :null => false
        foreign_key :nick_id, :null => false
        primary_key [:nick_id, :auth_mask_id]
    end
    Database.db.drop_table :nick_groups
end