Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare database for Doctrine DBAL 4 #4240

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DATABASE_URL=pgsql://symfony:symfony@database/symfony?serverVersion=14.9&charset

# Messenger configuration (for async tasks)
MESSENGER_TRANSPORT_DSN=sync://
MESSENGER_TRANSPORT_FAILED_DSN=doctrine://default?queue_name=failed
MESSENGER_TRANSPORT_FAILED_DSN=doctrine://default?queue_name=failed&auto_setup=false

# Mailer credentials
MAILER_DSN=smtp://mailer:1025
Expand Down
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ext-apcu": "*",
"a2lix/auto-form-bundle": "0.4.7",
"a2lix/translation-form-bundle": "3.2.4",
"doctrine/dbal": "3.9.3",
"doctrine/dbal": "4.2.1",
"doctrine/doctrine-bundle": "2.13.0",
"doctrine/doctrine-fixtures-bundle": "3.6.1",
"doctrine/doctrine-migrations-bundle": "3.3.1",
Expand Down Expand Up @@ -54,7 +54,6 @@
"symfony/twig-bundle": "7.1.5",
"symfony/ux-twig-component": "2.20.0",
"symfony/webpack-encore-bundle": "2.2.0",
"symfonycasts/reset-password-bundle": "1.22.0",
"twig/extra-bundle": "3.13.0",
"twig/string-extra": "3.13.0",
"twig/twig": "3.14.0",
Expand Down Expand Up @@ -84,9 +83,6 @@
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
Expand Down
94 changes: 21 additions & 73 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true],
SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'test' => true, 'staging' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true, 'staging' => true],
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
Expand Down
5 changes: 5 additions & 0 deletions config/packages/assets.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
framework:
assets:
json_manifest_path: "%kernel.project_dir%/public/build/manifest.json"

when@test:
framework:
assets:
json_manifest_path: null
8 changes: 3 additions & 5 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ doctrine:
dbal:
url: "%env(resolve:DATABASE_URL)%"
profiling_collect_backtrace: "%kernel.debug%"
use_savepoints: true
orm:
auto_generate_proxy_classes: true
controller_resolver:
Expand All @@ -10,6 +11,8 @@ doctrine:
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
identity_generation_preferences:
Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity
auto_mapping: true
mappings:
App:
Expand Down Expand Up @@ -37,8 +40,3 @@ when@prod:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system

when@test:
doctrine:
dbal:
use_savepoints: true
2 changes: 0 additions & 2 deletions config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ when@test:
test: true
session:
storage_factory_id: session.storage.factory.mock_file
assets:
json_manifest_path: null
2 changes: 0 additions & 2 deletions config/packages/reset_password.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions config/packages/web_profiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ when@dev:
framework:
profiler:
only_exceptions: false
collect_serializer_data: true

when@test:
web_profiler:
toolbar: false
intercept_redirects: false

framework:
profiler: { collect: false }
97 changes: 97 additions & 0 deletions migrations/Version20241022081700.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?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 Version20241022081700 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('ALTER TABLE basic_page ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE basic_page_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE book ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE book_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE category ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE category_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE contact ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE contact ALTER preferences TYPE TEXT');
$this->addSql('ALTER TABLE contact ALTER date TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('COMMENT ON COLUMN contact.preferences IS \'\'');
$this->addSql('COMMENT ON COLUMN contact.date IS \'\'');
$this->addSql('ALTER TABLE cookies_page ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE cookies_page_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE entity_meta_information ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE entity_meta_information_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE media__gallery_media ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE media__media ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE meta_information ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE meta_information_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE redirect ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE translation_translation ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE media__gallery ALTER id ADD GENERATED BY DEFAULT AS IDENTITY;');
$this->addSql('ALTER TABLE user__user ALTER id ADD GENERATED BY DEFAULT AS IDENTITY;');
$this->addSql('ALTER TABLE user__user ALTER roles TYPE JSON USING roles::json');
$this->addSql('COMMENT ON COLUMN user__user.roles IS \'\'');
$this->addSql('ALTER TABLE messenger_messages ALTER id DROP DEFAULT');
$this->addSql('ALTER TABLE messenger_messages ALTER id ADD GENERATED BY DEFAULT AS IDENTITY');
$this->addSql('ALTER TABLE messenger_messages ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE messenger_messages ALTER available_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE messenger_messages ALTER delivered_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE basic_page ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE entity_meta_information_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE book ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE category ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE basic_page_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE category_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE user__user ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE media__gallery ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE user__user ALTER roles TYPE TEXT');
$this->addSql('COMMENT ON COLUMN user__user.roles IS \'(DC2Type:array)\'');
$this->addSql('ALTER TABLE contact ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE contact ALTER preferences TYPE TEXT');
$this->addSql('ALTER TABLE contact ALTER date TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('COMMENT ON COLUMN contact.preferences IS \'(DC2Type:simple_array)\'');
$this->addSql('COMMENT ON COLUMN contact.date IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE media__gallery_media ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE book_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE cookies_page_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE messenger_messages ALTER id SET DEFAULT messenger_messages_id_seq');
$this->addSql('ALTER TABLE messenger_messages ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE messenger_messages ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE messenger_messages ALTER available_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE messenger_messages ALTER delivered_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE meta_information ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE meta_information_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE redirect ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE cookies_page ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE translation_translation ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE media__media ALTER id DROP IDENTITY');
$this->addSql('ALTER TABLE entity_meta_information ALTER id DROP IDENTITY');
}
}
4 changes: 2 additions & 2 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Sonata\UserBundle\Entity\BaseUser;
use Sonata\UserBundle\Entity\BaseUser3;

#[ORM\Entity]
#[ORM\Table(name: 'user__user')]
class User extends BaseUser
class User extends BaseUser3
{
#[ORM\Id]
#[ORM\GeneratedValue]
Expand Down
Loading
Loading