mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-14 22:29:33 +00:00
Postgre Statements integrieren
This commit is contained in:
parent
a3db6196e7
commit
321aeb13c0
2 changed files with 97 additions and 16 deletions
|
|
@ -16,16 +16,43 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration
|
||||||
|
|
||||||
public function mySQLUp(Schema $schema): void
|
public function mySQLUp(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql('CREATE TABLE `part_custom_states` (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, id_preview_attachment INT DEFAULT NULL, name VARCHAR(255) NOT NULL, comment LONGTEXT NOT NULL, not_selectable TINYINT(1) NOT NULL, alternative_names LONGTEXT DEFAULT NULL, last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, INDEX IDX_F552745D727ACA70 (parent_id), INDEX IDX_F552745DEA7100A1 (id_preview_attachment), INDEX part_custom_state_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');
|
$this->addSql(<<<'SQL'
|
||||||
$this->addSql('ALTER TABLE `part_custom_states` ADD CONSTRAINT FK_F552745D727ACA70 FOREIGN KEY (parent_id) REFERENCES `part_custom_states` (id)');
|
CREATE TABLE part_custom_states (
|
||||||
$this->addSql('ALTER TABLE `part_custom_states` ADD CONSTRAINT FK_F552745DEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES `attachments` (id) ON DELETE SET NULL');
|
id INT AUTO_INCREMENT NOT NULL,
|
||||||
|
parent_id INT DEFAULT NULL,
|
||||||
|
id_preview_attachment INT DEFAULT NULL,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
comment LONGTEXT NOT NULL,
|
||||||
|
not_selectable TINYINT(1) NOT NULL,
|
||||||
|
alternative_names LONGTEXT DEFAULT NULL,
|
||||||
|
last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
INDEX IDX_F552745D727ACA70 (parent_id),
|
||||||
|
INDEX IDX_F552745DEA7100A1 (id_preview_attachment),
|
||||||
|
INDEX part_custom_state_name (name),
|
||||||
|
PRIMARY KEY(id)
|
||||||
|
)
|
||||||
|
DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE part_custom_states ADD CONSTRAINT FK_F552745D727ACA70 FOREIGN KEY (parent_id) REFERENCES part_custom_states (id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE part_custom_states ADD CONSTRAINT FK_F552745DEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES attachments (id) ON DELETE SET NULL
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mySQLDown(Schema $schema): void
|
public function mySQLDown(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql('ALTER TABLE `part_custom_states` DROP FOREIGN KEY FK_F552745D727ACA70');
|
$this->addSql(<<<'SQL'
|
||||||
$this->addSql('ALTER TABLE `part_custom_states` DROP FOREIGN KEY FK_F552745DEA7100A1');
|
ALTER TABLE part_custom_states DROP FOREIGN KEY FK_F552745D727ACA70;
|
||||||
$this->addSql('DROP TABLE `part_custom_states`');
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE part_custom_states DROP FOREIGN KEY FK_F552745DEA7100A1
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE part_custom_states
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sqLiteUp(Schema $schema): void
|
public function sqLiteUp(Schema $schema): void
|
||||||
|
|
@ -62,11 +89,37 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration
|
||||||
|
|
||||||
public function postgreSQLUp(Schema $schema): void
|
public function postgreSQLUp(Schema $schema): void
|
||||||
{
|
{
|
||||||
//Not needed
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE TABLE "part_custom_states" (
|
||||||
|
id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
|
||||||
|
parent_id INT DEFAULT NULL,
|
||||||
|
id_preview_attachment INT DEFAULT NULL, PRIMARY KEY(id),
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
comment TEXT NOT NULL,
|
||||||
|
not_selectable BOOLEAN NOT NULL,
|
||||||
|
alternative_names TEXT 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
|
||||||
|
)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE INDEX IDX_F552745D727ACA70 ON "part_custom_states" (parent_id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE INDEX IDX_F552745DEA7100A1 ON "part_custom_states" (id_preview_attachment)
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postgreSQLDown(Schema $schema): void
|
public function postgreSQLDown(Schema $schema): void
|
||||||
{
|
{
|
||||||
//Not needed
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE "part_custom_states" DROP CONSTRAINT FK_F552745D727ACA70
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE "part_custom_states" DROP CONSTRAINT FK_F552745DEA7100A1
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE "part_custom_states"
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,28 @@ final class Version20250321141740 extends AbstractMultiPlatformMigration
|
||||||
|
|
||||||
public function mySQLUp(Schema $schema): void
|
public function mySQLUp(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql('ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL AFTER id_part_unit');
|
$this->addSql(<<<'SQL'
|
||||||
$this->addSql('ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES `part_custom_states` (id)');
|
ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL AFTER id_part_unit
|
||||||
$this->addSql('CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state)');
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES part_custom_states (id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state)
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mySQLDown(Schema $schema): void
|
public function mySQLDown(Schema $schema): void
|
||||||
{
|
{
|
||||||
$this->addSql('ALTER TABLE `parts` DROP FOREIGN KEY FK_6940A7FEA3ED1215');
|
$this->addSql(<<<'SQL'
|
||||||
$this->addSql('DROP INDEX IDX_6940A7FEA3ED1215 ON `parts`');
|
ALTER TABLE parts DROP FOREIGN KEY FK_6940A7FEA3ED1215
|
||||||
$this->addSql('ALTER TABLE `parts` DROP id_part_custom_state');
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP INDEX IDX_6940A7FEA3ED1215 ON parts
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE parts DROP id_part_custom_state
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sqLiteUp(Schema $schema): void
|
public function sqLiteUp(Schema $schema): void
|
||||||
|
|
@ -465,11 +477,27 @@ final class Version20250321141740 extends AbstractMultiPlatformMigration
|
||||||
|
|
||||||
public function postgreSQLUp(Schema $schema): void
|
public function postgreSQLUp(Schema $schema): void
|
||||||
{
|
{
|
||||||
//Not needed
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES "part_custom_states" (id) NOT DEFERRABLE INITIALLY IMMEDIATE
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state)
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postgreSQLDown(Schema $schema): void
|
public function postgreSQLDown(Schema $schema): void
|
||||||
{
|
{
|
||||||
//Not needed
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE "parts" DROP CONSTRAINT FK_6940A7FEA3ED1215
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP INDEX IDX_6940A7FEA3ED1215
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE "parts" DROP id_part_custom_state
|
||||||
|
SQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue