You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by D Tim Cummings <ti...@triptera.com.au> on 2014/03/22 07:42:01 UTC
How to use cayenne-migrations
I would like to try using cayenne-migrations to do database schema updates when my application starts but I am not sure how the cayenne sandbox works.
I have checked out cayenne-migrations
svn co http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
and then I tried to install it in my local maven repository
cd cayenne-migrations/
mvn clean install
But I get an error message
[ERROR] The project org.apache.cayenne:cayenne-migrations:3.2M1-SNAPSHOT (/Users/tim/temp/cayenne-migrations/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Could not find artifact org.apache.cayenne:cayenne-parent:pom:3.2M1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 4, column 10 -> [Help 2]
In the pom.xml I notice
<parent>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-parent</artifactId>
<version>3.2M1-SNAPSHOT</version>
</parent>
I changed the version to 3.2M1 and the build seems to get further. However, now I get the following error
[ERROR] Failed to execute goal on project cayenne-migrations: Could not resolve dependencies for project org.apache.cayenne:cayenne-migrations:jar:3.2M1: Failed to collect dependencies at org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,): No versions available for org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,) within specified range -> [Help 1]
In the pom.xml I notice
<dependency>
<groupId>org.apache.cayenne.unpublished</groupId>
<artifactId>cayenne-jdk1.5-unpublished</artifactId>
<version>[3.1,)</version>
</dependency>
What should I do next?
Tim
Re: How to use cayenne-migrations
Posted by D Tim Cummings <dt...@gmail.com>.
Thanks. I didn't think of that.
So now I am putting the migrations into my app.
1. I have worked out I need to change the Cayenne Model schema update strategy in cayenne-project.xml from
schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy"
to
schema-update-strategy="org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy"
Obviously I am new to Cayenne ;)
2. I added the generated Datamap0.java into my project. (I am using MySQL and found I need to keep catalog field blank for each dbentity in Cayenne Modeler or else there is a problem with index creation. I originally had the MySQL database name in the catalog field )
3. I added a method in my AppModule of my Tapestry project to run at startup to migrate to latest. Is this the correct way of getting domain?
@Startup
public static void initMigrateToLatest() {
try {
ServerRuntime sr = new ServerRuntime("cayenne-project.xml");
DataDomain domain = sr.getDataDomain();
new Migrator(domain.getDataNode("datanode"), Datamap0.class.getPackage().getName()).migrateToLatest();
} catch (SQLException e) {
throw new RuntimeException("Unable to migrate database to current version: " + e.getMessage(), e);
}
}
4. Now I am having a problem with auto_increment fields. For example I have a table called tbl_company. If it is created using Cayenne's CreateIfNoSchemaStrategy then it looks like this
mysql> describe tbl_company;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| date_cancel | datetime | YES | | NULL | |
| date_create | datetime | YES | | NULL | |
| id_company | int(11) | NO | PRI | NULL | auto_increment |
| str_company | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
If I create it using cayenne-migrations and Datamap0 it looks like this. (Note no auto_increment on id).
mysql> describe tbl_company;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| date_cancel | datetime | YES | | NULL | |
| date_create | datetime | YES | | NULL | |
| id_company | int(11) | NO | PRI | NULL | |
| str_company | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
My Datamap0 for this table is
MigrationTableNew tbl_company = db.createTable("tbl_company");
tbl_company.addTimestampColumn("date_cancel", 19);
tbl_company.addTimestampColumn("date_create", 19);
tbl_company.addIntegerColumn("id_company", MANDATORY, null);
tbl_company.addVarcharColumn("str_company", 255);
tbl_company.addPrimaryKey("id_company");
My datamap.map.xml for this table is (Note the isGenerated="true")
<db-entity name="tbl_company">
<db-attribute name="date_cancel" type="TIMESTAMP" length="19"/>
<db-attribute name="date_create" type="TIMESTAMP" length="19"/>
<db-attribute name="id_company" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
<db-attribute name="str_company" type="VARCHAR" length="255"/>
</db-entity>
So my question is, how do I get cayenne-migrations to create the auto_increment in MySQL.
Thanks
Tim
On 25 Mar 2014, at 0:11, John Huss <jo...@gmail.com> wrote:
> I usually run MigrationGenerator from eclipse. You can just create a new
> "Java Application" launch configuration for the project and enter
> "org.apache.cayenne.migration.MigrationGenerator" as the main class. And
> then on the arguments tab enter your cayenne project filename and the
> output directory. For example "cayenne-MyDomain.xml ." (dot for the
> current directory).
>
>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks Michael. I will have a look at flyway as well.
Tim
> On 25 Mar 2014, at 21:44, Michael Gentry <mg...@masslight.net> wrote:
>
> Hi Tim,
>
> I'm entering this conversation late and haven't used the migration feature
> of Cayenne before (outside of CreateIfNoSchemaStrategy for testing), but we
> *do* use automated migrations here with our Tapestry project using
> http://flywaydb.org/ (inside and outside of Cayenne/Tapestry).
>
> With Flyway, you create SQL scripts and/or Java-based migrations. You can
> run migrations/etc from Maven, the application, command-line, etc.
>
> For our project, we decided to always migrate outside of the application
> using Maven (more flexible that way, plus our application doesn't run with
> DB administrator privileges so it cannot create tables/etc), but have the
> application validate upon startup (and a symbol to be able to disable it on
> startup in an emergency):
>
> @Startup
> public void verifyDatabaseMigrations(@Symbol(FLYWAY_ENABLED) boolean
> flywayEnabled)
> {
> if (flywayEnabled)
> {
> DataContext context = DataContext.createDataContext();
> DataSource dataSource =
> context.getParentDataDomain().getNode("analytic").getDataSource();
> Flyway flyway = new Flyway();
>
> flyway.setDataSource(dataSource);
> flyway.validate();
> }
> }
>
> If the validate() call fails (the DB isn't current) an exception is thrown
> and the application fails to start. If you actually wanted the application
> to migrate, you could change validate() to migrate() and it would migrate
> all new SQL/Java migrations for you or throw an exception on failure.
>
> Not sure if this helps you or not, but thought I'd toss an alternative
> approach out for your consideration. If this interests you, I can answer
> more questions about it.
>
> mrg
>
>
>
> On Mon, Mar 24, 2014 at 11:21 PM, D Tim Cummings <ti...@triptera.com.au>wrote:
>
>> Thanks. I didn't think of that.
>>
>> So now I am putting the migrations into my app.
>>
>> 1. I have worked out I need to change the Cayenne Model schema update
>> strategy in cayenne-project.xml from
>>
>>
>> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy"
>>
>> to
>>
>>
>> schema-update-strategy="org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy"
>>
>> 2. I added the generated Datamap0.java into my project.
>>
>> 3. I added a method in my AppModule of my Tapestry project to run at
>> startup to migrate to latest. Is this the correct way of getting domain?
>>
>> @Startup
>> public static void initMigrateToLatest() {
>> try {
>> ServerRuntime sr = new ServerRuntime("cayenne-project.xml");
>> DataDomain domain = sr.getDataDomain();
>> new Migrator(domain.getDataNode("datanode"),
>> Datamap0.class.getPackage().getName()).migrateToLatest();
>> } catch (SQLException e) {
>> throw new RuntimeException("Unable to migrate database to current
>> version: " + e.getMessage(), e);
>> }
>> }
>>
>> 4. Now I am having a problem with auto_increment fields. For example I
>> have a table called tbl_company. If it is created using Cayenne's
>> CreateIfNoSchemaStrategy then it looks like this
>>
>> mysql> describe tbl_company;
>> +-------------+--------------+------+-----+---------+----------------+
>> | Field | Type | Null | Key | Default | Extra |
>> +-------------+--------------+------+-----+---------+----------------+
>> | date_cancel | datetime | YES | | NULL | |
>> | date_create | datetime | YES | | NULL | |
>> | id_company | int(11) | NO | PRI | NULL | auto_increment |
>> | str_company | varchar(255) | YES | | NULL | |
>> +-------------+--------------+------+-----+---------+----------------+
>>
>>
>> If I create it using cayenne-migrations and Datamap0 it looks like this.
>> (Note no auto_increment on id).
>>
>> mysql> describe tbl_company;
>> +-------------+--------------+------+-----+---------+-------+
>> | Field | Type | Null | Key | Default | Extra |
>> +-------------+--------------+------+-----+---------+-------+
>> | date_cancel | datetime | YES | | NULL | |
>> | date_create | datetime | YES | | NULL | |
>> | id_company | int(11) | NO | PRI | NULL | |
>> | str_company | varchar(255) | YES | | NULL | |
>> +-------------+--------------+------+-----+---------+-------+
>>
>>
>> My Datamap0 for this table is
>>
>> MigrationTableNew tbl_company = db.createTable("tbl_company");
>> tbl_company.addTimestampColumn("date_cancel", 19);
>> tbl_company.addTimestampColumn("date_create", 19);
>> tbl_company.addIntegerColumn("id_company", MANDATORY, null);
>> tbl_company.addVarcharColumn("str_company", 255);
>> tbl_company.addPrimaryKey("id_company");
>>
>>
>> My datamap.map.xml for this table is (Note the isGenerated="true")
>>
>> <db-entity name="tbl_company">
>> <db-attribute name="date_cancel" type="TIMESTAMP" length="19"/>
>> <db-attribute name="date_create" type="TIMESTAMP" length="19"/>
>>
>> <db-attribute name="id_company" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
>> <db-attribute name="str_company" type="VARCHAR" length="255"/>
>> </db-entity>
>>
>> So my question is, how do I get cayenne-migrations to create the
>> auto_increment in MySQL.
>>
>> Thanks
>>
>> Tim
>>
>> On 25 Mar 2014, at 0:11, John Huss <jo...@gmail.com> wrote:
>>
>> I usually run MigrationGenerator from eclipse. You can just create a new
>> "Java Application" launch configuration for the project and enter
>> "org.apache.cayenne.migration.MigrationGenerator" as the main class. And
>> then on the arguments tab enter your cayenne project filename and the
>> output directory. For example "cayenne-MyDomain.xml ." (dot for the
>> current directory).
>>
>>
>>
Re: How to use cayenne-migrations
Posted by Michael Gentry <mg...@masslight.net>.
Hi Tim,
I'm entering this conversation late and haven't used the migration feature
of Cayenne before (outside of CreateIfNoSchemaStrategy for testing), but we
*do* use automated migrations here with our Tapestry project using
http://flywaydb.org/ (inside and outside of Cayenne/Tapestry).
With Flyway, you create SQL scripts and/or Java-based migrations. You can
run migrations/etc from Maven, the application, command-line, etc.
For our project, we decided to always migrate outside of the application
using Maven (more flexible that way, plus our application doesn't run with
DB administrator privileges so it cannot create tables/etc), but have the
application validate upon startup (and a symbol to be able to disable it on
startup in an emergency):
@Startup
public void verifyDatabaseMigrations(@Symbol(FLYWAY_ENABLED) boolean
flywayEnabled)
{
if (flywayEnabled)
{
DataContext context = DataContext.createDataContext();
DataSource dataSource =
context.getParentDataDomain().getNode("analytic").getDataSource();
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.validate();
}
}
If the validate() call fails (the DB isn't current) an exception is thrown
and the application fails to start. If you actually wanted the application
to migrate, you could change validate() to migrate() and it would migrate
all new SQL/Java migrations for you or throw an exception on failure.
Not sure if this helps you or not, but thought I'd toss an alternative
approach out for your consideration. If this interests you, I can answer
more questions about it.
mrg
On Mon, Mar 24, 2014 at 11:21 PM, D Tim Cummings <ti...@triptera.com.au>wrote:
> Thanks. I didn't think of that.
>
> So now I am putting the migrations into my app.
>
> 1. I have worked out I need to change the Cayenne Model schema update
> strategy in cayenne-project.xml from
>
>
> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy"
>
> to
>
>
> schema-update-strategy="org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy"
>
> 2. I added the generated Datamap0.java into my project.
>
> 3. I added a method in my AppModule of my Tapestry project to run at
> startup to migrate to latest. Is this the correct way of getting domain?
>
> @Startup
> public static void initMigrateToLatest() {
> try {
> ServerRuntime sr = new ServerRuntime("cayenne-project.xml");
> DataDomain domain = sr.getDataDomain();
> new Migrator(domain.getDataNode("datanode"),
> Datamap0.class.getPackage().getName()).migrateToLatest();
> } catch (SQLException e) {
> throw new RuntimeException("Unable to migrate database to current
> version: " + e.getMessage(), e);
> }
> }
>
> 4. Now I am having a problem with auto_increment fields. For example I
> have a table called tbl_company. If it is created using Cayenne's
> CreateIfNoSchemaStrategy then it looks like this
>
> mysql> describe tbl_company;
> +-------------+--------------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-------------+--------------+------+-----+---------+----------------+
> | date_cancel | datetime | YES | | NULL | |
> | date_create | datetime | YES | | NULL | |
> | id_company | int(11) | NO | PRI | NULL | auto_increment |
> | str_company | varchar(255) | YES | | NULL | |
> +-------------+--------------+------+-----+---------+----------------+
>
>
> If I create it using cayenne-migrations and Datamap0 it looks like this.
> (Note no auto_increment on id).
>
> mysql> describe tbl_company;
> +-------------+--------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +-------------+--------------+------+-----+---------+-------+
> | date_cancel | datetime | YES | | NULL | |
> | date_create | datetime | YES | | NULL | |
> | id_company | int(11) | NO | PRI | NULL | |
> | str_company | varchar(255) | YES | | NULL | |
> +-------------+--------------+------+-----+---------+-------+
>
>
> My Datamap0 for this table is
>
> MigrationTableNew tbl_company = db.createTable("tbl_company");
> tbl_company.addTimestampColumn("date_cancel", 19);
> tbl_company.addTimestampColumn("date_create", 19);
> tbl_company.addIntegerColumn("id_company", MANDATORY, null);
> tbl_company.addVarcharColumn("str_company", 255);
> tbl_company.addPrimaryKey("id_company");
>
>
> My datamap.map.xml for this table is (Note the isGenerated="true")
>
> <db-entity name="tbl_company">
> <db-attribute name="date_cancel" type="TIMESTAMP" length="19"/>
> <db-attribute name="date_create" type="TIMESTAMP" length="19"/>
>
> <db-attribute name="id_company" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
> <db-attribute name="str_company" type="VARCHAR" length="255"/>
> </db-entity>
>
> So my question is, how do I get cayenne-migrations to create the
> auto_increment in MySQL.
>
> Thanks
>
> Tim
>
> On 25 Mar 2014, at 0:11, John Huss <jo...@gmail.com> wrote:
>
> I usually run MigrationGenerator from eclipse. You can just create a new
> "Java Application" launch configuration for the project and enter
> "org.apache.cayenne.migration.MigrationGenerator" as the main class. And
> then on the arguments tab enter your cayenne project filename and the
> output directory. For example "cayenne-MyDomain.xml ." (dot for the
> current directory).
>
>
>
Re: How to use cayenne-migrations
Posted by John Huss <jo...@gmail.com>.
On Mon, Mar 24, 2014 at 10:21 PM, D Tim Cummings <ti...@triptera.com.au>wrote:
> Thanks. I didn't think of that.
>
> So now I am putting the migrations into my app.
>
> 1. I have worked out I need to change the Cayenne Model schema update
> strategy in cayenne-project.xml from
>
>
> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy"
>
> to
>
>
> schema-update-strategy="org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy"
>
Yep
>
> 2. I added the generated Datamap0.java into my project.
>
> 3. I added a method in my AppModule of my Tapestry project to run at
> startup to migrate to latest. Is this the correct way of getting domain?
>
> @Startup
> public static void initMigrateToLatest() {
> try {
> ServerRuntime sr = new ServerRuntime("cayenne-project.xml");
> DataDomain domain = sr.getDataDomain();
> new Migrator(domain.getDataNode("datanode"),
> Datamap0.class.getPackage().getName()).migrateToLatest();
> } catch (SQLException e) {
> throw new RuntimeException("Unable to migrate database to current
> version: " + e.getMessage(), e);
> }
> }
>
If you are using CayenneFilter or similar you can just do this:
ServerRuntime localRuntime = (ServerRuntime) WebUtil.getCayenneRuntime(
servletContext);
>
> 4. Now I am having a problem with auto_increment fields. For example I
> have a table called tbl_company. If it is created using Cayenne's
> CreateIfNoSchemaStrategy then it looks like this
>
> mysql> describe tbl_company;
> +-------------+--------------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-------------+--------------+------+-----+---------+----------------+
> | date_cancel | datetime | YES | | NULL | |
> | date_create | datetime | YES | | NULL | |
> | id_company | int(11) | NO | PRI | NULL | auto_increment |
> | str_company | varchar(255) | YES | | NULL | |
> +-------------+--------------+------+-----+---------+----------------+
>
>
> If I create it using cayenne-migrations and Datamap0 it looks like this.
> (Note no auto_increment on id).
>
> mysql> describe tbl_company;
> +-------------+--------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +-------------+--------------+------+-----+---------+-------+
> | date_cancel | datetime | YES | | NULL | |
> | date_create | datetime | YES | | NULL | |
> | id_company | int(11) | NO | PRI | NULL | |
> | str_company | varchar(255) | YES | | NULL | |
> +-------------+--------------+------+-----+---------+-------+
>
>
> My Datamap0 for this table is
>
> MigrationTableNew tbl_company = db.createTable("tbl_company");
> tbl_company.addTimestampColumn("date_cancel", 19);
> tbl_company.addTimestampColumn("date_create", 19);
> tbl_company.addIntegerColumn("id_company", MANDATORY, null);
> tbl_company.addVarcharColumn("str_company", 255);
> tbl_company.addPrimaryKey("id_company");
>
>
> My datamap.map.xml for this table is (Note the isGenerated="true")
>
> <db-entity name="tbl_company">
> <db-attribute name="date_cancel" type="TIMESTAMP" length="19"/>
> <db-attribute name="date_create" type="TIMESTAMP" length="19"/>
>
> <db-attribute name="id_company" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
> <db-attribute name="str_company" type="VARCHAR" length="255"/>
> </db-entity>
>
> So my question is, how do I get cayenne-migrations to create the
> auto_increment in MySQL.
>
I'll have to look into that. You can do it manually by extending
SqlFileMigration and adding an sql file with the same name as your
migration class (YourClass.sql) with this content:
alter table tbl_company modify column id_company integer not nullauto_increment;
>
> Thanks
>
> Tim
>
> On 25 Mar 2014, at 0:11, John Huss <jo...@gmail.com> wrote:
>
> I usually run MigrationGenerator from eclipse. You can just create a new
> "Java Application" launch configuration for the project and enter
> "org.apache.cayenne.migration.MigrationGenerator" as the main class. And
> then on the arguments tab enter your cayenne project filename and the
> output directory. For example "cayenne-MyDomain.xml ." (dot for the
> current directory).
>
>
>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks. I didn't think of that.
So now I am putting the migrations into my app.
1. I have worked out I need to change the Cayenne Model schema update strategy in cayenne-project.xml from
schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy"
to
schema-update-strategy="org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy"
2. I added the generated Datamap0.java into my project.
3. I added a method in my AppModule of my Tapestry project to run at startup to migrate to latest. Is this the correct way of getting domain?
@Startup
public static void initMigrateToLatest() {
try {
ServerRuntime sr = new ServerRuntime("cayenne-project.xml");
DataDomain domain = sr.getDataDomain();
new Migrator(domain.getDataNode("datanode"), Datamap0.class.getPackage().getName()).migrateToLatest();
} catch (SQLException e) {
throw new RuntimeException("Unable to migrate database to current version: " + e.getMessage(), e);
}
}
4. Now I am having a problem with auto_increment fields. For example I have a table called tbl_company. If it is created using Cayenne's CreateIfNoSchemaStrategy then it looks like this
mysql> describe tbl_company;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| date_cancel | datetime | YES | | NULL | |
| date_create | datetime | YES | | NULL | |
| id_company | int(11) | NO | PRI | NULL | auto_increment |
| str_company | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
If I create it using cayenne-migrations and Datamap0 it looks like this. (Note no auto_increment on id).
mysql> describe tbl_company;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| date_cancel | datetime | YES | | NULL | |
| date_create | datetime | YES | | NULL | |
| id_company | int(11) | NO | PRI | NULL | |
| str_company | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
My Datamap0 for this table is
MigrationTableNew tbl_company = db.createTable("tbl_company");
tbl_company.addTimestampColumn("date_cancel", 19);
tbl_company.addTimestampColumn("date_create", 19);
tbl_company.addIntegerColumn("id_company", MANDATORY, null);
tbl_company.addVarcharColumn("str_company", 255);
tbl_company.addPrimaryKey("id_company");
My datamap.map.xml for this table is (Note the isGenerated="true")
<db-entity name="tbl_company">
<db-attribute name="date_cancel" type="TIMESTAMP" length="19"/>
<db-attribute name="date_create" type="TIMESTAMP" length="19"/>
<db-attribute name="id_company" type="INTEGER" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
<db-attribute name="str_company" type="VARCHAR" length="255"/>
</db-entity>
So my question is, how do I get cayenne-migrations to create the auto_increment in MySQL.
Thanks
Tim
On 25 Mar 2014, at 0:11, John Huss <jo...@gmail.com> wrote:
> I usually run MigrationGenerator from eclipse. You can just create a new
> "Java Application" launch configuration for the project and enter
> "org.apache.cayenne.migration.MigrationGenerator" as the main class. And
> then on the arguments tab enter your cayenne project filename and the
> output directory. For example "cayenne-MyDomain.xml ." (dot for the
> current directory).
>
Re: How to use cayenne-migrations
Posted by John Huss <jo...@gmail.com>.
I usually run MigrationGenerator from eclipse. You can just create a new
"Java Application" launch configuration for the project and enter
"org.apache.cayenne.migration.MigrationGenerator" as the main class. And
then on the arguments tab enter your cayenne project filename and the
output directory. For example "cayenne-MyDomain.xml ." (dot for the
current directory).
On Mon, Mar 24, 2014 at 12:22 AM, D Tim Cummings <ti...@triptera.com.au>wrote:
> It looks like the problem was me having a project called
> cayenne-migrations in my workspace directory. When I moved it out, the
> classpath issues were resolved. Solved the cayenne-di problem as well.
>
> So to summarise my procedure to generate initial migration for the benefit
> of others.
>
> 1. Checked out cayenne-migrations and installed in local mvn repository
>
> svn co http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
> cd cayenne-migrations/
> mvn clean install
> cd ..
>
>
> 2. create an empty tapestry 5.3.7 project called tapgen and an output
> folder to collect the generated class file
>
> mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org
> # I used all defaults apart from archetype=Tapestry 5 Quickstart Project,
> groupId mygroup, artifactId tapgen
> cd tapgen
> mkdir output
>
> 3. Add the following dependencies to pom.xml in tapgen
>
> <dependency>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-server</artifactId>
> <version>3.2M1</version>
> </dependency>
> <dependency>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-migrations</artifactId>
> <version>0.1</version>
> </dependency>
>
>
> 4. Copy my cayenne-project.xml and datamap.map.xml files into
> tapgen/src/main/resources/
>
> 5. Add code to src/main/java/mygroup/services/AppModule.java to do the
> generation at startup
>
> @org.apache.tapestry5.ioc.annotations.Startup
> public void doGenerate() {
> org.apache.cayenne.migration.MigrationGenerator gen = new
> org.apache.cayenne.migration.MigrationGenerator();
> gen.generateInitialMigration("cayenne-project.xml", "output");
> }
>
> 6. Run the tapestry app and file will be output to
> tapgen/output/Datamap0.java
>
> mvn jetty:run
>
> # ^C to stop when logs show generation complete
>
>
> I hope this is helpful to someone. :)
>
> Tim
>
> On 24 Mar 2014, at 14:06, D Tim Cummings <ti...@triptera.com.au> wrote:
>
> I worked out what the folder not a jar is. It is because I had
> cayenne-migrations open as a project in eclipse.
>
> However cayenne-migrations is still not on the classpath. I have compile
> errors in my code. When I do
>
> mvn eclipse:clean
> mvn eclipse:eclipse -DdownloadSources=true
> cat .classpath | grep cayenne
>
> All I get is
>
> <classpathentry kind="var"
> path="M2_REPO/org/apache/cayenne/cayenne-server/3.2M1/cayenne-server-3.2M1.jar"
> sourcepath="M2_REPO/org/apache/cayenne/cayenne-server/3.2M1/cayenne-server-3.2M1-sources.jar"/>
> <classpathentry kind="src" path="/cayenne-di"/>
>
> I think the cayenne-di is a mistake. In eclipse I get a build error saying
> project cayenne-di can not be found. I remove the project from the build
> path and error goes away.
>
> I would expect to see another line like the first for cayenne-migrations.
>
> Tim
>
>
>
>
> On 24 Mar 2014, at 11:12, D Tim Cummings <ti...@triptera.com.au> wrote:
>
>
> Another thing I find unusual is that when I add a maven dependency of
> cayenne-migrations to my tapestry app using the following
>
> <dependency>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-server</artifactId>
> <version>3.2M1</version>
> </dependency>
> <dependency>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-migrations</artifactId>
> <version>0.1</version>
> </dependency>
>
>
> then cayenne-migrations shows up as a folder not a jar in the dependency
> view of the pom, and it does not appear to be on the classpath.
>
> <Screen Shot 2014-03-24 at 10.57.35.png>
>
> I don't know what this means?
>
> Thanks
>
> Tim
>
>
>
>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
It looks like the problem was me having a project called cayenne-migrations in my workspace directory. When I moved it out, the classpath issues were resolved. Solved the cayenne-di problem as well.
So to summarise my procedure to generate initial migration for the benefit of others.
1. Checked out cayenne-migrations and installed in local mvn repository
svn co http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
cd cayenne-migrations/
mvn clean install
cd ..
2. create an empty tapestry 5.3.7 project called tapgen and an output folder to collect the generated class file
mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org
# I used all defaults apart from archetype=Tapestry 5 Quickstart Project, groupId mygroup, artifactId tapgen
cd tapgen
mkdir output
3. Add the following dependencies to pom.xml in tapgen
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>3.2M1</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-migrations</artifactId>
<version>0.1</version>
</dependency>
4. Copy my cayenne-project.xml and datamap.map.xml files into tapgen/src/main/resources/
5. Add code to src/main/java/mygroup/services/AppModule.java to do the generation at startup
@org.apache.tapestry5.ioc.annotations.Startup
public void doGenerate() {
org.apache.cayenne.migration.MigrationGenerator gen = new org.apache.cayenne.migration.MigrationGenerator();
gen.generateInitialMigration("cayenne-project.xml", "output");
}
6. Run the tapestry app and file will be output to tapgen/output/Datamap0.java
mvn jetty:run
# ^C to stop when logs show generation complete
I hope this is helpful to someone. :)
Tim
On 24 Mar 2014, at 14:06, D Tim Cummings <ti...@triptera.com.au> wrote:
> I worked out what the folder not a jar is. It is because I had cayenne-migrations open as a project in eclipse.
>
> However cayenne-migrations is still not on the classpath. I have compile errors in my code. When I do
>
> mvn eclipse:clean
> mvn eclipse:eclipse -DdownloadSources=true
> cat .classpath | grep cayenne
>
> All I get is
>
> <classpathentry kind="var" path="M2_REPO/org/apache/cayenne/cayenne-server/3.2M1/cayenne-server-3.2M1.jar" sourcepath="M2_REPO/org/apache/cayenne/cayenne-server/3.2M1/cayenne-server-3.2M1-sources.jar"/>
> <classpathentry kind="src" path="/cayenne-di"/>
>
> I think the cayenne-di is a mistake. In eclipse I get a build error saying project cayenne-di can not be found. I remove the project from the build path and error goes away.
>
> I would expect to see another line like the first for cayenne-migrations.
>
> Tim
>
>
>
>
> On 24 Mar 2014, at 11:12, D Tim Cummings <ti...@triptera.com.au> wrote:
>
>>
>> Another thing I find unusual is that when I add a maven dependency of cayenne-migrations to my tapestry app using the following
>>
>> <dependency>
>> <groupId>org.apache.cayenne</groupId>
>> <artifactId>cayenne-server</artifactId>
>> <version>3.2M1</version>
>> </dependency>
>> <dependency>
>> <groupId>org.apache.cayenne</groupId>
>> <artifactId>cayenne-migrations</artifactId>
>> <version>0.1</version>
>> </dependency>
>>
>>
>> then cayenne-migrations shows up as a folder not a jar in the dependency view of the pom, and it does not appear to be on the classpath.
>>
>> <Screen Shot 2014-03-24 at 10.57.35.png>
>>
>> I don't know what this means?
>>
>> Thanks
>>
>> Tim
>>
>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
I worked out what the folder not a jar is. It is because I had cayenne-migrations open as a project in eclipse.
However cayenne-migrations is still not on the classpath. I have compile errors in my code. When I do
mvn eclipse:clean
mvn eclipse:eclipse -DdownloadSources=true
cat .classpath | grep cayenne
All I get is
<classpathentry kind="var" path="M2_REPO/org/apache/cayenne/cayenne-server/3.2M1/cayenne-server-3.2M1.jar" sourcepath="M2_REPO/org/apache/cayenne/cayenne-server/3.2M1/cayenne-server-3.2M1-sources.jar"/>
<classpathentry kind="src" path="/cayenne-di"/>
I think the cayenne-di is a mistake. In eclipse I get a build error saying project cayenne-di can not be found. I remove the project from the build path and error goes away.
I would expect to see another line like the first for cayenne-migrations.
Tim
On 24 Mar 2014, at 11:12, D Tim Cummings <ti...@triptera.com.au> wrote:
>
> Another thing I find unusual is that when I add a maven dependency of cayenne-migrations to my tapestry app using the following
>
> <dependency>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-server</artifactId>
> <version>3.2M1</version>
> </dependency>
> <dependency>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-migrations</artifactId>
> <version>0.1</version>
> </dependency>
>
>
> then cayenne-migrations shows up as a folder not a jar in the dependency view of the pom, and it does not appear to be on the classpath.
>
> <Screen Shot 2014-03-24 at 10.57.35.png>
>
> I don't know what this means?
>
> Thanks
>
> Tim
>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
So I added a couple of extra jars to classpath
java -cp cayenne-migrations-0.1.jar:cayenne-server-3.2M1.jar:commons-logging-1.1.3.jar:commons-collections-3.2.1.jar org.apache.cayenne.migration.MigrationGenerator cayenne-project.xml .
and then got the following error.
Exception in thread "main" org.apache.cayenne.configuration.server.DataDomainLoadException: [v.3.2M1 Jul 07 2013 16:23:58] Configuration resource "cayenne-project.xml" is not found.
at org.apache.cayenne.configuration.server.DataDomainProvider.createAndInitDataDomain(DataDomainProvider.java:143)
at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:106)
at org.apache.cayenne.configuration.server.DataDomainProvider.get(DataDomainProvider.java:60)
at org.apache.cayenne.di.spi.CustomProvidersProvider.get(CustomProvidersProvider.java:38)
at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:103)
at org.apache.cayenne.configuration.server.ServerRuntime.getDataDomain(ServerRuntime.java:92)
at org.apache.cayenne.migration.MigrationGenerator.generateInitialMigration(MigrationGenerator.java:75)
at org.apache.cayenne.migration.MigrationGenerator.main(MigrationGenerator.java:58)
I had cayenne-project.xml and datamap.map.xml in the same folder I was running MigrationGenerator from.
Another thing I find unusual is that when I add a maven dependency of cayenne-migrations to my tapestry app using the following
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>3.2M1</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-migrations</artifactId>
<version>0.1</version>
</dependency>
then cayenne-migrations shows up as a folder not a jar in the dependency view of the pom, and it does not appear to be on the classpath.
I don't know what this means?
Thanks
Tim
On 24 Mar 2014, at 9:52, D Tim Cummings <ti...@triptera.com.au> wrote:
> What is the easiest way to run MigrationGenerator.
>
> I tried
>
> java -cp cayenne-migrations-0.1.jar org.apache.cayenne.migration.MigrationGenerator
>
> which gave me the usage instructions.
>
> Usage:
> java org.apache.cayenne.migration.MigrationGenerator <cayenne-Project.xml> <output-folder>
>
> I added the required arguments (with cayenne-migrations-0.1.jar and cayenne-project.xml in the same directory)
>
> java -cp cayenne-migrations-0.1.jar org.apache.cayenne.migration.MigrationGenerator cayenne-project.xml .
>
> but that gave me this error.
>
> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/cayenne/configuration/server/ServerRuntime
> at org.apache.cayenne.migration.MigrationGenerator.generateInitialMigration(MigrationGenerator.java:74)
> at org.apache.cayenne.migration.MigrationGenerator.main(MigrationGenerator.java:58)
> Caused by: java.lang.ClassNotFoundException: org.apache.cayenne.configuration.server.ServerRuntime
> ...
>
> So I added cayenne-server to the current directory and classpath and ran
>
> java -cp cayenne-migrations-0.1.jar:cayenne-server-3.2M1.jar org.apache.cayenne.migration.MigrationGenerator cayenne-project.xml .
>
> but got this error.
>
> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
> at org.apache.cayenne.configuration.server.DataDomainProvider.<clinit>(DataDomainProvider.java:62)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> at org.apache.cayenne.di.spi.ConstructorInjectingProvider.get(ConstructorInjectingProvider.java:164)
> at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
> at org.apache.cayenne.di.spi.CustomProvidersProvider.get(CustomProvidersProvider.java:38)
> at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
> at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
> at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:103)
> at org.apache.cayenne.configuration.server.ServerRuntime.getDataDomain(ServerRuntime.java:92)
> at org.apache.cayenne.migration.MigrationGenerator.generateInitialMigration(MigrationGenerator.java:75)
> at org.apache.cayenne.migration.MigrationGenerator.main(MigrationGenerator.java:58)
> Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
> ...
>
> I could keep finding jars for the classpath but figure there is an easier way. Thanks in advance
>
> Tim
>
>
> On 23 Mar 2014, at 0:42, John Huss <jo...@gmail.com> wrote:
>
>> Also, you should know that you can generate your initial migration from
>> your DataMap using MigrationGenerator. So take advantage of that.
>>
>>
>> On Sat, Mar 22, 2014 at 9:40 AM, John Huss <jo...@gmail.com> wrote:
>>
>>> Ah, sorry, the pom wasn't really right due to my lack of maven knowledge.
>>> If you update it should work now. Thanks!
>>>
>>>
>>> On Sat, Mar 22, 2014 at 1:42 AM, D Tim Cummings <ti...@triptera.com.au>wrote:
>>>
>>>> I would like to try using cayenne-migrations to do database schema
>>>> updates when my application starts but I am not sure how the cayenne
>>>> sandbox works.
>>>>
>>>> I have checked out cayenne-migrations
>>>>
>>>> svn co
>>>> http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
>>>>
>>>> and then I tried to install it in my local maven repository
>>>>
>>>> cd cayenne-migrations/
>>>> mvn clean install
>>>>
>>>> But I get an error message
>>>>
>>>> [ERROR] The project
>>>> org.apache.cayenne:cayenne-migrations:3.2M1-SNAPSHOT
>>>> (/Users/tim/temp/cayenne-migrations/pom.xml) has 1 error
>>>> [ERROR] Non-resolvable parent POM: Could not find artifact
>>>> org.apache.cayenne:cayenne-parent:pom:3.2M1-SNAPSHOT and
>>>> 'parent.relativePath' points at wrong local POM @ line 4, column 10 ->
>>>> [Help 2]
>>>>
>>>> In the pom.xml I notice
>>>>
>>>> <parent>
>>>> <groupId>org.apache.cayenne</groupId>
>>>> <artifactId>cayenne-parent</artifactId>
>>>> <version>3.2M1-SNAPSHOT</version>
>>>> </parent>
>>>>
>>>> I changed the version to 3.2M1 and the build seems to get further.
>>>> However, now I get the following error
>>>>
>>>> [ERROR] Failed to execute goal on project cayenne-migrations: Could not
>>>> resolve dependencies for project
>>>> org.apache.cayenne:cayenne-migrations:jar:3.2M1: Failed to collect
>>>> dependencies at
>>>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,): No
>>>> versions available for
>>>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,) within
>>>> specified range -> [Help 1]
>>>>
>>>> In the pom.xml I notice
>>>>
>>>> <dependency>
>>>> <groupId>org.apache.cayenne.unpublished</groupId>
>>>>
>>>> <artifactId>cayenne-jdk1.5-unpublished</artifactId>
>>>> <version>[3.1,)</version>
>>>> </dependency>
>>>>
>>>>
>>>> What should I do next?
>>>>
>>>> Tim
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
What is the easiest way to run MigrationGenerator.
I tried
java -cp cayenne-migrations-0.1.jar org.apache.cayenne.migration.MigrationGenerator
which gave me the usage instructions.
Usage:
java org.apache.cayenne.migration.MigrationGenerator <cayenne-Project.xml> <output-folder>
I added the required arguments (with cayenne-migrations-0.1.jar and cayenne-project.xml in the same directory)
java -cp cayenne-migrations-0.1.jar org.apache.cayenne.migration.MigrationGenerator cayenne-project.xml .
but that gave me this error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/cayenne/configuration/server/ServerRuntime
at org.apache.cayenne.migration.MigrationGenerator.generateInitialMigration(MigrationGenerator.java:74)
at org.apache.cayenne.migration.MigrationGenerator.main(MigrationGenerator.java:58)
Caused by: java.lang.ClassNotFoundException: org.apache.cayenne.configuration.server.ServerRuntime
...
So I added cayenne-server to the current directory and classpath and ran
java -cp cayenne-migrations-0.1.jar:cayenne-server-3.2M1.jar org.apache.cayenne.migration.MigrationGenerator cayenne-project.xml .
but got this error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.cayenne.configuration.server.DataDomainProvider.<clinit>(DataDomainProvider.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.apache.cayenne.di.spi.ConstructorInjectingProvider.get(ConstructorInjectingProvider.java:164)
at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
at org.apache.cayenne.di.spi.CustomProvidersProvider.get(CustomProvidersProvider.java:38)
at org.apache.cayenne.di.spi.FieldInjectingProvider.get(FieldInjectingProvider.java:42)
at org.apache.cayenne.di.spi.DefaultScopeProvider.get(DefaultScopeProvider.java:49)
at org.apache.cayenne.di.spi.DefaultInjector.getInstance(DefaultInjector.java:103)
at org.apache.cayenne.configuration.server.ServerRuntime.getDataDomain(ServerRuntime.java:92)
at org.apache.cayenne.migration.MigrationGenerator.generateInitialMigration(MigrationGenerator.java:75)
at org.apache.cayenne.migration.MigrationGenerator.main(MigrationGenerator.java:58)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
...
I could keep finding jars for the classpath but figure there is an easier way. Thanks in advance
Tim
On 23 Mar 2014, at 0:42, John Huss <jo...@gmail.com> wrote:
> Also, you should know that you can generate your initial migration from
> your DataMap using MigrationGenerator. So take advantage of that.
>
>
> On Sat, Mar 22, 2014 at 9:40 AM, John Huss <jo...@gmail.com> wrote:
>
>> Ah, sorry, the pom wasn't really right due to my lack of maven knowledge.
>> If you update it should work now. Thanks!
>>
>>
>> On Sat, Mar 22, 2014 at 1:42 AM, D Tim Cummings <ti...@triptera.com.au>wrote:
>>
>>> I would like to try using cayenne-migrations to do database schema
>>> updates when my application starts but I am not sure how the cayenne
>>> sandbox works.
>>>
>>> I have checked out cayenne-migrations
>>>
>>> svn co
>>> http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
>>>
>>> and then I tried to install it in my local maven repository
>>>
>>> cd cayenne-migrations/
>>> mvn clean install
>>>
>>> But I get an error message
>>>
>>> [ERROR] The project
>>> org.apache.cayenne:cayenne-migrations:3.2M1-SNAPSHOT
>>> (/Users/tim/temp/cayenne-migrations/pom.xml) has 1 error
>>> [ERROR] Non-resolvable parent POM: Could not find artifact
>>> org.apache.cayenne:cayenne-parent:pom:3.2M1-SNAPSHOT and
>>> 'parent.relativePath' points at wrong local POM @ line 4, column 10 ->
>>> [Help 2]
>>>
>>> In the pom.xml I notice
>>>
>>> <parent>
>>> <groupId>org.apache.cayenne</groupId>
>>> <artifactId>cayenne-parent</artifactId>
>>> <version>3.2M1-SNAPSHOT</version>
>>> </parent>
>>>
>>> I changed the version to 3.2M1 and the build seems to get further.
>>> However, now I get the following error
>>>
>>> [ERROR] Failed to execute goal on project cayenne-migrations: Could not
>>> resolve dependencies for project
>>> org.apache.cayenne:cayenne-migrations:jar:3.2M1: Failed to collect
>>> dependencies at
>>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,): No
>>> versions available for
>>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,) within
>>> specified range -> [Help 1]
>>>
>>> In the pom.xml I notice
>>>
>>> <dependency>
>>> <groupId>org.apache.cayenne.unpublished</groupId>
>>>
>>> <artifactId>cayenne-jdk1.5-unpublished</artifactId>
>>> <version>[3.1,)</version>
>>> </dependency>
>>>
>>>
>>> What should I do next?
>>>
>>> Tim
>>>
>>>
>>>
>>>
>>>
>>>
>>
Re: How to use cayenne-migrations
Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks John. It is building now. I will give MigrationGenerator a go also.
Tim
On 23 Mar 2014, at 0:42, John Huss <jo...@gmail.com> wrote:
> Also, you should know that you can generate your initial migration from
> your DataMap using MigrationGenerator. So take advantage of that.
>
>
> On Sat, Mar 22, 2014 at 9:40 AM, John Huss <jo...@gmail.com> wrote:
>
>> Ah, sorry, the pom wasn't really right due to my lack of maven knowledge.
>> If you update it should work now. Thanks!
>>
>>
>> On Sat, Mar 22, 2014 at 1:42 AM, D Tim Cummings <ti...@triptera.com.au>wrote:
>>
>>> I would like to try using cayenne-migrations to do database schema
>>> updates when my application starts but I am not sure how the cayenne
>>> sandbox works.
>>>
>>> I have checked out cayenne-migrations
>>>
>>> svn co
>>> http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
>>>
>>> and then I tried to install it in my local maven repository
>>>
>>> cd cayenne-migrations/
>>> mvn clean install
>>>
>>> But I get an error message
>>>
>>> [ERROR] The project
>>> org.apache.cayenne:cayenne-migrations:3.2M1-SNAPSHOT
>>> (/Users/tim/temp/cayenne-migrations/pom.xml) has 1 error
>>> [ERROR] Non-resolvable parent POM: Could not find artifact
>>> org.apache.cayenne:cayenne-parent:pom:3.2M1-SNAPSHOT and
>>> 'parent.relativePath' points at wrong local POM @ line 4, column 10 ->
>>> [Help 2]
>>>
>>> In the pom.xml I notice
>>>
>>> <parent>
>>> <groupId>org.apache.cayenne</groupId>
>>> <artifactId>cayenne-parent</artifactId>
>>> <version>3.2M1-SNAPSHOT</version>
>>> </parent>
>>>
>>> I changed the version to 3.2M1 and the build seems to get further.
>>> However, now I get the following error
>>>
>>> [ERROR] Failed to execute goal on project cayenne-migrations: Could not
>>> resolve dependencies for project
>>> org.apache.cayenne:cayenne-migrations:jar:3.2M1: Failed to collect
>>> dependencies at
>>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,): No
>>> versions available for
>>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,) within
>>> specified range -> [Help 1]
>>>
>>> In the pom.xml I notice
>>>
>>> <dependency>
>>> <groupId>org.apache.cayenne.unpublished</groupId>
>>>
>>> <artifactId>cayenne-jdk1.5-unpublished</artifactId>
>>> <version>[3.1,)</version>
>>> </dependency>
>>>
>>>
>>> What should I do next?
>>>
>>> Tim
>>>
>>>
>>>
>>>
>>>
>>>
>>
Re: How to use cayenne-migrations
Posted by John Huss <jo...@gmail.com>.
Also, you should know that you can generate your initial migration from
your DataMap using MigrationGenerator. So take advantage of that.
On Sat, Mar 22, 2014 at 9:40 AM, John Huss <jo...@gmail.com> wrote:
> Ah, sorry, the pom wasn't really right due to my lack of maven knowledge.
> If you update it should work now. Thanks!
>
>
> On Sat, Mar 22, 2014 at 1:42 AM, D Tim Cummings <ti...@triptera.com.au>wrote:
>
>> I would like to try using cayenne-migrations to do database schema
>> updates when my application starts but I am not sure how the cayenne
>> sandbox works.
>>
>> I have checked out cayenne-migrations
>>
>> svn co
>> http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
>>
>> and then I tried to install it in my local maven repository
>>
>> cd cayenne-migrations/
>> mvn clean install
>>
>> But I get an error message
>>
>> [ERROR] The project
>> org.apache.cayenne:cayenne-migrations:3.2M1-SNAPSHOT
>> (/Users/tim/temp/cayenne-migrations/pom.xml) has 1 error
>> [ERROR] Non-resolvable parent POM: Could not find artifact
>> org.apache.cayenne:cayenne-parent:pom:3.2M1-SNAPSHOT and
>> 'parent.relativePath' points at wrong local POM @ line 4, column 10 ->
>> [Help 2]
>>
>> In the pom.xml I notice
>>
>> <parent>
>> <groupId>org.apache.cayenne</groupId>
>> <artifactId>cayenne-parent</artifactId>
>> <version>3.2M1-SNAPSHOT</version>
>> </parent>
>>
>> I changed the version to 3.2M1 and the build seems to get further.
>> However, now I get the following error
>>
>> [ERROR] Failed to execute goal on project cayenne-migrations: Could not
>> resolve dependencies for project
>> org.apache.cayenne:cayenne-migrations:jar:3.2M1: Failed to collect
>> dependencies at
>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,): No
>> versions available for
>> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,) within
>> specified range -> [Help 1]
>>
>> In the pom.xml I notice
>>
>> <dependency>
>> <groupId>org.apache.cayenne.unpublished</groupId>
>>
>> <artifactId>cayenne-jdk1.5-unpublished</artifactId>
>> <version>[3.1,)</version>
>> </dependency>
>>
>>
>> What should I do next?
>>
>> Tim
>>
>>
>>
>>
>>
>>
>
Re: How to use cayenne-migrations
Posted by John Huss <jo...@gmail.com>.
Ah, sorry, the pom wasn't really right due to my lack of maven knowledge.
If you update it should work now. Thanks!
On Sat, Mar 22, 2014 at 1:42 AM, D Tim Cummings <ti...@triptera.com.au> wrote:
> I would like to try using cayenne-migrations to do database schema updates
> when my application starts but I am not sure how the cayenne sandbox works.
>
> I have checked out cayenne-migrations
>
> svn co http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-migrations/
>
> and then I tried to install it in my local maven repository
>
> cd cayenne-migrations/
> mvn clean install
>
> But I get an error message
>
> [ERROR] The project org.apache.cayenne:cayenne-migrations:3.2M1-SNAPSHOT
> (/Users/tim/temp/cayenne-migrations/pom.xml) has 1 error
> [ERROR] Non-resolvable parent POM: Could not find artifact
> org.apache.cayenne:cayenne-parent:pom:3.2M1-SNAPSHOT and
> 'parent.relativePath' points at wrong local POM @ line 4, column 10 ->
> [Help 2]
>
> In the pom.xml I notice
>
> <parent>
> <groupId>org.apache.cayenne</groupId>
> <artifactId>cayenne-parent</artifactId>
> <version>3.2M1-SNAPSHOT</version>
> </parent>
>
> I changed the version to 3.2M1 and the build seems to get further.
> However, now I get the following error
>
> [ERROR] Failed to execute goal on project cayenne-migrations: Could not
> resolve dependencies for project
> org.apache.cayenne:cayenne-migrations:jar:3.2M1: Failed to collect
> dependencies at
> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,): No
> versions available for
> org.apache.cayenne.unpublished:cayenne-jdk1.5-unpublished:jar:[3.1,) within
> specified range -> [Help 1]
>
> In the pom.xml I notice
>
> <dependency>
> <groupId>org.apache.cayenne.unpublished</groupId>
> <artifactId>cayenne-jdk1.5-unpublished</artifactId>
> <version>[3.1,)</version>
> </dependency>
>
>
> What should I do next?
>
> Tim
>
>
>
>
>
>