Database tables not generating for package entities

Permalink
I'm developing a package and need database tables. I've created entities in the /src/Concrete/Entity folder, prefixed the models with Doctine comments and followed all possible variations following the docs onhttps://documentation.concrete5.org/developers/packages/custom-datab...

But no tables are generated. I finally just made a db.xml and placed it in the package folder and that does work but I prefer the models just 'working' and triggering the tables generation because now I have my tables defined in two places.

I'm developing for Concrete 5.8.2 and higher and running Concrete 5.8. Can anyone point me in the right direction? Once again; I tried all the possible variations mentioned on the url above and they don't work.

Justin1978
View Replies:
JohntheFish replied on at Permalink Reply
JohntheFish
The location for doctrine entities changed between 5.7 and v8. There is also some 'legacy' detection in v8 that can further confuse things.
Justin1978 replied on at Permalink Reply
Justin1978
Well, that's unfortunate. This is one of those things that needs to be documented properly. I'm basically stuck, tried everything. I'll have to write my own queries now.

I remember trying to get Doctrine to work a year ago and spent days trying and finally gave up. Compared to Eloquent ORM this is waaay to complicated.
surefyre replied on at Permalink Reply
surefyre
So /blocks/myblock/db.xml isn't correct any more?

I have a block in a package in V8.4.5 with db.xml and it's not creating the expected DB table. I diodn't even realise db.xml had changed format to Doctrine until I spotted a comment at the bottom of a blocks page which eventually led me to the Doctrine converter which says my current db.xml is valid. I pasted db.xml in below, basic stuff.

Wasting so much time on this I think I'll just require a page attribute instead for the apikey/URL fields, would take 10 mins to implement,

<?xml version="1.0" encoding="UTF-8"?>
<schema
        xmlns="http://www.concrete5.org/doctrine-xml/0.5"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.concrete5.org/doctrine-xml/0.5http://concrete5.github.io/doctrine-xml/doctrine-xml-0.5.xsd"...
>
    <table name="Pdhspmap">
        <field name="bID" type="integer">
            <unsigned></unsigned>
            <key></key>
        </field>
        <field name="gmapkey" type="string" size="255"></field>
        <field name="spurl" type="string" size="255"></field>
    </table>
</schema>
Justin1978 replied on at Permalink Reply
Justin1978
I finally figured it out. I was already writing my own queries an decided to give it one more try.

I had the @ORM annotation in my models but that is only supported from version 8 and I'm developing for 5.8.2. I didn't realize Concrete version 8 is actually really version 8; I thought they meant 5.8.
gstekelenburg replied on at Permalink Reply
Well, I'm using 8 and my entities aren't mapped at all... see screenshot for example entity, which are located at /concrete/package/package_name/src/Entity/....

What am I doing wrong here? Checked namespaces and everything dozen times... maybe im still drunk... but it doesn't show up in the database after refreshing entities.

<?php
namespace Concrete\Package\PackageName\Src\Entity;
defined('C5_EXECUTE') or die(_("Access Denied."));
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
 * @ORM\Entity
 * @ORM\Table(name="PackageNameArtist")
 */
class Artist extends Entity
{
    /**
     * @ORM\Column(type="string")
     */
    protected $name;