Wiec tak
Zrobilem sobie ze w schema.rb wpisalem sobie VERSION=0 i mam taki kod aby mi kiedy zrobie rake db:reset tworzyl wszystkie potrzebne tabele
This file is auto-generated from the current state of the database. Instead of editing this file,
please use the migrations feature of Active Record to incrementally modify your database, and
then regenerate this schema definition.
Note that this schema.rb definition is the authoritative source for your database schema. If you need
to create the application database on another system, you should be using db:schema:load, not running
all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
you’ll amass, the slower it’ll run and the greater likelihood for issues).
It’s strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 0) do
create_table “categories”, :force => true do |t|
t.string “name”
t.integer “parent_id”
end
create_table “categories_photos”, :id => false, :force => true do |t|
t.integer “category_id”
t.integer “photo_id”
end
create_table “photos”, :force => true do |t|
t.string “filename”
end
create_table “slides”, :force => true do |t|
t.integer “position”
t.integer “photo_id”
t.integer “slideshow_id”
end
create_table “slideshows”, :force => true do |t|
t.string “name”
t.date “created_at”
end
end
ale i tak nie wykonuje mi tej migracji gdzie chce zeby dodawal 3 kolumny do tabeli photos , dokladnie ten kod
class AddPhotoColumns < ActiveRecord::Migration
def self.up
add_column :photos, :created_at, :date
add_column :photos, :thumbnail, :string
add_column :photos, :description, :string
Photo.find(:all).each do |photo|
photo.update_attribute :created_at, Time.now
photo.update_attribute :thumbnail, photo.filename.gsub(’.’, ‘_m’)
end
end
def self.down
remove_column “photos”, “created_at”
remove_column “photos”, “thumbnail”
remove_column “photos”, “description”
end
end
po wykonanie rake db:reset mam takie cos:
damian-kaleks-computer:photos kalek$ rake db:reset
(in /Users/kalek/rubydev/photos)
– create_table(“categories”, {:force=>true})
-> 0.3335s
– create_table(“categories_photos”, {:force=>true, :id=>false})
-> 0.0705s
– create_table(“photos”, {:force=>true})
-> 0.0909s
– create_table(“slides”, {:force=>true})
-> 0.0895s
– create_table(“slideshows”, {:force=>true})
-> 0.0892s
– initialize_schema_migrations_table()
-> 0.3313s
– assume_migrated_upto_version(0)
-> 0.0021s
damian-kaleks-computer:photos kalek$
Nie wiem czemu pomija mi jedna migracje z tym dodawaniem kolumn wie ktos moze , pleseeeee ???
Wyczytalem tez ze mozna podac ktora migracje chce sie wykonac i jaka czesc np - rake db:migrate:up VERSION=20090811221223
i teraz dodaje ladnie 3 kolumny ale czemu nie robi tego przy resecie nie wiem , ma ktos jakis pomysl , dla mnie hmm dziwne to 