Migrationsproblem

Scaffolding, Configuration, Helper

Migrationsproblem

Beitragvon Theoric am 23.07.2008, 13:01

Hallo,

weiß gerade nicht ob ich hier im richtigen Unterforum bin, falls nicht wäre ich dem Admin sehr dankbar wenn er oder sie diesen Thread verschiebt ;-)

Ich bin gerade dabei mich in Ruby on Rails einzuarbeiten, bin noch ein Frischling darin :oops: , und möchte mit rake db:migrate die Anwendung migrieren und ich bekomme folgende Fehlermeldung:

Code: Alles auswählen
abogo@abogo-desktop:~/ontrack$ rake db:migrate --trace
(in /home/abogo/ontrack)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== 1 CreateProjects: migrating ================================================
-- create_table(:projects)
-- default()
rake aborted!
undefined method `default' for #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0xb73c0408>
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `method_missing'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:281:in `method_missing'
./db/migrate//001_create_projects.rb:5:in `up_without_benchmarks'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:94:in `create_table'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:416:in `create_table'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `method_missing'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:281:in `method_missing'
./db/migrate//001_create_projects.rb:3:in `up_without_benchmarks'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:339:in `each'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:339:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:307:in `up'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:298:in `migrate'
/home/abogo/ontrack/vendor/rails/railties/lib/tasks/databases.rake:85
/usr/lib/ruby/1.8/rake.rb:546:in `call'
/usr/lib/ruby/1.8/rake.rb:546:in `execute'
/usr/lib/ruby/1.8/rake.rb:541:in `each'
/usr/lib/ruby/1.8/rake.rb:541:in `execute'
/usr/lib/ruby/1.8/rake.rb:508:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:501:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:501:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:494:in `invoke'
/usr/lib/ruby/1.8/rake.rb:1931:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:1909:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1909:in `each'
/usr/lib/ruby/1.8/rake.rb:1909:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1903:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1881:in `run'
/usr/lib/ruby/1.8/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1878:in `run'
/usr/bin/rake:28


Ich frag mich hier jetzt schon seit mehreren Stunden woran das nur liegen mag, weiß jemand Rat?
Danke im voraus!

Gruß
Theoric
Theoric
 
Beiträge: 10
Registriert: 23.07.2008, 12:48

Re: Migrationsproblem

Beitragvon megawatt am 23.07.2008, 14:06

Hallo Theoric,

kannst du auch mal deine migration-datei posten?
megawatt
 
Beiträge: 30
Registriert: 06.12.2007, 20:38

Re: Migrationsproblem

Beitragvon Theoric am 23.07.2008, 14:11

Hallo,

hier kommt die Migrationsdatei:

Code: Alles auswählen
class CreateProjects < ActiveRecord::Migration
  def self.up
    create_table :projects do |t|
      t.column :name, :string, :limit => 100,
               :null => false, default => ""
      t.column :description, :text, :null => false, default => 0
      t.column :start_date, :date, :null => false, default => 0
    end
  end

  def self.down
    drop_table :projects
  end
end
Theoric
 
Beiträge: 10
Registriert: 23.07.2008, 12:48

Re: Migrationsproblem

Beitragvon megawatt am 23.07.2008, 14:32

ok, du darfst "default" nicht als Variable schreiben, sondern musst ein symbol einfügen.
Es muss also heissen:

:default=>""
megawatt
 
Beiträge: 30
Registriert: 06.12.2007, 20:38

Re: Migrationsproblem

Beitragvon Theoric am 23.07.2008, 14:40

Danke für den Tip :) ,

allerdings bekomme ich jetzt schon wieder eine Fehlermeldung:

Code: Alles auswählen
abogo@abogo-desktop:~/ontrack$ rake db:migrate --trace
(in /home/abogo/ontrack)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== 1 CreateProjects: migrating ================================================
-- create_table(:projects)
rake aborted!
Mysql::Error: #42000Invalid default value for 'start_date': CREATE TABLE `projects` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(100) DEFAULT '' NOT NULL, `description` text DEFAULT '' NOT NULL, `start_date` date DEFAULT '' NOT NULL) ENGINE=InnoDB
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:281:in `execute'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:104:in `create_table'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:416:in `create_table'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `method_missing'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:281:in `method_missing'
./db/migrate//001_create_projects.rb:3:in `up_without_benchmarks'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:339:in `each'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:339:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:307:in `up'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:298:in `migrate'
/home/abogo/ontrack/vendor/rails/railties/lib/tasks/databases.rake:85
/usr/lib/ruby/1.8/rake.rb:546:in `call'
/usr/lib/ruby/1.8/rake.rb:546:in `execute'
/usr/lib/ruby/1.8/rake.rb:541:in `each'
/usr/lib/ruby/1.8/rake.rb:541:in `execute'
/usr/lib/ruby/1.8/rake.rb:508:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:501:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:501:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:494:in `invoke'
/usr/lib/ruby/1.8/rake.rb:1931:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:1909:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1909:in `each'
/usr/lib/ruby/1.8/rake.rb:1909:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1903:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1881:in `run'
/usr/lib/ruby/1.8/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1878:in `run'
/usr/bin/rake:28
Zuletzt geändert von Theoric am 23.07.2008, 14:54, insgesamt 1-mal geändert.
Theoric
 
Beiträge: 10
Registriert: 23.07.2008, 12:48

Re: Migrationsproblem

Beitragvon megawatt am 23.07.2008, 14:53

hm, die Fehlermeldung ist immer noch die alte ...
Code: Alles auswählen
== 1 CreateProjects: migrating ================================================
-- create_table(:projects)
-- default()
rake aborted!


Hast du den Server neu gestartet?
megawatt
 
Beiträge: 30
Registriert: 06.12.2007, 20:38

Re: Migrationsproblem

Beitragvon Theoric am 23.07.2008, 14:56

Hi,
hatte gerade gesehen, während du geantwortet hast, dass ich vor dem default wert die : vergessen hatte, nun hat sich die fehlermeldung verändert:

Code: Alles auswählen
abogo@abogo-desktop:~/ontrack$ rake db:migrate --trace
(in /home/abogo/ontrack)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== 1 CreateProjects: migrating ================================================
-- create_table(:projects)
rake aborted!
Mysql::Error: #42000Invalid default value for 'start_date': CREATE TABLE `projects` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(100) DEFAULT '' NOT NULL, `description` text DEFAULT '' NOT NULL, `start_date` date DEFAULT '' NOT NULL) ENGINE=InnoDB
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:281:in `execute'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:104:in `create_table'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:416:in `create_table'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:285:in `method_missing'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:265:in `say_with_time'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:281:in `method_missing'
./db/migrate//001_create_projects.rb:3:in `up_without_benchmarks'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `send'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:219:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:339:in `each'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:339:in `migrate'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:307:in `up'
/home/abogo/ontrack/vendor/rails/activerecord/lib/active_record/migration.rb:298:in `migrate'
/home/abogo/ontrack/vendor/rails/railties/lib/tasks/databases.rake:85
/usr/lib/ruby/1.8/rake.rb:546:in `call'
/usr/lib/ruby/1.8/rake.rb:546:in `execute'
/usr/lib/ruby/1.8/rake.rb:541:in `each'
/usr/lib/ruby/1.8/rake.rb:541:in `execute'
/usr/lib/ruby/1.8/rake.rb:508:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:501:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:501:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:494:in `invoke'
/usr/lib/ruby/1.8/rake.rb:1931:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:1909:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1909:in `each'
/usr/lib/ruby/1.8/rake.rb:1909:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1903:in `top_level'
/usr/lib/ruby/1.8/rake.rb:1881:in `run'
/usr/lib/ruby/1.8/rake.rb:1948:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1878:in `run'
/usr/bin/rake:28


Muss der Server denn während des Migrierens an sein`?
Theoric
 
Beiträge: 10
Registriert: 23.07.2008, 12:48

Re: Migrationsproblem

Beitragvon megawatt am 23.07.2008, 15:01

Ok, wir arbeiten uns langsam nach vorne :)

Code: Alles auswählen
t.column :start_date, :date, :null => false, default => 0

Da es sich hier um ein Datumsfeld handelt, ist "0" kein möglicher Default-Wert.
Ich würde "default ..." einfach löschen!
megawatt
 
Beiträge: 30
Registriert: 06.12.2007, 20:38

Re: Migrationsproblem

Beitragvon Theoric am 23.07.2008, 15:03

cool, danke :)

Jetzt hat es geklappt!
Theoric
 
Beiträge: 10
Registriert: 23.07.2008, 12:48


Zurück zu Strukturierung

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast

cron