Files
componentowl-rails-archive/db/migrate/20090713163655_initial_migration.rb

332 lines
8.4 KiB
Ruby

class InitialMigration < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :first_name
t.string :last_name
t.string :login, :null => false
t.string :email, :null => false
t.string :crypted_password, :null => false
t.string :password_salt, :null => false
t.string :persistence_token, :null => false
t.string :single_access_token, :null => false
t.string :perishable_token, :null => false
t.integer :login_count, :null => false, :default => 0
t.integer :failed_login_count, :null => false, :default => 0
t.datetime :last_request_at
t.datetime :current_login_at
t.datetime :last_login_at
t.string :current_login_ip
t.string :last_login_ip
t.timestamps
t.datetime :deleted_at
end
create_table :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 :product_categories do |t|
t.string :code
t.string :name
t.integer :position
t.timestamps
t.datetime :deleted_at
end
add_index(:product_categories, :code, :unique => true)
create_table :products do |t|
t.integer :product_category_id
t.string :code
t.string :internal_code
t.string :file
t.string :name
t.string :label
t.boolean :promoted, :default => false
t.boolean :homepage, :default => false
t.decimal :price, :scale => 2, :precision => 10
t.decimal :regular_price, :scale => 2, :precision => 10
t.integer :bmtID
t.integer :position
t.timestamps
t.datetime :deleted_at
end
add_index(:products, :code, :unique => true)
add_index(:products, :internal_code, :unique => true)
create_table :products_promotions, :id => false, :primary_key => [:product_id, :promotion_id] do |t|
t.integer :product_id
t.integer :promotion_id, :references => :allowed_values
end
create_table :product_descriptions do |t|
t.integer :product_description_type_id, :references => :allowed_values
t.integer :product_id
t.string :title
t.text :value
t.timestamps
end
create_table :product_pages do |t|
t.integer :parent_id, :references => :product_pages
t.integer :product_id
t.boolean :tab, :default => false
t.string :code
t.string :name
t.text :html
t.integer :position
t.timestamps
t.datetime :deleted_at
end
create_table :product_offers do |t|
t.integer :product_id
t.integer :related_product_id, :references => :products
t.integer :bmtID
t.string :name
t.text :description
t.decimal :price, :scale => 2, :precision => 10
t.datetime :begins_at
t.datetime :expires_at
t.integer :position
t.timestamps
end
create_table :product_editions do |t|
t.integer :product_id
t.string :code
t.string :internal_code
t.integer :bmtID
t.string :name
t.text :description
t.decimal :price, :scale => 2, :precision => 10
t.decimal :regular_price, :scale => 2, :precision => 10
t.boolean :initial, :default => false
t.integer :position
t.timestamps
end
add_index(:product_editions, :internal_code, :unique => true)
create_table :product_discounts do |t|
t.integer :product_id
t.integer :product_edition_id
t.string :discount_type
t.string :discount_code
t.decimal :price, :scale => 2, :precision => 10
t.timestamps
end
create_table :product_upgrades do |t|
t.integer :product_id
t.integer :product_edition_id
t.string :upgrade_type
t.string :bmtID
t.decimal :price, :scale => 2, :precision => 10
t.timestamps
end
create_table :product_url_params do |t|
t.integer :product_id
t.integer :url_destination_id, :references => :allowed_values
t.string :url_param
t.boolean :default, :default => false
t.timestamps
end
create_table :releases do |t|
t.integer :product_id
t.string :version
t.integer :build
t.text :description
t.text :changelog
t.date :date
t.datetime :postpone_till
t.timestamps
end
create_table :testimonials do |t|
t.integer :product_id
t.text :text
t.string :author
t.boolean :hidden, :default => false
t.integer :position
t.timestamps
t.datetime :deleted_at
end
create_table :testimonial_positions do |t|
t.integer :testimonial_id
t.integer :testimonial_location_id, :references => :allowed_values
t.integer :product_id
t.text :extract
t.integer :position
end
create_table :product_images do |t|
t.integer :product_id
t.string :image
t.string :alt
t.string :label
t.timestamps
end
create_table :screenshots do |t|
t.integer :product_id
t.string :image
t.string :alt
t.string :label
t.integer :position
t.timestamps
end
create_table :product_icons do |t|
t.integer :product_id
t.string :icon
t.integer :size
t.timestamps
end
create_table :latests do |t|
t.string :title
t.string :link
t.text :body
t.date :date
t.timestamps
t.datetime :deleted_at
end
create_table :faq_categories do |t|
t.integer :product_id
t.string :url_param
t.string :name
t.string :description
t.integer :position
t.timestamps
t.datetime :deleted_at
end
create_table :faqs do |t|
t.integer :faq_category_id
t.string :url_param
t.text :question
t.text :answer
t.boolean :featured, :default => false
t.integer :position
t.timestamps
t.datetime :deleted_at
end
create_table :support_requests do |t|
t.integer :support_request_origin_id, :references => :allowed_values
t.string :name
t.string :email
t.integer :product_id
t.string :subject
t.text :message
t.boolean :mail_sent, :default => false
t.timestamps
t.datetime :deleted_at
end
create_table :volume_discounts do |t|
t.integer :from
t.integer :to
t.integer :discount
t.timestamps
end
create_table :download_logs do |t|
t.integer :product_id
t.text :request
t.timestamp :created_at
end
create_table :meta_tags do |t|
t.string :path
t.string :title
t.text :keywords
t.text :description
t.timestamps
end
create_table :sitemap_titles do |t|
t.string :path
t.string :title
t.timestamps
end
create_table :static_pages do |t|
t.string :code
t.string :url_param
t.string :name
t.text :html
t.timestamps
t.datetime :deleted_at
end
add_index(:static_pages, :code, :unique => true)
end
def self.down
drop_table :static_pages
drop_table :sitemap_titles
drop_table :meta_tags
drop_table :download_logs
drop_table :volume_discounts
drop_table :support_requests
drop_table :faqs
drop_table :faq_categories
drop_table :latests
drop_table :product_icons
drop_table :product_screenshots
drop_table :product_images
drop_table :testimonial_positions
drop_table :testimonials
drop_table :releases
drop_table :product_url_params
drop_table :product_upgrades
drop_table :product_discounts
drop_table :product_editions
drop_table :product_offers
drop_table :product_pages
drop_table :product_descriptions
drop_table :products_promotions
drop_table :products
drop_table :product_categories
drop_table :allowed_values
drop_table :users
end
end