Versionable don't uses all the required namespaces for foreign tables #294

Closed
alphalemon opened this Issue Feb 14, 2012 · 6 comments

Comments

Projects
None yet
3 participants

Hello,
as exposed for the Archiviable behavior (issue #293), I've got similar problems with the versionable behavior too. In this case it seems that the builder has not declared the foreign versionable peer and queries. I've got a schema like the one below:

<table name="al_content">
    <column name="id" type="INTEGER" required="true" autoIncrement="true" primaryKey="true" />
    <column name="page_id" type="INTEGER" required="true" />
    <foreign-key foreignTable="al_page" onDelete="CASCADE">
      <reference local="page_id" foreign="id" />
    </foreign-key>
    [...]
  </table>

  <table name="al_page" idMethod="native">
    <column name="id" type="INTEGER" required="true" autoIncrement="true" primaryKey="true" />
    <column name="page_name" type="VARCHAR" size="255" required="true" />
    [..]
  </table>

The behavior works fine until I try to restore from a previous version, because some namespaces are not declared:

use AlphaLemon\AlphaLemonCmsBundle\Model\AlContentVersionPeer;
use AlphaLemon\AlphaLemonCmsBundle\Model\AlContentVersionQuery;

@fzaninotto fzaninotto added a commit to fzaninotto/Propel that referenced this issue Feb 14, 2012

@fzaninotto fzaninotto Add missing namespace declarations in versionable behavior.
Closes #294.
1f46f36
Member

fzaninotto commented Feb 14, 2012

@alphalemon The attached PR should fix the problem. Would you mind testing it?

Hi Francois,
thank you for the fix. I did some tests and at the moment I've still got errors. Tomorrow I would like to make other tests starting from the scratch. I'll let you know

fzaninotto reopened this Feb 15, 2012

Member

fzaninotto commented Feb 15, 2012

Could you paste the errors you get?

Hello,
yesterday I tried on the database that manages my website, which has not been started with versionable behavior. So I write down a script to try to populate the derived versionable tables from my schema, but it seems that something is wrong because I got some errors noticed in the previous comment.

Today I started from a fresh install of my cms, adding the versionable behavior before installing the database and building the model using the lastest propel master branch, and everything was fine. The built model has all its dependencies, and I could have added some records and return back to previous version. So thank you for the very quick fix!

I take advantage from this discussion to ask you if there are some already existing propel features that could help me to add versionable records on a database created before adding this awesome behavior.

Owner

willdurand commented Feb 15, 2012

Hi @alphalemon, thanks for your feedback.

You should ask your question on the Propel mailing-list, I'm not sure there are existing stuffs for that, but people may have done that for their own needs.

willdurand closed this Feb 15, 2012

Hello,
playing with versionable, I noticed that a namespace still misses. Following the documentation, I used this code:

$page = AlPageQuery::create()->findPk(75);
$page->toVersion(1);
foreach ($page->getAllVersions() as $pageVersion) {
echo $pageVersion->getPageName() . "
";
}

and this is the error I get:

Fatal error: Class 'AlphaLemon\AlphaLemonCmsBundle\Model\om\AlPageVersionPeer' not found in /home/alphalemon/www/alphaLemon/vendor/bundles/AlphaLemon/AlphaLemonCmsBundle/Model/om/BaseAlPage.php on line 2116 Call Stack: 0.0004 335492 1.

Adding the namespace manually fixes the problem.
Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment