A
A
AstonMartin2017-06-10 05:18:56
git
AstonMartin, 2017-06-10 05:18:56

Git flow development, tests and bases?

Good afternoon!
Tell me, please, on the nuances of the development and organization of the environment.
Now we are developing a small web project just in the master & dev branches, we want to switch to git flow and it is not clear what to do with the databases.
Let's say a developer starts working on a new feature, makes a branch for it in the git. The feature involves changing the structure of the database (changing / adding tables). Accordingly, the developer on his computer needs to create a new instance of the database for the development of this feature? Register it in configs and so on. And if several features are being sawn, then several databases are needed both at the developer and on the dev server? Windows developers on computers.
How is it customary to organize it with the least effort?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TyzhSysAdmin, 2017-06-10
@POS_troi

Exclude the db config from git (and add it to .gitignore) and leave only bd.config.example.
The developer copies example and prescribes his settings and this config will never get into the git.
Creates a copy of the database on the dev server and works on it (so as not to interfere with others), if everything is ok, then merges its changes into the main branch and, if necessary, adds new, possible, parameters to bd.config.example.
I don’t know how the creation of a database is arranged for you, whether you import the structure with your hands or use migration roofing felts, then think for yourself, if it’s developed by hand. also makes changes to the files with the structure.
PS Here, the use of Docker is just right.

E
Eugene, 2017-06-10
@immaculate

The question is difficult to answer without knowing what you are developing on. When I develop with Django, I have a package in each project settingswith three modules: production, development, and local. If development requires migrations that change the schema, I make a copy of the database (pg_dump | psql) with the appropriate names, and in local_settings I prescribe the name of the copy.
In one project where I have a lot of branches and it is important for the customer that they are all independent (he does a thorough code review for each and merges each one separately), I automated this process a little:

database = 'frobnicator'
branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('ascii').strip()
if branch.startswith('python-3'):
    database = 'frobnicator-python3-port'
elif branch == 'master' or branch.startswith('FB-472'):
    database = 'frobnicator-filestack-integration'
else:
    raise RuntimeError('Please, update configuration file to use correct database')

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': database,
        'USER': '',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question