Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CreateProjects < ActiveRecord::Migration
- def up
- create_table :projects do |t|
- t.boolean :enabled
- t.integer :rating
- t.integer :seen_count
- t.integer :saved_count
- t.integer :replied_count
- t.string :name
- t.text :description
- t.integer :identification
- t.integer :price_from
- t.integer :price_to
- t.integer :area_from
- t.integer :area_to
- t.integer :rooms_from
- t.integer :rooms_to
- t.timestamps null: false
- end
- execute <<-SQL
- CREATE TYPE offer_type AS ENUM ('sale', 'rent', 'purchase', 'sublease');
- CREATE TYPE project_state AS ENUM ('in_preparation', 'under_construction', 'finished', 'approved');
- CREATE TYPE standard AS ENUM ('standard', 'higher_standard', 'bare');
- CREATE TYPE construction AS ENUM ('reinforced_concrete', 'brick', 'reinforced_concrete_with_brick', 'itong', 'straw', 'ceramics', 'wood', 'mounted_wood');
- SQL
- add_column :projects, :offer_type_code, :offer_type, index: true
- add_column :projects, :project_state_code, :project_state, index: true
- add_column :projects, :standard_code, :standard, index: true
- add_column :projects, :construction_code, :construction, index: true
- end
- def down
- execute <<-SQL
- DROP TYPE offer_type;
- DROP TYPE project_state;
- DROP TYPE standard;
- DROP TYPE construction;
- SQL
- drop_table :projects
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement