ruby on rails - Heroku Deployment failing -


i'm trying deploy app first time in heroku , i'm encountering weird bug. when try run heroku rake db:migrate, see error :

rake aborted! standarderror: error has occurred, , later migrations canceled:

pg::undefinedtable: error:  relation "companies" not exist : create table "users" ("id" bigserial primary key, "admin" boolean default 'f', "admin_c" boolean default 'f', "color" character varying, "initial" character varying, "name" character varying, "surname" character varying, "pseudo" character varying, "step" integer, "company_id" bigint, "email" character varying default '' not null, "encrypted_password" character varying default '' not null, "reset_password_token" character varying, "reset_password_sent_at" timestamp, "remember_created_at" timestamp, "sign_in_count" integer default 0 not null, "current_sign_in_at" timestamp, "last_sign_in_at" timestamp, "current_sign_in_ip" character varying, "last_sign_in_ip" character varying, "created_at" timestamp not null, "updated_at" timestamp not null, constraint "fk_rails_7682a3bdfe" foreign key ("company_id")   references "companies" ("id") ) 

i have verified thousand times migrations files users & companies nothing seems bad. don't know do. try database reset etc.. in answer example. nothing working me. have seen before ?? i'm desperate @ point.

ps: , remove made pg , sql3 changes.

so give code if can useful discover problem

company_model :

class company < applicationrecord   has_many :users, dependent: :destroy   has_many :groups, dependent: :destroy end 

user_model :

class user < applicationrecord   # include default devise modules. others available are:   # :confirmable, :lockable, :timeoutable , :omniauthable   devise :database_authenticatable, :registerable,          :recoverable, :rememberable, :trackable, :validatable    belongs_to :company, optional: true    has_many :users_group, dependent: :destroy   has_many :groups, through: :users_group   has_many :users_post, dependent: :destroy   has_many :posts, through: :users_post   has_many :tasks_users, dependent: :destroy   has_many :tasks, through: :tasks_users    has_many :requests, dependent: :destroy   has_many :groupes_admin, dependent: :destroy   has_many :posts, dependent: :destroy   has_many :comments, dependent: :destroy   has_many :tasks, dependent: :destroy  end 

company migration :

class createcompanies < activerecord::migration[5.1]   def change     create_table :companies |t|       t.string :name       t.string :ref        t.timestamps     end   end end 

devise migration :

class devisecreateusers < activerecord::migration[5.1]   def change     create_table :users |t|       ## database authenticatable       t.boolean :admin, default: false       t.boolean :admin_c, default: false       t.string :color       t.string :initial       t.string :name       t.string :surname       t.string :pseudo       t.integer :step        t.references :company, index: true, foreign_key: true       t.boolean :admin, default: false       t.string :email,              null: false, default: ""       t.string :encrypted_password, null: false, default: ""        ## recoverable       t.string   :reset_password_token       t.datetime :reset_password_sent_at        ## rememberable       t.datetime :remember_created_at        ## trackable       t.integer  :sign_in_count, default: 0, null: false       t.datetime :current_sign_in_at       t.datetime :last_sign_in_at       t.string   :current_sign_in_ip       t.string   :last_sign_in_ip        t.timestamps null: false     end      add_index :users, :email,                unique: true     add_index :users, :reset_password_token, unique: true   end end 

schema :

activerecord::schema.define(version: 20170727071936)    create_table "comments", force: :cascade |t|     t.string "content"     t.boolean "done"     t.integer "post_id"     t.integer "user_id"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["post_id"], name: "index_comments_on_post_id"     t.index ["user_id"], name: "index_comments_on_user_id"   end    create_table "companies", force: :cascade |t|     t.string "name"     t.string "ref"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false   end    create_table "groupes_admins", force: :cascade |t|     t.integer "user_id"     t.integer "group_id"     t.index ["group_id"], name: "index_groupes_admins_on_group_id"     t.index ["user_id"], name: "index_groupes_admins_on_user_id"   end    create_table "groups", force: :cascade |t|     t.string "name"     t.integer "cat"     t.boolean "main"     t.boolean "perso"     t.integer "effectif", default: 0     t.integer "elm", default: 0     t.integer "elm_d", default: 0     t.integer "date_cat"     t.integer "date_id"     t.datetime "date"     t.integer "company_id"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["company_id"], name: "index_groups_on_company_id"   end    create_table "posts", force: :cascade |t|     t.text "content"     t.boolean "attached"     t.integer "attached_cat"     t.integer "attached_id"     t.boolean "done"     t.datetime "done_at"     t.integer "done_cat"     t.integer "donner_id"     t.datetime "upd_at"     t.integer "upd_cat"     t.integer "updater_id"     t.string "title"     t.date "deadline"     t.integer "group_id"     t.integer "user_id"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["group_id"], name: "index_posts_on_group_id"     t.index ["user_id"], name: "index_posts_on_user_id"   end    create_table "requests", force: :cascade |t|     t.integer "user_id"     t.integer "group_id"     t.datetime "validate_at"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["group_id"], name: "index_requests_on_group_id"     t.index ["user_id"], name: "index_requests_on_user_id"   end    create_table "subtasks", force: :cascade |t|     t.string "title"     t.datetime "date"     t.boolean "finished"     t.datetime "done_at"     t.integer "done_id"     t.integer "assign_id"     t.integer "task_id"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["task_id"], name: "index_subtasks_on_task_id"   end    create_table "tasks", force: :cascade |t|     t.integer "user_id"     t.integer "group_id"     t.integer "post_id"     t.string "title"     t.datetime "date"     t.boolean "done"     t.integer "doner_id"     t.datetime "done_at"     t.boolean "assigned"     t.integer "elm", default: 0     t.integer "elm_d", default: 0     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["group_id"], name: "index_tasks_on_group_id"     t.index ["post_id"], name: "index_tasks_on_post_id"     t.index ["user_id"], name: "index_tasks_on_user_id"   end    create_table "tasks_users", force: :cascade |t|     t.integer "task_id"     t.integer "user_id"     t.index ["task_id"], name: "index_tasks_users_on_task_id"     t.index ["user_id"], name: "index_tasks_users_on_user_id"   end    create_table "users", force: :cascade |t|     t.boolean "admin", default: false     t.boolean "admin_c", default: false     t.string "color"     t.string "initial"     t.string "name"     t.string "surname"     t.string "pseudo"     t.integer "step"     t.integer "company_id"     t.string "email", default: "", null: false     t.string "encrypted_password", default: "", null: false     t.string "reset_password_token"     t.datetime "reset_password_sent_at"     t.datetime "remember_created_at"     t.integer "sign_in_count", default: 0, null: false     t.datetime "current_sign_in_at"     t.datetime "last_sign_in_at"     t.string "current_sign_in_ip"     t.string "last_sign_in_ip"     t.datetime "created_at", null: false     t.datetime "updated_at", null: false     t.index ["company_id"], name: "index_users_on_company_id"     t.index ["email"], name: "index_users_on_email", unique: true     t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true   end    create_table "users_groups", force: :cascade |t|     t.integer "user_id"     t.integer "group_id"     t.index ["group_id"], name: "index_users_groups_on_group_id"     t.index ["user_id"], name: "index_users_groups_on_user_id"   end    create_table "users_posts", force: :cascade |t|     t.integer "post_id"     t.integer "user_id"     t.index ["post_id"], name: "index_users_posts_on_post_id"     t.index ["user_id"], name: "index_users_posts_on_user_id"   end  end 

the error message suggests you're trying create reference companies on users table companies table doesn't yet exist. try making sure order of migrations such companies created before users. can try loading schema @ once rather migrating 1 @ time, heroku run rake db:schema:load.

disclaimer: rake db:schema:load wipe of data. best used setting new database. never run against production database contains critical data. once have data need incremental migrations.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -