-
-
Save dbrkv/297097727ec3655db549cbe6fa9cac5b to your computer and use it in GitHub Desktop.
Symfony Doctrine support for timescaledb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Domain\Doctrine\DBAL\Platforms; | |
| use Doctrine\DBAL\Platforms\PostgreSQL100Platform as PostgreSqlPlatformBase; | |
| class PostgreSqlPlatform extends PostgreSqlPlatformBase | |
| { | |
| /** | |
| * {@inheritDoc} | |
| */ | |
| public function getListNamespacesSQL() | |
| { | |
| return "SELECT schema_name AS nspname | |
| FROM information_schema.schemata | |
| WHERE schema_name NOT LIKE 'pg\_%' | |
| AND schema_name NOT LIKE '%timescaledb%' | |
| AND schema_name != 'information_schema'"; | |
| } | |
| public function getListSequencesSQL($database) : string | |
| { | |
| return 'SELECT sequence_name AS relname, | |
| sequence_schema AS schemaname, | |
| minimum_value AS min_value, | |
| increment AS increment_by | |
| FROM information_schema.sequences | |
| WHERE sequence_catalog = ' . $this->quoteStringLiteral($database) . " | |
| AND sequence_schema NOT LIKE 'pg\_%' | |
| AND sequence_schema NOT LIKE '%timescaledb\_%' | |
| AND sequence_schema != 'information_schema'"; | |
| } | |
| /** | |
| * {@inheritDoc} | |
| */ | |
| public function getListTablesSQL() | |
| { | |
| return "SELECT quote_ident(table_name) AS table_name, | |
| table_schema AS schema_name | |
| FROM information_schema.tables | |
| WHERE table_schema NOT LIKE 'pg\_%' | |
| AND table_schema NOT LIKE '%timescaledb%' | |
| AND table_schema != 'information_schema' | |
| AND table_name != 'geometry_columns' | |
| AND table_name != 'spatial_ref_sys' | |
| AND table_type != 'VIEW'"; | |
| } | |
| /** | |
| * {@inheritDoc} | |
| */ | |
| /* public function getListTableColumnsSQL($table, $database = null) | |
| { | |
| return "SELECT | |
| a.attnum, | |
| quote_ident(a.attname) AS field, | |
| t.typname AS type, | |
| format_type(a.atttypid, a.atttypmod) AS complete_type, | |
| (SELECT t1.typname FROM pg_catalog.pg_type t1 WHERE t1.oid = t.typbasetype) AS domain_type, | |
| (SELECT format_type(t2.typbasetype, t2.typtypmod) FROM | |
| pg_catalog.pg_type t2 WHERE t2.typtype = 'd' AND t2.oid = a.atttypid) AS domain_complete_type, | |
| a.attnotnull AS isnotnull, | |
| (SELECT 't' | |
| FROM pg_index | |
| WHERE c.oid = pg_index.indrelid | |
| AND pg_index.indkey[0] = a.attnum | |
| AND pg_index.indisprimary = 't' | |
| ) AS pri, | |
| (SELECT pg_get_expr(adbin, adrelid) | |
| FROM pg_attrdef | |
| WHERE c.oid = pg_attrdef.adrelid | |
| AND pg_attrdef.adnum=a.attnum | |
| ) AS default, | |
| (SELECT pg_description.description | |
| FROM pg_description WHERE pg_description.objoid = c.oid AND a.attnum = pg_description.objsubid | |
| ) AS comment | |
| FROM pg_attribute a, pg_class c, pg_type t, pg_namespace n | |
| WHERE " . $this->getTableWhereClause($table, 'c', 'n') . ' | |
| AND a.attnum > 0 | |
| AND a.attrelid = c.oid | |
| AND a.atttypid = t.oid | |
| AND n.oid = c.relnamespace | |
| AND n.nspname NOT LIKE \'%timescaledb%\' | |
| ORDER BY a.attnum'; | |
| }*/ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment