API throwing sequence does not exist error

Viewed 243

I have created an entity using doctrine ORM and synchronized the entity to the postgres database using the following command.

sudo /usr/local/bin/docker-compose exec php bin/console doctrine:schema:update --dump-sql

 The following SQL statements will be executed:

     CREATE SEQUENCE financial_statement_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
     CREATE SEQUENCE financial_statement_templates_fstemplate_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
     CREATE SEQUENCE financial_statement_templates_definition_fstemplate_definition_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
     CREATE TABLE financial_statement_type (id INT NOT NULL, fstype_short_code VARCHAR(9) NOT NULL, fstype_name VARCHAR(99) NOT NULL, fstype_created_by VARCHAR(9) NOT NULL, fstype_created_on TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id));
     CREATE TABLE financial_statement_templates (fstemplate_id INT NOT NULL, fstemplate_short_code VARCHAR(9) NOT NULL, fstemplate_name VARCHAR(99) NOT NULL, fstemplate_created_by VARCHAR(9) NOT NULL, fstemplate_created_on TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(fstemplate_id));
     CREATE TABLE financial_statement_templates_definition (fstemplate_definition_id INT NOT NULL, fstemplate_definition_type VARCHAR(9) NOT NULL, fstemplate_definition VARCHAR(5000) NOT NULL, fstemplate_created_by VARCHAR(9) NOT NULL, fstemplate_created_on TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(fstemplate_definition_id));

To create an entity using the API Platform page on the browser I provided the following data

{
  "financialStatementTypeShortCode": "BS",
  "financialStatementTypeName": "BALANCE SHEET",
  "financialStatementTypeCreatedBy": "000000001",
  "financialStatementTypeCreatedOn": "2020-12-04T10:06:30.672Z"
}

The opration throws an error(relevant portion reproduced)

  "type": "https://tools.ietf.org/html/rfc2616#section-10",
  "title": "An error occurred",
  "detail": "An exception occurred while executing 'SELECT NEXTVAL('financial_statement_type_id_seq')':\n\nSQLSTATE[42P01]: Undefined table: 7 ERROR:  relation \"financial_statement_type_id_seq\" does not exist\nLINE 1: SELECT NEXTVAL('financial_statement_type_id_seq')\n   

The message says that the financial_statement_type_id_seq sequence doesn't exist. However the schema update shows that the sequence was created. Is there anything I am missing? Is there a way to resolve this?

EDIT

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
// use Doctrine\Common\Collections\ArrayCollection;  Used in the documentation but not in the sample file

/**
 * FINANCIAL STATEMENT TYPE
 * Describes the type of Financial Statement
 * @ApiResource
 * @ORM\Entity
 */
class financial_statement_type
{
    /**
     * @var int A unique identifier for the balance sheet template
     *
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @var string A shortcode for the financial statement type e.g. BS – Balance Sheet IS – Income Statement
     *
     * @ORM\Column(type="string", length=9)
     * @Assert\NotBlank
     */
    private $fstype_ShortCode = '';

    /**
     * @var string A decriptive name for the financial statement
     *
     * @ORM\Column(type="string", length=99)
     * @Assert\NotBlank
     */
    private $fstype_Name = '';

    /**
     * @var string The userid of the person who created this template
     *
     * @ORM\Column(type="string", length=9)
     * @Assert\NotBlank
     */
    private $fstype_CreatedBy = '';
    /**
     * @var \DateTimeInterface The date and time this financial statement type was created on
     *
     * @ORM\Column(type="datetime")
     * @Assert\Type("\DateTimeInterface")
     * @Assert\NotBlank
     */
    private $fstype_CreatedOn = '';

    public function getfinancialStatementTypeId(): int
    {
        return $this->fstype_Id;
    }

(also contains the get and set functions- not reproduced here for brevity)

0 Answers
Related