initial commit
This commit is contained in:
53
migrations/Version20251006214042.php
Normal file
53
migrations/Version20251006214042.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251006214042 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Initial schema with default data';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE kampagnen (id INT AUTO_INCREMENT NOT NULL, is_fb TINYINT(1) NOT NULL, is_tr TINYINT(1) NOT NULL, is_mail TINYINT(1) NOT NULL, dest_url VARCHAR(255) NOT NULL, mailtext LONGTEXT DEFAULT NULL, img VARCHAR(255) DEFAULT NULL, linktext VARCHAR(255) DEFAULT NULL, ma SMALLINT NOT NULL, reload SMALLINT NOT NULL, dateCreated DATETIME NOT NULL, dateModified DATETIME NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_37572FC6A76ED395 (user_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('CREATE TABLE reloadsperre (id INT AUTO_INCREMENT NOT NULL, reload_bis DATETIME NOT NULL, ip VARCHAR(45) NOT NULL, dateCreated DATETIME NOT NULL, kampagne_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_B6A62B2AACE19231 (kampagne_id), INDEX IDX_B6A62B2AA76ED395 (user_id), INDEX idx_kampagne_user (kampagne_id, user_id), INDEX idx_reload_bis (reload_bis), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('CREATE TABLE users (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(100) NOT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\'), createdAt DATETIME NOT NULL, werbenetzwerk_id INT DEFAULT NULL, INDEX IDX_1483A5E948B23AFC (werbenetzwerk_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('CREATE TABLE werbenetzwerk (id INT AUTO_INCREMENT NOT NULL, umrechnungskurs DOUBLE PRECISION NOT NULL, eigenanteil_prozent SMALLINT UNSIGNED NOT NULL, date_updated DATETIME DEFAULT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE kampagnen ADD CONSTRAINT FK_37572FC6A76ED395 FOREIGN KEY (user_id) REFERENCES users (id)');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AACE19231 FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id)');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AA76ED395 FOREIGN KEY (user_id) REFERENCES users (id)');
|
||||
$this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E948B23AFC FOREIGN KEY (werbenetzwerk_id) REFERENCES werbenetzwerk (id)');
|
||||
|
||||
// Default data - Werbenetzwerk
|
||||
$this->addSql('INSERT INTO werbenetzwerk (umrechnungskurs, eigenanteil_prozent, date_updated) VALUES (0.0000000022, 25, NOW())');
|
||||
|
||||
// Default data - Users
|
||||
$this->addSql('INSERT INTO users (username, email, password, rolle, createdAt) VALUES ("admin", "admin@example.com", "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi", "admin", NOW())');
|
||||
$this->addSql('INSERT INTO users (username, email, password, rolle, createdAt) VALUES ("testuser1", "testuser1@example.com", "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi", "user", NOW())');
|
||||
$this->addSql('INSERT INTO users (username, email, password, rolle, createdAt) VALUES ("testuser2", "testuser2@example.com", "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi", "user", NOW())');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE kampagnen DROP FOREIGN KEY FK_37572FC6A76ED395');
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AACE19231');
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AA76ED395');
|
||||
$this->addSql('ALTER TABLE users DROP FOREIGN KEY FK_1483A5E948B23AFC');
|
||||
$this->addSql('DROP TABLE kampagnen');
|
||||
$this->addSql('DROP TABLE reloadsperre');
|
||||
$this->addSql('DROP TABLE users');
|
||||
$this->addSql('DROP TABLE werbenetzwerk');
|
||||
}
|
||||
}
|
||||
33
migrations/Version20251006214520.php
Normal file
33
migrations/Version20251006214520.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251006214520 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Change IP column to VARBINARY(16) for efficient storage';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reloadsperre CHANGE ip ip VARBINARY(16) NOT NULL');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\')');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reloadsperre CHANGE ip ip VARCHAR(45) NOT NULL');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\') DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
33
migrations/Version20251006214635.php
Normal file
33
migrations/Version20251006214635.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251006214635 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Change IP column to INT UNSIGNED for IPv4 storage (4 bytes)';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reloadsperre CHANGE ip ip INT UNSIGNED NOT NULL');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\')');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reloadsperre CHANGE ip ip VARBINARY(16) NOT NULL');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\') DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
47
migrations/Version20251006214741.php
Normal file
47
migrations/Version20251006214741.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251006214741 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add ON DELETE actions to foreign keys';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE kampagnen DROP FOREIGN KEY `FK_37572FC6A76ED395`');
|
||||
$this->addSql('ALTER TABLE kampagnen ADD CONSTRAINT FK_37572FC6A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL');
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY `FK_B6A62B2AA76ED395`');
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY `FK_B6A62B2AACE19231`');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AACE19231 FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE users DROP FOREIGN KEY `FK_1483A5E948B23AFC`');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\')');
|
||||
$this->addSql('ALTER TABLE users ADD CONSTRAINT FK_1483A5E948B23AFC FOREIGN KEY (werbenetzwerk_id) REFERENCES werbenetzwerk (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE kampagnen DROP FOREIGN KEY FK_37572FC6A76ED395');
|
||||
$this->addSql('ALTER TABLE kampagnen ADD CONSTRAINT `FK_37572FC6A76ED395` FOREIGN KEY (user_id) REFERENCES users (id)');
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AACE19231');
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AA76ED395');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT `FK_B6A62B2AACE19231` FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id)');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT `FK_B6A62B2AA76ED395` FOREIGN KEY (user_id) REFERENCES users (id)');
|
||||
$this->addSql('ALTER TABLE users DROP FOREIGN KEY FK_1483A5E948B23AFC');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\') DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE users ADD CONSTRAINT `FK_1483A5E948B23AFC` FOREIGN KEY (werbenetzwerk_id) REFERENCES werbenetzwerk (id)');
|
||||
}
|
||||
}
|
||||
35
migrations/Version20251006214859.php
Normal file
35
migrations/Version20251006214859.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20251006214859 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Change kampagne FK to RESTRICT (kampagne must exist)';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY `FK_B6A62B2AACE19231`');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT FK_B6A62B2AACE19231 FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id) ON DELETE RESTRICT');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\')');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE reloadsperre DROP FOREIGN KEY FK_B6A62B2AACE19231');
|
||||
$this->addSql('ALTER TABLE reloadsperre ADD CONSTRAINT `FK_B6A62B2AACE19231` FOREIGN KEY (kampagne_id) REFERENCES kampagnen (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE users CHANGE rolle rolle ENUM(\'user\', \'admin\', \'werbenetzwerk\') DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user