Part-DB-server/migrations/Version20260727143622.php
2026-07-27 17:46:18 +02:00

81 lines
3 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use App\Migration\AbstractMultiPlatformMigration;
use Doctrine\DBAL\Schema\Schema;
final class Version20260727143622 extends AbstractMultiPlatformMigration
{
public function getDescription(): string
{
return 'Add oauth_client_grant_preferences (per user+client OAuth2 consent preferences: granted scope level, friendly name, refresh token TTL)';
}
public function mySQLUp(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE oauth_client_grant_preferences (
id INT AUTO_INCREMENT NOT NULL,
user_identifier VARCHAR(128) NOT NULL,
client_identifier VARCHAR(32) NOT NULL,
scope_level SMALLINT NOT NULL,
friendly_name VARCHAR(255) DEFAULT NULL,
refresh_token_ttl_days INT DEFAULT NULL,
last_used_at DATETIME DEFAULT NULL,
UNIQUE INDEX oauth_client_grant_pref_user_client (user_identifier, client_identifier),
PRIMARY KEY (id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`
SQL);
}
public function mySQLDown(Schema $schema): void
{
$this->addSql('DROP TABLE oauth_client_grant_preferences');
}
public function sqLiteUp(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE oauth_client_grant_preferences (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
user_identifier VARCHAR(128) NOT NULL,
client_identifier VARCHAR(32) NOT NULL,
scope_level SMALLINT NOT NULL,
friendly_name VARCHAR(255) DEFAULT NULL,
refresh_token_ttl_days INTEGER DEFAULT NULL,
last_used_at DATETIME DEFAULT NULL
)
SQL);
$this->addSql('CREATE UNIQUE INDEX oauth_client_grant_pref_user_client ON oauth_client_grant_preferences (user_identifier, client_identifier)');
}
public function sqLiteDown(Schema $schema): void
{
$this->addSql('DROP TABLE oauth_client_grant_preferences');
}
public function postgreSQLUp(Schema $schema): void
{
$this->addSql(<<<'SQL'
CREATE TABLE oauth_client_grant_preferences (
id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
user_identifier VARCHAR(128) NOT NULL,
client_identifier VARCHAR(32) NOT NULL,
scope_level SMALLINT NOT NULL,
friendly_name VARCHAR(255) DEFAULT NULL,
refresh_token_ttl_days INT DEFAULT NULL,
last_used_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
PRIMARY KEY (id)
)
SQL);
$this->addSql('CREATE UNIQUE INDEX oauth_client_grant_pref_user_client ON oauth_client_grant_preferences (user_identifier, client_identifier)');
}
public function postgreSQLDown(Schema $schema): void
{
$this->addSql('DROP TABLE oauth_client_grant_preferences');
}
}