mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2026-01-25 16:02:19 +01:00
18 lines
385 B
PHP
18 lines
385 B
PHP
<?php
|
|
|
|
class DropTableSQLRewriter extends AbstractSQLRewriter
|
|
{
|
|
public function rewrite(): string
|
|
{
|
|
$sql = $this->original();
|
|
|
|
$pattern = '/DROP TABLE.+ [`]?(\w+)[`]?$/';
|
|
preg_match($pattern, $sql, $matches);
|
|
$table = $matches[1];
|
|
$seq = $table . '_seq';
|
|
$sql .= ";\nDROP SEQUENCE IF EXISTS $seq;";
|
|
|
|
return $sql;
|
|
}
|
|
}
|