Database Management

Instructions for managing your application databases in the Flynn hosting environment used by your Satorix Hosting Cluster.

Importing an existing Postgresql database

flynn -a projectname pg restore postgres-db.dump

Note: If the database exists already and you want to make sure the import is perfectly clean do the following.

  • First scale down your application:
    flynn -a projectname scale web=0
  • Then remove all existing tables and data from the database:
    flynn -a projectname pg psql -- -c "
    DO \$\$ DECLARE r RECORD;
      BEGIN
        FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
          EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
        END LOOP;
      END \$\$;
    "
    

    THE ABOVE PSQL COMMAND WILL DESTROY ALL EXISTING DATA!

Importing an existing MySQL database

flynn -a projectname mysql restore mysql-db.dump