Schema Migration

280 views
Skip to first unread message

Navid Mitchell

unread,
Jan 6, 2012, 12:30:53 AM1/6/12
to redbeanphp
Hello,

I hope this is not a duplicate post. I am sure someone else must have
had this question, but I cannot find anything about it searching the
group.

What is the best way to handle Schema Migration as the project evolves
and you go through production releases?

Example:

I develop version 1 with freeze turned off. Then at the end of my
development cycle I change some flag to set freeze to on then I
release the application as production and deploy it to my customers
servers.

Then I start work on version 2. I turn freeze off and start making may
changes adding new data objects/changing existing one whatever.

Now I deploy version 2 to my customers. How do I handle making sure
all of their data is migrated properly prior to or after deploying the
product? Do I need to write SQL scripts to change the database to
reflect the new schema?

Thank you,
Navid Mitchell

gabor de mooij

unread,
Jan 6, 2012, 2:15:04 PM1/6/12
to redbe...@googlegroups.com

Hi, there is a tool for this:

http://www.redbeanphp.com/community/wiki/index.php/Syncing_databases
https://github.com/gabordemooij/redshoe

However I am planning to release a better version.


Navid Mitchell

--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To post to this group, send email to redbe...@googlegroups.com.
To unsubscribe from this group, send email to redbeanorm+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redbeanorm?hl=en.


Nikhil Lanjewar

unread,
Jun 19, 2013, 2:43:54 AM6/19/13
to redbe...@googlegroups.com
Hi,

I stumbled upon this email thread while looking for an effective database migration strategy with RedBean. Navid has pretty much summarized every bit of this use-case and I'm sure there are many others who are looking for an answer (I'd be glad if someone corrects me here with link to a solution).

The links provided by Gabor aren't working any more. Has the project 'redshoe' been moved somewhere else?

--
Nikhil

sah

unread,
Jun 20, 2013, 12:06:43 PM6/20/13
to redbe...@googlegroups.com
Hi,

you may log the schema changes with timeline http://redbeanphp.com/logging after every freeze cycle.

Knowing about redshow i do not.

Greetz,
Stephan

gabor

unread,
Jun 26, 2013, 1:58:03 PM6/26/13
to redbe...@googlegroups.com

Hi, there are two solutions for this:


1. For simple databases you can use R::syncSchema() (http://www.redbeanphp.com/multiple_databases) plugin from github, this syncs two RedBeanPHP databases, however this tool does not 'delete' columns.

2. If you want to do some 'manual' stuff and you also want to delete columns then I recommend to simply log your changes using TimeLine or the regular logger
and create some neat delta files yourself for proper migration. (http://www.redbeanphp.com/logging)

cheers,
Gabor

Kevin Lyda

unread,
Jan 8, 2016, 6:29:37 PM1/8/16
to redbeanphp
So 2.5 years later I'm looking at ORMs for a new project and the docs don't really seem to cover this. I'm not clear on the development lifecycle of a project using redbean.

Imaging a project over time I see it going like this:

v1-dev: rb set to fluid, code keeps changing.
v1: dev instances stay fluid but production is set to frozen.
v2-dev: same as v1-dev - rb is fluid in dev instances and schema changes keep getting done.
v2: and here I'm lost, how does production migrate to the new v2 schema in frozen mode?

Kevin

gabor

unread,
Jan 10, 2016, 7:51:01 AM1/10/16
to redbeanphp

Hi there,

This is not an ORM related problem, it's just about schema migration in general.
There are lots of wonderful schema migration tools out there, both commercial and open source.

Personally I like to do this stuff manually but a friend of mine uses https://www.red-gate.com/ for example.
You could also build a little migration tool using RedBeanPHP fluid mode if you like.

In the past RedBeanPHP offered schema migration helpers but I removed those because, like I said there are
tools that specialize in this kind of work and it seems beyond the scope of an ORM lib.

cheers
gabor

charlie

unread,
Jan 10, 2016, 10:55:58 AM1/10/16
to redbe...@googlegroups.com
Typically what I do is create a simple update script and run it fluid mode when deploying, then freeze it once the deploy is done.  But I realize that might not work for a lot of companies.

For MySQL there is mysqldiff : https://dev.mysql.com/doc/mysql-utilities/1.5/en/mysqldiff.html
And for MS SQL there is a tool call tablediff.exe : https://msdn.microsoft.com/en-us/library/ms162843.aspx

Cheers,
Charlie

--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redbeanorm+...@googlegroups.com.

To post to this group, send email to redbe...@googlegroups.com.



--
Thanks!
Charlie
Reply all
Reply to author
Forward
0 new messages