Commit b3dc4fb72146d439314bdb40377272a317974397

Authored by Andrew8xx8
1 parent 3b6228dc

Migrations to convert data added

db/migrate/20130323174317_add_private_to_snippets.rb
1 1 class AddPrivateToSnippets < ActiveRecord::Migration
2 2 def change
3   - add_column :snippets, :private, :boolean
  3 + add_column :snippets, :private, :boolean, null: false, default: true
4 4 end
5 5 end
... ...
db/migrate/20130324203535_add_type_value_for_snippets.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +class AddTypeValueForSnippets < ActiveRecord::Migration
  2 + def up
  3 + Snippet.where("project_id IS NOT NULL").update_all(type: 'ProjectSnippet')
  4 + end
  5 +
  6 + def down
  7 + end
  8 +end
... ...
db/schema.rb
... ... @@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(:version => 20130324172327) do
  14 +ActiveRecord::Schema.define(:version => 20130324203535) do
15 15  
16 16 create_table "events", :force => true do |t|
17 17 t.string "target_type"
... ... @@ -184,13 +184,13 @@ ActiveRecord::Schema.define(:version =&gt; 20130324172327) do
184 184 create_table "snippets", :force => true do |t|
185 185 t.string "title"
186 186 t.text "content"
187   - t.integer "author_id", :null => false
  187 + t.integer "author_id", :null => false
188 188 t.integer "project_id"
189   - t.datetime "created_at", :null => false
190   - t.datetime "updated_at", :null => false
  189 + t.datetime "created_at", :null => false
  190 + t.datetime "updated_at", :null => false
191 191 t.string "file_name"
192 192 t.datetime "expires_at"
193   - t.boolean "private"
  193 + t.boolean "private", :default => true, :null => false
194 194 t.string "type"
195 195 end
196 196  
... ...