I am trying to use migrations for the first time on my in-development Propel project (so I don't have to re-insert 15MB of data), but am having some difficulties. I made the changes in my schema and ran propel-gen diff
. I first received an error that it couldn't locate my buildtime-conf.xml
file. I hadn't made one yet (since it wasn't necessary), but read that the structure should be the same as the runtime-conf.xml
. I copied runtime-conf.xml
to buildtime-conf.xml
. And now receive the following error:
[propel-sql-diff] Reading databases structure...
[phingcall] Unable to find adapter for datasource [project].
Execution of target "sql-diff" failed for the following reason: /var/www/project/vendor/propel/propel1/generator/build-propel.xml:317:26: Execution of the target buildfile failed. Aborting.
[phing] /var/www/project/vendor/propel/propel1/generator/build-propel.xml:317:26: Execution of the target buildfile failed. Aborting.
My runtime and buildtime files look like the following:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<propel>
<datasources default="project">
<datasource id="project">
<adapter>pgsql</adapter>
<connection>
<dsn>pgsql:host=###.###.###.###;dbname=database</dsn>
<user>USER</user>
<password>PASS</password>
</connection>
</datasource>
</datasources>
</propel>
</config>
My schema is along the lines of this:
<?xml version="1.0" encoding="UTF-8"?>
<database name="project" defaultIdMethod="native">
<table schema="accounts" name="accounts" phpName="Account" package="accounts">
<column />
</table>
</database>
I tried changing the buildtime-conf to <datasource id="testing">
and the error changed to Unable to find adapter for datasource [testing]
. So the error lies in the actual buildtime-conf file (not the schema), as far as I can tell. I thought maybe Propel couldn't find PostgreSQL's adapter (even though it works fine in my runtime-conf), so I tried changing my adapter to mysql
. It came up with the same unable to find adapter error.
I'm completely lost, thoughts?
Update: so I was able to go into /Propel/runtime/lib/Propel.php
and locate the line where the Unable to find adapter
exception was thrown. I manually defined the variable by adding the line self::$configuration['datasources'][$name]['adapter'] = 'pgsql'
and it works. This obviously isn't verify useful for now, as I won't be able to update Propel without redoing this change. I dumped self::$configuration
in Propel.php and it is NULL
, any ideas why?
Looks like switching a Composer dependency to dev-master
fixes this - there is 20 commits difference between the current release (1.7.1) and master, at the time of writing. The migrations patch specifically is here.
Hopefully a 1.7.2 release will be made in due course, though it should be noted that the team's development effort will likely be focussed on Propel2 at present (still in alpha).
In the latest stable version of Propel (1.7.1) it is inpossible to add the following code:
self::$configuration['datasources'][$name]['adapter'] = 'mysql';
Resulting in the following error:
Indirect modification of overloaded element of PropelConfiguration has no effect
That's why, if you have only one adapter you could use:
/*
if (!isset(self::$configuration['datasources'][$name]['adapter'])) {
throw new PropelException("Unable to find adapter for datasource [" . $name . "].");
}
*/
$db = DBAdapter::factory('mysql');
// register the adapter for this name
self::$adapterMap[$name] = $db;
This error happens only when using ./propel-gen diff. Still very strange. Hope they fix it soon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With