2016-05-04 9 views
0

Ich hoffe, dass jemand mir helfen kann, dies zu sortieren, ohne mein gesamtes Backend neu erstellen zu müssen.Schienen - Verwirrung mit Migrationen

Ich verwende Rails und hatte Probleme bei der Bereitstellung auf Heroku. Wenn ich lief

$ heroku run rake db:migrate 

meine Migration fehlgeschlagen, weil ich eine Migration hatte, die eine Tabelle fallen gelassen, die nicht existierte. Was passiert war, war, dass ich eine Tabelle mit dem Namen Relationen hatte und sie in SchoolCityType umbenannte (singular).

Diese Migration, die die Tabelle gelöscht tropfte SchoolCityType s (Plural, wie es sein sollte).

Problem: Ich löschte die Migrationsdatei, anstatt sie zurückzurollen, aber Heroku wird den Befehl immer noch nicht ausführen.

Was soll ich tun? Danke im Voraus.

Heroku Migration Fehlermeldung:

== 20160407014126 DropSchoolDistrictCityTypesTable: migrating ================= 
-- drop_table(:school_district_city_types) 
    (1.7ms) DROP TABLE "school_district_city_types" 
PG::UndefinedTable: ERROR: table "school_district_city_types" does not exist 
: DROP TABLE "school_district_city_types" 
    (1.1ms) ROLLBACK 
rake aborted! 
StandardError: An error has occurred, this and all later migrations canceled:`== 20160407014126 DropSchoolDistrictCityTypesTable: migrating ================= 
-- drop_table(:school_district_city_types) 
    (1.7ms) DROP TABLE "school_district_city_types" 
PG::UndefinedTable: ERROR: table "school_district_city_types" does not exist 
: DROP TABLE "school_district_city_types" 
    (1.1ms) ROLLBACK 
rake aborted! 
StandardError: An error has occurred, this and all later migrations canceled: 

PG::UndefinedTable: ERROR: table "school_district_city_types" does not exist 
: DROP TABLE "school_district_city_types" 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:473:in `block in log' 
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:467:in `log' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:116:in `drop_table' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:662:in `block in method_missing' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:632:in `block in say_with_time' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:632:in `say_with_time' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:652:in `method_missing' 
/app/db/migrate/20160407014126_drop_school_district_city_types_table.rb:3:in `change' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:606:in `exec_migration' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:590:in `block (2 levels) in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:589:in `block in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:588:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:765:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:1041:in `block in ddl_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/transactions.rb:220:in `transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:1041:in `ddl_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:994:in `execute_migration_in_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:956:in `block in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:952:in `each' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:952:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:820:in `up' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:798:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/tasks/database_tasks.rb:137:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>' 
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: table "school_district_city_types" does not exist 
: DROP TABLE "school_district_city_types" 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:473:in `block in log' 
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:467:in `log' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:116:in `drop_table' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:662:in `block in method_missing' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:632:in `block in say_with_time' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:632:in `say_with_time' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:652:in `method_missing' 
/app/db/migrate/20160407014126_drop_school_district_city_types_table.rb:3:in `change' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:606:in `exec_migration' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:590:in `block (2 levels) in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:589:in `block in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:588:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:765:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:1041:in `block in ddl_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/transactions.rb:220:in `transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:1041:in `ddl_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:994:in `execute_migration_in_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:956:in `block in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:952:in `each' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:952:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:820:in `up' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:798:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/tasks/database_tasks.rb:137:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>' 
PG::UndefinedTable: ERROR: table "school_district_city_types" does not exist 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:473:in `block in log' 
/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:467:in `log' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:116:in `drop_table' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:662:in `block in method_missing' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:632:in `block in say_with_time' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:632:in `say_with_time' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:652:in `method_missing' 
/app/db/migrate/20160407014126_drop_school_district_city_types_table.rb:3:in `change' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:606:in `exec_migration' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:590:in `block (2 levels) in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:589:in `block in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:588:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:765:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:1041:in `block in ddl_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/transactions.rb:220:in `transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:1041:in `ddl_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:994:in `execute_migration_in_transaction' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:956:in `block in migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:952:in `each' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:952:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:820:in `up' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/migration.rb:798:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/tasks/database_tasks.rb:137:in `migrate' 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.2/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>' 
Tasks: TOP => db:migrate` 
+0

Es ist nicht wirklich klar, was Sie fragen. Wenn Sie die Migrationsdatei gelöscht haben, sollte dies kein Problem darstellen. Bitte fügen Sie die Fehlermeldung aus den Heroku-Protokollen bei. – meagar

+0

Ich habe es gerade hinzugefügt. Danke –

+1

Laut den Protokollen existiert '20160407014126_drop_school_district_city_types_table' immer noch und versucht, Ihre Tabelle zu löschen. Wenn die Tabelle in keiner Ihrer Datenbanken mehr existiert, können Sie diese Datei einfach löschen. Wenn Sie die Migration beibehalten möchten, weil einige Instanzen Ihrer Anwendung möglicherweise über diese Datenbank verfügen, können Sie einfach eine leere Tabelle mit dem korrekten Namen auf Heroku erstellen, damit die Migration erfolgreich abgeschlossen werden kann. – meagar

Antwort

0

Sie immer noch, auch wenn Sie Ihre Migrationen löschen Rollback können.

Ich schlage vor, Sie Rollback zu einer Position, die Sie sich wohl fühlen und arbeiten von dort mit neuen Migrationen.

Hoffe, es half

0

Es ist sieht aus wie Sie die Migrationsdatei gelöscht haben, die ‚school_district_city_types‘ erzeugt. Sie versuchen nun, die Tabelle zu löschen, die zuvor nicht existiert. Löschen Sie einfach die Migrationsdatei '20160407014126', die diese Tabelle löscht.

0

Sie sollten in der Lage sein, einfach die Migrationsdatei zu löschen. Schreiben Sie in Zukunft Ihre Migrationen wie folgt:

drop_table :school_district_city_types if (table_exists? :school_district_city_types) 

und Sie werden dieses Problem nie wieder haben.