59 lines
1.6 KiB
Ruby
59 lines
1.6 KiB
Ruby
class AddNewsletterEngine < ActiveRecord::Migration
|
|
def self.up
|
|
|
|
create_table :newsletter_allowed_values do |t|
|
|
t.string :type
|
|
t.string :code
|
|
t.string :value
|
|
t.integer :position
|
|
|
|
t.timestamps
|
|
t.datetime :deleted_at
|
|
end
|
|
|
|
create_table :contacts do |t|
|
|
t.string :email
|
|
t.string :first_name
|
|
t.string :last_name
|
|
t.string :country
|
|
|
|
t.integer :active_subscriptions, :default => 0
|
|
|
|
t.timestamps
|
|
t.datetime :deleted_at
|
|
end
|
|
|
|
create_table :subscription_lists do |t|
|
|
t.integer :subscription_list_type_id, :references => :newsletter_allowed_values
|
|
t.integer :product_id
|
|
t.string :name
|
|
|
|
t.timestamps
|
|
t.datetime :deleted_at
|
|
end
|
|
|
|
create_table :subscriptions do |t|
|
|
t.integer :subscription_list_id
|
|
t.integer :contact_id
|
|
t.datetime :started_at
|
|
t.datetime :ended_at
|
|
t.boolean :active, :default => true
|
|
|
|
t.timestamps
|
|
t.datetime :deleted_at
|
|
end
|
|
|
|
create_table :subscription_list_types_subscription_locations, :id => false, :primary_key => [:subscription_list_type_id, :subscription_location_id] do |t|
|
|
t.integer :subscription_list_type_id, :references => :newsletter_allowed_values
|
|
t.integer :subscription_location_id, :references => :newsletter_allowed_values
|
|
end
|
|
|
|
end
|
|
|
|
def self.down
|
|
drop_table :subscription_list_types_subscription_locations
|
|
drop_table :subscriptions
|
|
drop_table :subscription_lists
|
|
drop_table :contacts
|
|
end
|
|
end |