Skip to content

Commit

Permalink
fix(doctrine): force sequence strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Mar 5, 2024
1 parent 5b4cd92 commit d8e8342
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion api/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ api_platform:
title: Hello API Platform
version: 1.0.0
# Mercure integration, remove if unwanted
mercure: ~
mercure:
include_type: true
formats:
jsonld: ['application/ld+json']
docs_formats:
Expand Down
4 changes: 2 additions & 2 deletions api/config/routes/annotations.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
controllers:
resource: ../../src/Controller/
type: annotation
type: attribute

kernel:
resource: ../../src/Kernel.php
type: annotation
type: attribute
34 changes: 34 additions & 0 deletions api/migrations/Version20240305143335.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240305143335 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP SEQUENCE greeting_id_seq CASCADE');
$this->addSql('CREATE SEQUENCE greeting_seq INCREMENT BY 100 MINVALUE 1 START 1');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE greeting_seq CASCADE');
$this->addSql('CREATE SEQUENCE greeting_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
}
}
3 changes: 2 additions & 1 deletion api/src/Entity/Greeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Greeting
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'SEQUENCE')]
#[ORM\SequenceGenerator(sequenceName: 'greeting_seq', initialValue: 1, allocationSize: 100)]
private ?int $id = null;

/**
Expand Down

0 comments on commit d8e8342

Please sign in to comment.