From f7126dba43b8745251cf114258572f75b108c6b1 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Tue, 11 Jan 2022 22:42:01 +0100 Subject: [PATCH] Use mariadb for dev and prod --- .env | 4 +- DEVELOPMENT.md | 14 +++---- README.md | 2 +- docker-compose.yml | 25 ++++------- migrations/Version20210422125046.php | 35 ---------------- migrations/Version20210422132314.php | 32 -------------- migrations/Version20210422155430.php | 34 --------------- migrations/Version20210424153343.php | 38 ----------------- migrations/Version20210426205302.php | 34 --------------- migrations/Version20210502123444.php | 42 ------------------- migrations/Version20210503161858.php | 36 ---------------- migrations/Version20210614104026.php | 34 --------------- ...19090349.php => Version20220111213438.php} | 6 +-- 13 files changed, 19 insertions(+), 317 deletions(-) delete mode 100644 migrations/Version20210422125046.php delete mode 100644 migrations/Version20210422132314.php delete mode 100644 migrations/Version20210422155430.php delete mode 100644 migrations/Version20210424153343.php delete mode 100644 migrations/Version20210426205302.php delete mode 100644 migrations/Version20210502123444.php delete mode 100644 migrations/Version20210503161858.php delete mode 100644 migrations/Version20210614104026.php rename migrations/{Version20210519090349.php => Version20220111213438.php} (74%) diff --git a/.env b/.env index 7da46f2..db284e4 100644 --- a/.env +++ b/.env @@ -23,8 +23,8 @@ APP_SECRET=8a390490e448f181dd8d3e6bd38efe6a # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml # # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" -# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7" -DATABASE_URL="postgresql://postgres:develop@localhost:5432/plantex?serverVersion=13&charset=utf8" +DATABASE_URL="mysql://pflaenzli:develop@127.0.0.1:3306/pflaenzli?serverVersion=mariadb-10.5.13" +# DATABASE_URL="postgresql://postgres:develop@localhost:5432/pflaenzli?serverVersion=13&charset=utf8" ###< doctrine/doctrine-bundle ### ###> symfony/mailer ### diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index bd818af..d08ddec 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -36,14 +36,13 @@ cd plant-exchange ``` docker-compose up -d ``` -To create the database (or use pgadmin): +To create the database ``` -docker exec -it plant-exchange_db_1 psql -U postgres -c 'CREATE DATABASE plantex;' -``` - + bin/console doctrine:schema:create + ``` and migrate ``` -symfony console doctrine:migrations:migrate -n +bin/console doctrine:migrations:migrate -n ``` ### 4. Install dependencies @@ -63,10 +62,7 @@ symfony serve --port 8080 --no-tls -d You sholud be able to access the site under [localhost:8080](http://localhost:8080) ### 6. Create a user -Go to the database and add a user manually. For the password use this to generate the appropriate hash: -``` -symfony console security:encode-password -``` +Register your own account and set the `role` in the databse to `["ROLE"ADMIN"]` ### 7. Watch files If you are editing `.scss` or other webpack files, you'll want to run diff --git a/README.md b/README.md index 00dc4b4..a8a91cd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A platform where people can exchange plants. They can post what they have and se ## Tech stack - [Symfony](https://symfony.com/) -- [PostgreSQL](https://www.postgresql.org/), maybe should be using MySQL for easier deployment? +- [MariaDB](https://www.mariadb.org) Deployment: TBD diff --git a/docker-compose.yml b/docker-compose.yml index 88c27e2..cd5a5a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,29 +2,20 @@ version: '3' services: db: - image: postgres:13 + image: mariadb:10.5 environment: - POSTGRES_PASSWORD: develop + MARIADB_USER: pflaenzli + MARIADB_PASSWORD: develop + MARIADB_DATABASE: pflaenzli + MARIADB_ROOT_PASSWORD: r00tpa55w0rd ports: - - 5432:5432 + - 3306:3306 volumes: - - postgres-data:/var/lib/postgresql/data - - pgadmin: - image: dpage/pgadmin4 - environment: - PGADMIN_DEFAULT_EMAIL: admin@admin.com - PGADMIN_DEFAULT_PASSWORD: root - ports: - - "8001:80" - volumes: - - ./pgadmin_data/servers.json:/pgadmin4/servers.json - - pgadmin-data:/varl/lib/pgadmin + - mariadb-data:/var/lib/mysql mailer: image: schickling/mailcatcher ports: [1025,1080] volumes: - postgres-data: - pgadmin-data: + mariadb-data: diff --git a/migrations/Version20210422125046.php b/migrations/Version20210422125046.php deleted file mode 100644 index 1c6fd4e..0000000 --- a/migrations/Version20210422125046.php +++ /dev/null @@ -1,35 +0,0 @@ -addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE "user" (id INT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON "user" (email)'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('DROP SEQUENCE "user_id_seq" CASCADE'); - $this->addSql('DROP TABLE "user"'); - } -} diff --git a/migrations/Version20210422132314.php b/migrations/Version20210422132314.php deleted file mode 100644 index 8896d21..0000000 --- a/migrations/Version20210422132314.php +++ /dev/null @@ -1,32 +0,0 @@ -addSql('ALTER TABLE "user" ADD is_verified BOOLEAN NOT NULL DEFAULT TRUE'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE "user" DROP is_verified'); - } -} diff --git a/migrations/Version20210422155430.php b/migrations/Version20210422155430.php deleted file mode 100644 index 8317eee..0000000 --- a/migrations/Version20210422155430.php +++ /dev/null @@ -1,34 +0,0 @@ -addSql('ALTER TABLE "user" ADD username VARCHAR(255) NOT NULL DEFAULT \'\''); - $this->addSql('ALTER TABLE "user" ALTER is_verified DROP DEFAULT'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE "user" DROP username'); - $this->addSql('ALTER TABLE "user" ALTER is_verified SET DEFAULT \'true\''); - } -} diff --git a/migrations/Version20210424153343.php b/migrations/Version20210424153343.php deleted file mode 100644 index 951a673..0000000 --- a/migrations/Version20210424153343.php +++ /dev/null @@ -1,38 +0,0 @@ -addSql('CREATE SEQUENCE offering_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE offering (id INT NOT NULL, by_user_id INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, title VARCHAR(255) NOT NULL, photo_filename VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_A5682AB1DC9C2434 ON offering (by_user_id)'); - $this->addSql('ALTER TABLE offering ADD CONSTRAINT FK_A5682AB1DC9C2434 FOREIGN KEY (by_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE "user" ALTER username DROP DEFAULT'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('DROP SEQUENCE offering_id_seq CASCADE'); - $this->addSql('DROP TABLE offering'); - $this->addSql('ALTER TABLE "user" ALTER username SET DEFAULT \'\''); - } -} diff --git a/migrations/Version20210426205302.php b/migrations/Version20210426205302.php deleted file mode 100644 index 3a1ab50..0000000 --- a/migrations/Version20210426205302.php +++ /dev/null @@ -1,34 +0,0 @@ -addSql('ALTER TABLE offering ADD zip_code INT NOT NULL DEFAULT 0'); - $this->addSql('ALTER TABLE offering ADD description TEXT NOT NULL DEFAULT \'Lorem ipsum dolor\''); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE offering DROP zip_code'); - $this->addSql('ALTER TABLE offering DROP description'); - } -} diff --git a/migrations/Version20210502123444.php b/migrations/Version20210502123444.php deleted file mode 100644 index a7261ed..0000000 --- a/migrations/Version20210502123444.php +++ /dev/null @@ -1,42 +0,0 @@ -addSql('CREATE SEQUENCE reset_password_request_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE reset_password_request (id INT NOT NULL, user_id INT NOT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, expires_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_7CE748AA76ED395 ON reset_password_request (user_id)'); - $this->addSql('COMMENT ON COLUMN reset_password_request.requested_at IS \'(DC2Type:datetime_immutable)\''); - $this->addSql('COMMENT ON COLUMN reset_password_request.expires_at IS \'(DC2Type:datetime_immutable)\''); - $this->addSql('ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE offering ALTER zip_code DROP DEFAULT'); - $this->addSql('ALTER TABLE offering ALTER description DROP DEFAULT'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('DROP SEQUENCE reset_password_request_id_seq CASCADE'); - $this->addSql('DROP TABLE reset_password_request'); - $this->addSql('ALTER TABLE offering ALTER zip_code SET DEFAULT 0'); - $this->addSql('ALTER TABLE offering ALTER description SET DEFAULT \'Lorem ipsum dolor\''); - } -} diff --git a/migrations/Version20210503161858.php b/migrations/Version20210503161858.php deleted file mode 100644 index 69375cd..0000000 --- a/migrations/Version20210503161858.php +++ /dev/null @@ -1,36 +0,0 @@ -addSql('CREATE SEQUENCE wish_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE wish (id INT NOT NULL, by_user_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_D7D174C9DC9C2434 ON wish (by_user_id)'); - $this->addSql('ALTER TABLE wish ADD CONSTRAINT FK_D7D174C9DC9C2434 FOREIGN KEY (by_user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - } - - public function down(Schema $schema) : void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('DROP SEQUENCE wish_id_seq CASCADE'); - $this->addSql('DROP TABLE wish'); - } -} diff --git a/migrations/Version20210614104026.php b/migrations/Version20210614104026.php deleted file mode 100644 index 8735f19..0000000 --- a/migrations/Version20210614104026.php +++ /dev/null @@ -1,34 +0,0 @@ -addSql('ALTER TABLE offering ALTER description SET NOT NULL'); - $this->addSql('ALTER TABLE "user" ADD zip_code INT DEFAULT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE "user" DROP zip_code'); - $this->addSql('ALTER TABLE offering ALTER description DROP NOT NULL'); - } -} diff --git a/migrations/Version20210519090349.php b/migrations/Version20220111213438.php similarity index 74% rename from migrations/Version20210519090349.php rename to migrations/Version20220111213438.php index ef91083..e6705f2 100644 --- a/migrations/Version20210519090349.php +++ b/migrations/Version20220111213438.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20210519090349 extends AbstractMigration +final class Version20220111213438 extends AbstractMigration { public function getDescription(): string { @@ -20,12 +20,12 @@ final class Version20210519090349 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE offering ALTER COLUMN description DROP NOT NULL'); + } public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); + } }