Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to Migrate from Heroku to Hatchbox.io Discussion

Thanks, Chris!

I'd love to see more of these. I'm using Hatch and loving it, I just don't think I'm using it to it's full potential.

I think a series of setting up and configuring different features would be cool!


Reply
Nice! Really useful. Was using the same db from heroku and hitting the row limits .. So migrating the db solves this. 

Would love to see more of these - Best practices for background jobs, elastic search implementations etc. Thank you!!
Reply
Cool. Out of curiosity, when creating servers and apps, are the passwords stored in clear in the database? 
Reply
They're all encrypted. Not sure why you would store anything in plaintext like that.
Reply
Right, it wouldn't make sense :)  I was wondering mainly about automated deployments - i.e. how does the app know which passwords to use when doing things on servers if passwords are encrypted. But I was now reading about attr_encrypted and similar, would that be a good enough approach to encrypt sensitive information? Thanks!
Reply

Great tutorial, but I am missing something... What is the benefit of using Hatchbox over Heroku?

Reply

Chris, I can see that you mention Passenger + NGINX, any chace to use PUMA instead?

Reply

I always get the error pg_restore: error: could not execute query: ERROR: cannot drop schema public because other objects depend on it. It happens even if I clear all data from my hatchbox DB (using db:schema:load). This "public" schema is nothing I set up, but it seems to be a default thing from PG in the "postgres" and "template1" databases (both were automatically created). How do I get around this error?

Reply

Hier is the full dump btw. It contains a bunch of errors, even though I completely dropped and re-created the empty DB.

pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3091; 1259 9316695 INDEX unique_schema_migrations ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  index "unique_schema_migrations" does not exist
Command was: DROP INDEX "public"."unique_schema_migrations";
pg_restore: from TOC entry 3108; 2606 9316673 CONSTRAINT users users_pkey ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  cannot drop constraint users_pkey on table public.users because other objects depend on it
DETAIL:  constraint fk_rails_330c32d8d9 on table public.oauth_access_grants depends on index public.users_pkey
constraint fk_rails_ee63f25419 on table public.oauth_access_tokens depends on index public.users_pkey
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: ALTER TABLE ONLY "public"."users" DROP CONSTRAINT "users_pkey";
pg_restore: from TOC entry 214; 1259 9316599 TABLE users ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  cannot drop table public.users because other objects depend on it
DETAIL:  constraint fk_rails_330c32d8d9 on table public.oauth_access_grants depends on table public.users
constraint fk_rails_ee63f25419 on table public.oauth_access_tokens depends on table public.users
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: DROP TABLE "public"."users";
pg_restore: from TOC entry 6; 2615 9316488 SCHEMA public ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  cannot drop schema public because other objects depend on it
DETAIL:  table public.flipper_features depends on schema public
table public.flipper_gates depends on schema public
table public.gig_payments depends on schema public
table public.oauth_access_grants depends on schema public
table public.oauth_access_tokens depends on schema public
table public.oauth_applications depends on schema public
table public.users depends on schema public
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: DROP SCHEMA "public";
pg_restore: error: could not execute query: ERROR:  schema "public" already exists
Command was: CREATE SCHEMA public;


pg_restore: from TOC entry 214; 1259 9316599 TABLE users ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  relation "users" already exists
Command was: CREATE TABLE "public"."users" (
    "id" integer NOT NULL,
    "email" character varying(255) DEFAULT ''::character varying NOT NULL,
    "encrypted_password" character varying DEFAULT ''::character varying NOT NULL,
    "reset_password_token" character varying(255),
    "reset_password_sent_at" timestamp without time zone,
    "remember_created_at" timestamp without time zone,
    "sign_in_count" integer DEFAULT 0 NOT NULL,
    "current_sign_in_at" timestamp without time zone,
    "last_sign_in_at" timestamp without time zone,
    "current_sign_in_ip" character varying(255),
    "last_sign_in_ip" character varying(255),
    "created_at" timestamp without time zone NOT NULL,
    "updated_at" timestamp without time zone NOT NULL,
    "name" character varying(255),
    "roles_mask" integer,
    "mobile" character varying(255),
    "invitation_token" character varying(255),
    "invitation_sent_at" timestamp without time zone,
    "invitation_accepted_at" timestamp without time zone,
    "invitation_limit" integer,
    "invited_by_id" integer,
    "invited_by_type" character varying(255),
    "invitation_created_at" timestamp without time zone,
    "provider" character varying DEFAULT 'email'::character varying NOT NULL,
    "uid" character varying DEFAULT ''::character varying NOT NULL,
    "oauth_token" character varying(255),
    "oauth_expires_at" timestamp without time zone,
    "image_uid" character varying(255),
    "is_backoffice_admin" boolean,
    "locale" character varying(255),
    "icalendar_token" character varying(255),
    "invited_to_band_id" integer,
    "last_ical_access_at" timestamp without time zone,
    "receive_create_notification_emails" boolean DEFAULT true,
    "receive_update_notification_emails" boolean DEFAULT true,
    "receive_attendance_state_change_emails" boolean DEFAULT true,
    "receive_attendance_initial_reaction_email" boolean DEFAULT false,
    "confirmation_token" character varying,
    "confirmed_at" timestamp without time zone,
    "confirmation_sent_at" timestamp without time zone,
    "unconfirmed_email" character varying,
    "tokens" "jsonb",
    "tos_agreement" boolean,
    "tos_accepted_at" timestamp without time zone,
    "default_band_id" integer
);


pg_restore: from TOC entry 3275; 0 9316599 TABLE DATA users ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  column "provider" of relation "users" does not exist
Command was: COPY "public"."users" ("id", "email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "created_at", "updated_at", "name", "roles_mask", "mobile", "invitation_token", "invitation_sent_at", "invitation_accepted_at", "invitation_limit", "invited_by_id", "invited_by_type", "invitation_created_at", "provider", "uid", "oauth_token", "oauth_expires_at", "image_uid", "is_backoffice_admin", "locale", "icalendar_token", "invited_to_band_id", "last_ical_access_at", "receive_create_notification_emails", "receive_update_notification_emails", "receive_attendance_state_change_emails", "receive_attendance_initial_reaction_email", "confirmation_token", "confirmed_at", "confirmation_sent_at", "unconfirmed_email", "tokens", "tos_agreement", "tos_accepted_at", "default_band_id") FROM stdin;
pg_restore: from TOC entry 3108; 2606 9316673 CONSTRAINT users users_pkey ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  multiple primary keys for table "users" are not allowed
Command was: ALTER TABLE ONLY "public"."users"
    ADD CONSTRAINT "users_pkey" PRIMARY KEY ("id");


pg_restore: from TOC entry 3128; 2606 9316706 FK CONSTRAINT subscriptions fk_rails_933bdff476 ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  insert or update on table "subscriptions" violates foreign key constraint "fk_rails_933bdff476"
DETAIL:  Key (user_id)=(843) is not present in table "users".
Command was: ALTER TABLE ONLY "public"."subscriptions"
    ADD CONSTRAINT "fk_rails_933bdff476" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id");


pg_restore: warning: errors ignored on restore: 9
Reply

Ha, never mind. I had an older version of the schema on heroku, which made it incompatible with the schema on hatchbox.

I had to first deploy the latest version (including the latest migrations) to heroku before capturing the DB backup. After that I had no problems importing the data into hatchbox.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.