db = Pgsql::with($pgsql); } protected Pgsql $db; function db(): Pgsql { return $this->db; } const PRIMARY_KEY_DEFINITION = [ "id_" => "serial primary key", ]; protected function tableExists(string $tableName): bool { if (($index = strpos($tableName, ".")) !== false) { $schemaName = substr($tableName, 0, $index); $tableName = substr($tableName, $index + 1); } else { $schemaName = "public"; } $found = $this->db->get([ "select tablename from pg_tables", "where" => [ "schemaname" => $schemaName, "tablename" => $tableName, ], ]); return $found !== null; } function _getMigration(CapacitorChannel $channel): _pgsqlMigration { $migrations = cl::merge([ "0init" => [$this->_createSql($channel)], ], $channel->getMigration()); return new _pgsqlMigration($migrations, $channel->getName()); } protected function _addToChannelsSql(CapacitorChannel $channel): array { return cl::merge(parent::_addToChannelsSql($channel), [ "suffix" => "on conflict (name) do nothing", ]); } function close(): void { $this->db->close(); } }