cleaning up migration
Oleg
committed Jan 17, 2012
commit e2ea7b1df6e9c79ad9fb16ac7db5460b6b2476fe
Showing 2
changed files with
16 additions
and 33 deletions
app/views/layouts/cms_admin/_body.html.erb
+1
-1
| @@ | @@ -13,7 +13,7 @@ |
| <div class='center_column'> | |
| <%= render :partial => 'layouts/cms_admin/center' %> | |
| <div class='sofa'> | |
| - | <a href='http://comfortablemexicansofa.twg.ca' target='_blank'>ComfortableMexicanSofa</a> |
| + | <a href='https://github.com/twg/comfortable-mexican-sofa' target='_blank'>ComfortableMexicanSofa</a> |
| <span class='version'><%= ComfortableMexicanSofa::VERSION %></span> | |
| </div> | |
| </div> | |
migrate/01_create_cms.rb b/db/migrate/01_create_cms.rb
+15
-32
| @@ | @@ -1,8 +1,14 @@ |
| class CreateCms < ActiveRecord::Migration | |
| - | |
| - | |
| def self.up | |
| + | |
| + | text_limit = case ActiveRecord::Base.connection.adapter_name |
| + | when 'PostgreSQL' |
| + | nil |
| + | else |
| + | { :limit => 16777215 } |
| + | end |
| + | |
| # -- Sites -------------------------------------------------------------- | |
| create_table :cms_sites do |t| | |
| t.string :label, :null => false | |
| @@ | @@ -22,17 +28,9 @@ class CreateCms < ActiveRecord::Migration |
| t.string :app_layout | |
| t.string :label, :null => false | |
| t.string :identifier, :null => false | |
| - | |
| - | case ActiveRecord::Base.connection.adapter_name |
| - | when 'PostgreSQL' |
| - | t.text :content |
| - | t.text :css |
| - | t.text :js |
| - | else |
| - | t.text :content, :limit => 16777215 |
| - | t.text :css, :limit => 16777215 |
| - | t.text :js, :limit => 16777215 |
| - | end |
| + | t.text :content, text_limit |
| + | t.text :css, text_limit |
| + | t.text :js, text_limit |
| t.integer :position, :null => false, :default => 0 | |
| t.boolean :is_shared, :null => false, :default => false | |
| t.timestamps | |
| @@ | @@ -49,12 +47,7 @@ class CreateCms < ActiveRecord::Migration |
| t.string :label, :null => false | |
| t.string :slug | |
| t.string :full_path, :null => false | |
| - | case ActiveRecord::Base.connection.adapter_name |
| - | when 'PostgreSQL' |
| - | t.text :content |
| - | else |
| - | t.text :content, :limit => 16777215 |
| - | end |
| + | t.text :content, text_limit |
| t.integer :position, :null => false, :default => 0 | |
| t.integer :children_count, :null => false, :default => 0 | |
| t.boolean :is_published, :null => false, :default => true | |
| @@ | @@ -78,7 +71,7 @@ class CreateCms < ActiveRecord::Migration |
| t.integer :site_id, :null => false | |
| t.string :label, :null => false | |
| t.string :identifier, :null => false | |
| - | t.text :content |
| + | t.text :content, text_limit |
| t.integer :position, :null => false, :default => 0 | |
| t.boolean :is_shared, :null => false, :default => false | |
| t.timestamps | |
| @@ | @@ -94,12 +87,7 @@ class CreateCms < ActiveRecord::Migration |
| t.string :file_file_name, :null => false | |
| t.string :file_content_type, :null => false | |
| t.integer :file_file_size, :null => false | |
| - | case ActiveRecord::Base.connection.adapter_name |
| - | when 'PostgreSQL' |
| - | t.string :description |
| - | else |
| - | t.string :description, :limit => 2048 |
| - | end |
| + | t.string :description, :limit => 2048 |
| t.integer :position, :null => false, :default => 0 | |
| t.timestamps | |
| end | |
| @@ | @@ -112,12 +100,7 @@ class CreateCms < ActiveRecord::Migration |
| create_table :cms_revisions, :force => true do |t| | |
| t.string :record_type, :null => false | |
| t.integer :record_id, :null => false | |
| - | case ActiveRecord::Base.connection.adapter_name |
| - | when 'PostgreSQL' |
| - | t.text :data |
| - | else |
| - | t.text :data, :limit => 16777215 |
| - | end |
| + | t.text :data, text_limit |
| t.datetime :created_at | |
| end | |
| add_index :cms_revisions, [:record_type, :record_id, :created_at] | |