title: Heroku Deployment failing
body: <p>I'm trying to deploy my app for the first time in heroku and I'm encountering a weird bug. When I try to run heroku rake db:migrate, i see this error :</p>
  
  <blockquote>
    <p>rake aborted! StandardError: An error has occurred, this and all later
    migrations canceled:</p>
  </blockquote>
  
  <pre><code>PG::UndefinedTable: ERROR:  relation "companies" does 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")
  )
  </code></pre>
  
  <p>I have verified a thousand times my migrations files Users &amp; Companies but nothing seems bad. So I really don't know what to do. I also try all the database reset etc..
  Like in this <a href="https://stackoverflow.com/questions/19097558/pg-undefinedtable-error-relation-users-does-not-exist?rq=1/">answer</a> for example. But nothing is working for me. Anyone have seen this before ?? I'm really desperate at this point.</p>
  
  <p>PS: And I also remove made the pg and sql3 changes.</p>
  
  <p>So I give you my code if it can be useful to discover the problem</p>
  
  <p>Company_model :</p>
  
  <pre><code>class Company &lt; ApplicationRecord
    has_many :users, dependent: :destroy
    has_many :groups, dependent: :destroy
  end
  </code></pre>
  
  <p>User_model :</p>
  
  <pre><code>class User &lt; ApplicationRecord
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :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
  </code></pre>
  
  <p>Company migration :</p>
  
  <pre><code>class CreateCompanies &lt; ActiveRecord::Migration[5.1]
    def change
      create_table :companies do |t|
        t.string :name
        t.string :ref
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>Devise migration :</p>
  
  <pre><code>class DeviseCreateUsers &lt; ActiveRecord::Migration[5.1]
    def change
      create_table :users do |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
  </code></pre>
  
  <p>Schema :</p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20170727071936) do
  
    create_table "comments", force: :cascade do |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 do |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 do |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 do |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 do |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 do |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 do |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 do |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 do |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 do |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 do |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 do |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
  </code></pre>