Use natural sorting for string datatables columns when using postgres

The natural sorting solution is quite portable, so this should be possible for other database types too later
This commit is contained in:
Jan Böhmer 2024-06-17 21:38:16 +02:00
parent 8a42dfa154
commit 9db822eabd
7 changed files with 86 additions and 11 deletions

View file

@ -24,6 +24,9 @@ final class Version20240606203053 extends AbstractMultiPlatformMigration impleme
public function postgreSQLUp(Schema $schema): void
{
//Create a collation for natural sorting
$this->addSql("CREATE COLLATION numeric (provider = icu, locale = 'en@colNumeric=yes');");
$this->addSql('CREATE TABLE api_tokens (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(255) NOT NULL, valid_until TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, token VARCHAR(68) NOT NULL, level SMALLINT NOT NULL, last_time_used TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, last_modified TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_2CAD560E5F37A13B ON api_tokens (token)');
$this->addSql('CREATE INDEX IDX_2CAD560EA76ED395 ON api_tokens (user_id)');