updating - merge design of mysql between localhost and server? -
i'm kinda new kind of problem. i'm developing web-app , changing db design trying improve , add new tables. since had not published app since days ago, dump tables in server , import local version we've passed version 1 , users starting use it. can't dump server, still need update design of server db when want publish new version. best practices here?
- i know how can manage differences between local , server in mysql?
- i need preserve data in server , change design, data on local db test.
- before other apps small , change single table or column can't keep track of changes now, since might revert many of them later , managing team members on impossible.
assuming not using framework provides migration tool database, need keep track of changes manually.
- create folder
sql_upgrades
(or whatever name name) in code repository - whenever team member updates sql schema, creates file in folder corresponding
alter
statements, , possiblyupdate
,create table
etc. file contains statements used update dev database. - name files it's easy manage, , statements same feature grouped together. suggest
yyyymmdd-description.sql
, e.g.20150825-queries-for-feature-foobar.sql
- when push production, execute files upgrade sql schema in production. execute files have been created since last deployment, , execute them in order have been created.
- should need rollback file, check queries contains, , write queries undo done (drop added columns, re-create dropped columns, etc.). note "non-trivial", many changes cannot rolled (e.g. can recreate dropped column, have lost data inside).
many web frameworks (such ruby of rails) have tools process you. work orm provided framework. keeping track of changes manually in sql works well.
Comments
Post a Comment