1 |
On Thu, Þíè 15, 2006 9:15 pm, Benjamin Blazke wrote: |
2 |
> Hi, |
3 |
> |
4 |
> I'm looking for a tool that given an existing (base) |
5 |
> database schema and an 'update patch' DDL .sql script |
6 |
> on input would produce a 'reverse' script that could |
7 |
> be used to undo the changes done by the patch. For |
8 |
> example: |
9 |
> |
10 |
> base.sql: |
11 |
> CREATE TABLE xxx (...); |
12 |
> |
13 |
> patch.sql: |
14 |
> CREATE TABLE yyy (...); |
15 |
> ALTER TABLE xxx ADD COLUMN aaa ...; |
16 |
> ALTER TABLE xxx CHANGE column bbb ... |
17 |
> |
18 |
> reverse.sql: |
19 |
> DROP TABLE yyy; |
20 |
> ALTER TABLE xxx DROP column aaa; |
21 |
> ALTER TABLE xxx CHANGE column bbb <get this from the |
22 |
> original base schema> |
23 |
> |
24 |
> The purpose of this exercise is to have a production |
25 |
> database (MySQL) server that needs to update its |
26 |
> schema once in a while to reflect the changes in the |
27 |
> related application without the need to recreate the |
28 |
> schema from scratch (and possibly losing data). The |
29 |
> reverse.sql script could be later used to rollback the |
30 |
> schema changes at any time, even rollback multiple |
31 |
> patches. |
32 |
> |
33 |
> How do people generally solve this? I'm sure this must |
34 |
> be a fairly common problem. |
35 |
> |
36 |
> Thanks. |
37 |
> |
38 |
> Ben |
39 |
> |
40 |
> |
41 |
> |
42 |
> __________________________________________________ |
43 |
> Do You Yahoo!? |
44 |
> Tired of spam? Yahoo! Mail has the best spam protection around |
45 |
> http://mail.yahoo.com |
46 |
> -- |
47 |
> gentoo-user@g.o mailing list |
48 |
> |
49 |
> |
50 |
|
51 |
If we're talking about a production system its very very bad idea to patch it directly. |
52 |
The right way is to have an offline mirror of the system where you apply the |
53 |
patches, test and only if they work fine, you apply the update on the production |
54 |
system. If the patches are not OK, you just roll them back, restore from a backup, |
55 |
or copy the live system over the offline one. |
56 |
|
57 |
-- |
58 |
Best regards, |
59 |
Daniel |
60 |
|
61 |
-- |
62 |
gentoo-user@g.o mailing list |