Discussion:
[Liquibase-user] is there any way in liquibase to alter a view
avinashC
2008-01-18 08:45:36 UTC
Permalink
Hello all,

i am a newbie to liquibase, i am using views(MySql) in my application. if i
want to modify any view is there any other way other than <dropView/> and
then <createView/>. coz how can i get my previous view, if at any point of
time i need any roll back for my view....?

and if i do like dropView and createView, my ant-db is failing...!

Any solution would be thankful and fruitful...


Thanks,
Avinash..
--
View this message in context: http://www.nabble.com/is-there-any-way-in-liquibase-to-alter-a-view-tp14947388p14947388.html
Sent from the LiquiBase - User mailing list archive at Nabble.com.
Nathan Voxland
2008-01-22 16:08:47 UTC
Permalink
Sorry for the slow reply. I'm just catching up on the mailing list
today.

You may want to use mysql's "create or replace view" syntax inside the
<sql> tag. That way you don't need to worry about the update failing if
you try to drop the view before it has been created.

Generally for views, I use the create or replace syntax and use the
"runOnChange" attribute on the <changeSet> tag so I can simply make the
necessary changes directly in the view definition and liquibase will run
the update only when I make changes. I can then more easily see what
has changed over time with my source control system's diff tools.

For rollback, however, you don't have automatic rollback support within
LiquiBase using the create or replace synax, but you don't get automatic
rollback support because of the dropView tag anyway. If I need to roll
back view definitions, I think the best way would be to use your source
controls rollback functionality on the definition then re-run the new
changelog file.

Does this help?

Nathan

-----Original Message-----
From: liquibase-user-***@lists.sourceforge.net
[mailto:liquibase-user-***@lists.sourceforge.net] On Behalf Of
avinashC
Sent: Friday, January 18, 2008 2:46 AM
To: liquibase-***@lists.sourceforge.net
Subject: [Liquibase-user] is there any way in liquibase to alter a view


Hello all,

i am a newbie to liquibase, i am using views(MySql) in my application.
if i
want to modify any view is there any other way other than <dropView/>
and
then <createView/>. coz how can i get my previous view, if at any point
of
time i need any roll back for my view....?

and if i do like dropView and createView, my ant-db is failing...!

Any solution would be thankful and fruitful...


Thanks,
Avinash..
--
View this message in context:
http://www.nabble.com/is-there-any-way-in-liquibase-to-alter-a-view-tp14
947388p14947388.html
Sent from the LiquiBase - User mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
DATACOM - Diego
2008-01-22 17:23:04 UTC
Permalink
Just for the sake of curiosity, how do you deal with the issue of
changeSet ordering when using the "runOnChange" attribute? Imagine that
some modification on the view is dependent on some other changeSet which
is run after the changeSet which is creating/updating the view.

Diego
Post by Nathan Voxland
Sorry for the slow reply. I'm just catching up on the mailing list
today.
You may want to use mysql's "create or replace view" syntax inside the
<sql> tag. That way you don't need to worry about the update failing if
you try to drop the view before it has been created.
Generally for views, I use the create or replace syntax and use the
"runOnChange" attribute on the <changeSet> tag so I can simply make the
necessary changes directly in the view definition and liquibase will run
the update only when I make changes. I can then more easily see what
has changed over time with my source control system's diff tools.
For rollback, however, you don't have automatic rollback support within
LiquiBase using the create or replace synax, but you don't get automatic
rollback support because of the dropView tag anyway. If I need to roll
back view definitions, I think the best way would be to use your source
controls rollback functionality on the definition then re-run the new
changelog file.
Does this help?
Nathan
-----Original Message-----
avinashC
Sent: Friday, January 18, 2008 2:46 AM
Subject: [Liquibase-user] is there any way in liquibase to alter a view
Hello all,
i am a newbie to liquibase, i am using views(MySql) in my application. if i
want to modify any view is there any other way other than <dropView/> and
then <createView/>. coz how can i get my previous view, if at any point of
time i need any roll back for my view....?
and if i do like dropView and createView, my ant-db is failing...!
Any solution would be thankful and fruitful...
Thanks,
Avinash..
Nathan Voxland
2008-01-22 17:40:13 UTC
Permalink
That is one issue I run into and don't have a great work-around
currently. We have an integration server that does a fresh database
build from our change sets each day so we are notified right away if we
introduce an update-breaking change. When that occurs then we create a
new change set with the new view definition which is kind of ugly but
works.

If you run into the issue a lot, or if you have a lot of views, you may
have better luck moving all your view definitions to the end of your
change log so the rest of the database is always updated completely
before the new view definitions are applied.

Nathan

-----Original Message-----
From: liquibase-user-***@lists.sourceforge.net
[mailto:liquibase-user-***@lists.sourceforge.net] On Behalf Of
DATACOM - Diego
Sent: Tuesday, January 22, 2008 11:23 AM
To: liquibase-***@lists.sourceforge.net
Subject: Re: [Liquibase-user] is there any way in liquibase to alter a
view

Just for the sake of curiosity, how do you deal with the issue of
changeSet ordering when using the "runOnChange" attribute? Imagine that
some modification on the view is dependent on some other changeSet which

is run after the changeSet which is creating/updating the view.

Diego
Post by Nathan Voxland
Sorry for the slow reply. I'm just catching up on the mailing list
today.
You may want to use mysql's "create or replace view" syntax inside the
<sql> tag. That way you don't need to worry about the update failing if
you try to drop the view before it has been created.
Generally for views, I use the create or replace syntax and use the
"runOnChange" attribute on the <changeSet> tag so I can simply make the
necessary changes directly in the view definition and liquibase will run
the update only when I make changes. I can then more easily see what
has changed over time with my source control system's diff tools.
For rollback, however, you don't have automatic rollback support within
LiquiBase using the create or replace synax, but you don't get
automatic
Post by Nathan Voxland
rollback support because of the dropView tag anyway. If I need to roll
back view definitions, I think the best way would be to use your source
controls rollback functionality on the definition then re-run the new
changelog file.
Does this help?
Nathan
-----Original Message-----
avinashC
Sent: Friday, January 18, 2008 2:46 AM
Subject: [Liquibase-user] is there any way in liquibase to alter a view
Hello all,
i am a newbie to liquibase, i am using views(MySql) in my application. if i
want to modify any view is there any other way other than <dropView/> and
then <createView/>. coz how can i get my previous view, if at any
point
Post by Nathan Voxland
of
time i need any roll back for my view....?
and if i do like dropView and createView, my ant-db is failing...!
Any solution would be thankful and fruitful...
Thanks,
Avinash..
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
DATACOM - Diego
2008-01-23 13:12:49 UTC
Permalink
Post by Nathan Voxland
That is one issue I run into and don't have a great work-around
currently. We have an integration server that does a fresh database
build from our change sets each day so we are notified right away if we
introduce an update-breaking change. When that occurs then we create a
new change set with the new view definition which is kind of ugly but
works.
Yes, very ugly indeed. Sometimes the change is made on the same
changeSet. Other times not.
Post by Nathan Voxland
If you run into the issue a lot, or if you have a lot of views, you may
have better luck moving all your view definitions to the end of your
change log so the rest of the database is always updated completely
before the new view definitions are applied.
Well, better luck maybe, but definitely that does not solve the problem.
You can think of a regular changeSet that depends on a view change or
even a view change that depends on another view. Since the views are
created/updated in the end, clearly more ordering issues may arise.

I really do not think it is worth breaking the Liquibase ordering
paradigm just to have all the changes to a view/stored-procedure in the
same file. It would be better to just drop the view/SP and create it
again in a regular changeSet. We should not count on luck when dealing
with this! ;-)

Diego

Loading...