metafresh logo and link to homepage

Get your local DB up and running

Option one:
Import the dump into your local PostgreSQL instalation

Notes

Import the initial dump from command line

To get the database dump into your local database via command line, do as follows, as user postgres:

createuser --login --createdb --no-createrole --no-superuser --encrypted --replication --inherit --pwprompt metasfresh

For convenience and since this is just your local development DB, you might want to also specify --superuser

createdb metasfresh -O metasfresh
pg_restore -Fc -j 2 -d metasfresh metasfresh_latest.pgdump

Note that metasfresh contains more than 1000 tables. Importing the dump might take a while.

…or import the initial dump using pgAdmin

To get the database dump into your local database via pgAdmin, do as follows:

printpreview

For development purposes, you can create the role with the role privileges LOGIN, SUPERUSER, INHERIT, CREATEDB and NOCREATEROLE

printpreview

Make sure that the new database is owned by the metasfresh role.

Option two:
Run the DB in docker

If you have a docker host running locally, you can pull and run the latest metasfresh database in it.

To obtain a docker host, you can for example use our vagrant file.

See https://github.com/metasfresh/metasfresh-dev/tree/master/vagrant to get started.

In order to run the PostgreSQL server inside your local virtual machine and access it, you can edit the vagrant file and add a “forwarded port mapping”. To do this, find the respective section in the vagrant file and add something like

config.vm.network "forwarded_port", id: "metasfresh-db", guest: 5432 , host: 5432 , host_ip: "127.0.0.1"

Once your started your local virtual machine this way and sshed into it, you can run

sudo docker run -p 5432:5432 -t metasfresh/metasfresh-db

To get our latest metasfresh-db and start it up.

Update the database from the master branch

This section describes how to update your local (developer) DB with the latest migration scripts that were just build from the master branch

You can get those migration script by downloading them as a tar.gz file from this URL

https://repo.metasfresh.com/service/local/artifact/maven/redirect?g=de.metas.dist&a=de.metas.endcustomer.mf15.dist&v=LATEST&r=mvn-master&p=tar.gz&c=sql-only

That tar.gz contains

What you still need to provide is the following:

METASFRESH_DB_SERVER=localhost
METASFRESH_DB_PORT=5432
METASFRESH_DB_NAME=metasfresh
METASFRESH_DB_USER=metasfresh
METASFRESH_DB_PASSWORD=

The values written here in this documentation are the defaults which the tool assumes if the respective value is missing.

By default, the tool will assume the settings file to be ~/local_settings.properties (i.e. usually /home/metasfresh/local_settings.properties). If you need to specify a different settings file, please run sql_remote.sh -h and check out the help message (-d and -s options).

Note: it might generally be a good idea to first run sql_remote.sh -h and take a look at the help message.

When the tool runs, it scans a directory for SQL files and applies those files that were not yet recorded in the AD_MigrationScript table of the metasfresh database.

Further reading and doing:


Zur Quelldatei auf github.com