Wednesday 15 August 2012

php - Syncronising MySQL database across multiple devices -



php - Syncronising MySQL database across multiple devices -

i utilize both desktop pc , laptop develop web applications.

both devices run on latest version of ubuntu apache2. maintain actual files synchronised via git have no way of keeping mysql database synchronised across both machines.

i wouldn't mind if have force changes manually, how git works, want work available on both machines wherever am.

does have ideas of solution this?

your database should thought of in few different parts. relational databases contain @ least

a schema (table definitions, constraints, etc.), application data, e.g. 1 table might contain list of country codes, and instance data, e.g. users have registered, or blog posts have been saved.

the first 2 of these part of application. must synchronized particular code revisions or else can conflicts. ideally, should somehow tracked in revision command scheme , committed alongside related source code.

a popular approach utilize schema migrations. track text files define migrations, each of can executed forwards (and backward), each of modifies database schema , / or application data.

for instance, particular migration might

create new table states, and pre-populate info table.

reversing migration simple deleting table.

there many libraries back upwards this, e.g. doctrine migrations (specific doctrine php library), or liquibase, language-agnostic.

one nice thing approach database schema doesn't limit revisions can work on. if makes sense create new branch old revision, run migrations point , start working. can utilize migration scripts on production server, though in general you'll want run them forwards there.

the instance info not part of application, , should not tracked in way. may take manually migrate info between instances, or may not. either way, migrations should modify user info remains consistent schema.

for instance, if migration splits table should move info old columns new table. reverse migration should move info new table old columns.

php sql git ubuntu synchronisation

No comments:

Post a Comment