Accessing properties from changes

View: New views
4 Messages — Rating Filter:   Alert me  

Accessing properties from changes

by Carlos Phillips :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I would like to be able to perform database object path mapping within  
SQLFileChange. Say I have an SQL file with the following query:

SELECT * FROM main_db.schem.addresses

I would like to use properties to create mappings for database object  
paths. Such a mapping could be placed in the liquibase properties as  
follows.

#liquibase.properties
database. main_db: local_db

The sql loaded would then be converted to the following query.

SELECT * FROM local_db.schem.addresses

This would be particularly helpful for distributed, sandboxed database  
development.  I would of course like to implement this with least  
amount of refactoring possible. The problem I run into is that  
instances of Change do not seem to
have access to liquibase properties. I want the properties to be  
applied to all instances of SQLFileChange with some "mapSQLObjects"  
flag set to true, so placing the required properties into each sqlFile  
tag is not convenient.

Would there be any real disadvantage to making the Liquibase class a  
singleton? Is there another way to get at the properties from changes?

Thank you for your help.

Carlos Phillips

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Liquibase-devel mailing list
Liquibase-devel@...
https://lists.sourceforge.net/lists/listinfo/liquibase-devel

Re: Accessing properties from changes

by Voxland, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think change log parameters are what you are looking for:
http://www.liquibase.org/manual/changelog_parameters

You would create your changeset as:
<sql>SELECT * FROM ${main_db}.schem.addresses</sql>

And then you would pass the main.db value to liquibase via your ant,
maven, etc, script.

Nathan

-----Original Message-----
From: Carlos Phillips [mailto:carlos.e.phillips@...]
Sent: Monday, March 16, 2009 4:10 PM
To: liquibase-devel@...
Subject: [Liquibase-devel] Accessing properties from changes

Hello,

I would like to be able to perform database object path mapping within  
SQLFileChange. Say I have an SQL file with the following query:

SELECT * FROM main_db.schem.addresses

I would like to use properties to create mappings for database object  
paths. Such a mapping could be placed in the liquibase properties as  
follows.

#liquibase.properties
database. main_db: local_db

The sql loaded would then be converted to the following query.

SELECT * FROM local_db.schem.addresses

This would be particularly helpful for distributed, sandboxed database  
development.  I would of course like to implement this with least  
amount of refactoring possible. The problem I run into is that  
instances of Change do not seem to
have access to liquibase properties. I want the properties to be  
applied to all instances of SQLFileChange with some "mapSQLObjects"  
flag set to true, so placing the required properties into each sqlFile  
tag is not convenient.

Would there be any real disadvantage to making the Liquibase class a  
singleton? Is there another way to get at the properties from changes?

Thank you for your help.

Carlos Phillips

------------------------------------------------------------------------
------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based
development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Liquibase-devel mailing list
Liquibase-devel@...
https://lists.sourceforge.net/lists/listinfo/liquibase-devel

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Liquibase-devel mailing list
Liquibase-devel@...
https://lists.sourceforge.net/lists/listinfo/liquibase-devel

Re: Accessing properties from changes

by Carlos Phillips :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for the response. Unfortunately, I do not believe that I was  
clear. I am aware of change log parameters. They are, however, not  
passed along to changes during execution. I wish to add search and  
replace functionality to SQLFileChange that specifically replaces the  
database part of database object paths. I wanted to know whether the  
parameters are available when changes are executed. After looking  
through the code, it seems that they are not. It would be useful to  
have, for example, the following invocation called on implementations  
of Change.

public void executeStatements(Database database, List<SqlVisitor>  
sqlVisitors, Map<String, Object> changeLogParameters)

This way changes could use parameters as they see fit. I can of course  
make these changes myself. First, I wanted to make sure that there  
isn't another easier way that I am missing. Note that I absolutely  
must use .sql files.

Carlos

On 17-Mar-09, at 6:09 PM, Voxland, Nathan wrote:

> I think change log parameters are what you are looking for:
> http://www.liquibase.org/manual/changelog_parameters
>
> You would create your changeset as:
> <sql>SELECT * FROM ${main_db}.schem.addresses</sql>
>
> And then you would pass the main.db value to liquibase via your ant,
> maven, etc, script.
>
> Nathan
>
> -----Original Message-----
> From: Carlos Phillips [mailto:carlos.e.phillips@...]
> Sent: Monday, March 16, 2009 4:10 PM
> To: liquibase-devel@...
> Subject: [Liquibase-devel] Accessing properties from changes
>
> Hello,
>
> I would like to be able to perform database object path mapping within
> SQLFileChange. Say I have an SQL file with the following query:
>
> SELECT * FROM main_db.schem.addresses
>
> I would like to use properties to create mappings for database object
> paths. Such a mapping could be placed in the liquibase properties as
> follows.
>
> #liquibase.properties
> database. main_db: local_db
>
> The sql loaded would then be converted to the following query.
>
> SELECT * FROM local_db.schem.addresses
>
> This would be particularly helpful for distributed, sandboxed database
> development.  I would of course like to implement this with least
> amount of refactoring possible. The problem I run into is that
> instances of Change do not seem to
> have access to liquibase properties. I want the properties to be
> applied to all instances of SQLFileChange with some "mapSQLObjects"
> flag set to true, so placing the required properties into each sqlFile
> tag is not convenient.
>
> Would there be any real disadvantage to making the Liquibase class a
> singleton? Is there another way to get at the properties from changes?
>
> Thank you for your help.
>
> Carlos Phillips
>
> ------------------------------------------------------------------------
> ------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM)  
> are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly  
> and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based
> development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Liquibase-devel mailing list
> Liquibase-devel@...
> https://lists.sourceforge.net/lists/listinfo/liquibase-devel
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM)  
> are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly  
> and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based  
> development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Liquibase-devel mailing list
> Liquibase-devel@...
> https://lists.sourceforge.net/lists/listinfo/liquibase-devel


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Liquibase-devel mailing list
Liquibase-devel@...
https://lists.sourceforge.net/lists/listinfo/liquibase-devel

Re: Accessing properties from changes

by Voxland, Nathan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I see what you mean now.  I think you are right that they are not  
passed. It is a good idea, if you want to submit a patch I can add it  
to the codebase.  Otherwise I can look into adding it for 1.10.

Nathan



On Mar 17, 2009, at 5:46 PM, "Carlos Phillips" <carlos.e.phillips@...
 > wrote:

> Thank you for the response. Unfortunately, I do not believe that I was
> clear. I am aware of change log parameters. They are, however, not
> passed along to changes during execution. I wish to add search and
> replace functionality to SQLFileChange that specifically replaces the
> database part of database object paths. I wanted to know whether the
> parameters are available when changes are executed. After looking
> through the code, it seems that they are not. It would be useful to
> have, for example, the following invocation called on implementations
> of Change.
>
> public void executeStatements(Database database, List<SqlVisitor>
> sqlVisitors, Map<String, Object> changeLogParameters)
>
> This way changes could use parameters as they see fit. I can of course
> make these changes myself. First, I wanted to make sure that there
> isn't another easier way that I am missing. Note that I absolutely
> must use .sql files.
>
> Carlos
>
> On 17-Mar-09, at 6:09 PM, Voxland, Nathan wrote:
>
>> I think change log parameters are what you are looking for:
>> http://www.liquibase.org/manual/changelog_parameters
>>
>> You would create your changeset as:
>> <sql>SELECT * FROM ${main_db}.schem.addresses</sql>
>>
>> And then you would pass the main.db value to liquibase via your ant,
>> maven, etc, script.
>>
>> Nathan
>>
>> -----Original Message-----
>> From: Carlos Phillips [mailto:carlos.e.phillips@...]
>> Sent: Monday, March 16, 2009 4:10 PM
>> To: liquibase-devel@...
>> Subject: [Liquibase-devel] Accessing properties from changes
>>
>> Hello,
>>
>> I would like to be able to perform database object path mapping  
>> within
>> SQLFileChange. Say I have an SQL file with the following query:
>>
>> SELECT * FROM main_db.schem.addresses
>>
>> I would like to use properties to create mappings for database object
>> paths. Such a mapping could be placed in the liquibase properties as
>> follows.
>>
>> #liquibase.properties
>> database. main_db: local_db
>>
>> The sql loaded would then be converted to the following query.
>>
>> SELECT * FROM local_db.schem.addresses
>>
>> This would be particularly helpful for distributed, sandboxed  
>> database
>> development.  I would of course like to implement this with least
>> amount of refactoring possible. The problem I run into is that
>> instances of Change do not seem to
>> have access to liquibase properties. I want the properties to be
>> applied to all instances of SQLFileChange with some "mapSQLObjects"
>> flag set to true, so placing the required properties into each  
>> sqlFile
>> tag is not convenient.
>>
>> Would there be any real disadvantage to making the Liquibase class a
>> singleton? Is there another way to get at the properties from  
>> changes?
>>
>> Thank you for your help.
>>
>> Carlos Phillips
>>
>> ---
>> ---------------------------------------------------------------------
>> ------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM)
>> are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly
>> and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based
>> development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Liquibase-devel mailing list
>> Liquibase-devel@...
>> https://lists.sourceforge.net/lists/listinfo/liquibase-devel
>>
>> ---
>> ---
>> ---
>> ---------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM)
>> are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly
>> and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based
>> development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Liquibase-devel mailing list
>> Liquibase-devel@...
>> https://lists.sourceforge.net/lists/listinfo/liquibase-devel
>
>
> ---
> ---
> ---
> ---------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM)  
> are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly  
> and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based  
> development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Liquibase-devel mailing list
> Liquibase-devel@...
> https://lists.sourceforge.net/lists/listinfo/liquibase-devel

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Liquibase-devel mailing list
Liquibase-devel@...
https://lists.sourceforge.net/lists/listinfo/liquibase-devel