Class: ActsAsEventOwnerMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/acts_as_event_owner_migration/templates/acts_as_event_owner_migration.rb,
lib/generators/acts_as_event_owner/migration/templates/active_record/acts_as_event_owner_migration.rb

Class Method Summary collapse

Class Method Details

.downObject



34
35
36
37
# File 'lib/generators/acts_as_event_owner_migration/templates/acts_as_event_owner_migration.rb', line 34

def self.down
  drop_table :event_specifications
  drop_table :event_occurrences
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/acts_as_event_owner_migration/templates/acts_as_event_owner_migration.rb', line 2

def self.up
  create_table :event_specifications do |t|
    t.integer :owner_id
    t.string :owner_type
    t.string :description
    t.datetime :start_at
    t.datetime :end_at
    t.string :repeat                         # daily, weekly, monthly, yearly
    t.integer :frequency, :default => 1      # every 'n' days, weeks, months, or years
    t.string :on                             # su, mo, tu, we, th, fr, sa, 1-31, jan-dec
    t.string :on_the                         # first, second, third, fourth, last
    t.string :target                         # su, mo, tu, we, th, fr, sa, day, wkday, wkend
    t.datetime :until
    t.timestamps
  end

  add_index :event_specifications, [:owner_id, :owner_type]

  create_table :event_occurrences do |t|
    t.integer :owner_id
    t.string :owner_type
    t.integer :event_specification_id
    t.datetime :start_at
    t.datetime :end_at
    t.string :description
    t.timestamps
  end

  add_index :event_occurrences, [:owner_id, :owner_type]
  add_index :event_occurrences, :event_specification_id
end