Use mariadb for dev and prod

This commit is contained in:
Jannis Portmann 2022-01-11 22:42:01 +01:00
parent cb90ba1eb3
commit f7126dba43
13 changed files with 19 additions and 317 deletions

4
.env
View file

@ -23,8 +23,8 @@ APP_SECRET=8a390490e448f181dd8d3e6bd38efe6a
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml # 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="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="mysql://pflaenzli:develop@127.0.0.1:3306/pflaenzli?serverVersion=mariadb-10.5.13"
DATABASE_URL="postgresql://postgres:develop@localhost:5432/plantex?serverVersion=13&charset=utf8" # DATABASE_URL="postgresql://postgres:develop@localhost:5432/pflaenzli?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ### ###< doctrine/doctrine-bundle ###
###> symfony/mailer ### ###> symfony/mailer ###

View file

@ -36,14 +36,13 @@ cd plant-exchange
``` ```
docker-compose up -d 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 and migrate
``` ```
symfony console doctrine:migrations:migrate -n bin/console doctrine:migrations:migrate -n
``` ```
### 4. Install dependencies ### 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) You sholud be able to access the site under [localhost:8080](http://localhost:8080)
### 6. Create a user ### 6. Create a user
Go to the database and add a user manually. For the password use this to generate the appropriate hash: Register your own account and set the `role` in the databse to `["ROLE"ADMIN"]`
```
symfony console security:encode-password
```
### 7. Watch files ### 7. Watch files
If you are editing `.scss` or other webpack files, you'll want to run If you are editing `.scss` or other webpack files, you'll want to run

View file

@ -5,7 +5,7 @@ A platform where people can exchange plants. They can post what they have and se
## Tech stack ## Tech stack
- [Symfony](https://symfony.com/) - [Symfony](https://symfony.com/)
- [PostgreSQL](https://www.postgresql.org/), maybe should be using MySQL for easier deployment? - [MariaDB](https://www.mariadb.org)
Deployment: TBD Deployment: TBD

View file

@ -2,29 +2,20 @@ version: '3'
services: services:
db: db:
image: postgres:13 image: mariadb:10.5
environment: environment:
POSTGRES_PASSWORD: develop MARIADB_USER: pflaenzli
MARIADB_PASSWORD: develop
MARIADB_DATABASE: pflaenzli
MARIADB_ROOT_PASSWORD: r00tpa55w0rd
ports: ports:
- 5432:5432 - 3306:3306
volumes: volumes:
- postgres-data:/var/lib/postgresql/data - mariadb-data:/var/lib/mysql
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
mailer: mailer:
image: schickling/mailcatcher image: schickling/mailcatcher
ports: [1025,1080] ports: [1025,1080]
volumes: volumes:
postgres-data: mariadb-data:
pgadmin-data:

View file

@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210422125046 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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"');
}
}

View file

@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210422132314 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

View file

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210422155430 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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\'');
}
}

View file

@ -1,38 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210424153343 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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 \'\'');
}
}

View file

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210426205302 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

View file

@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210502123444 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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\'');
}
}

View file

@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210503161858 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

View file

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210614104026 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

View file

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/** /**
* Auto-generated Migration: Please modify to your needs! * Auto-generated Migration: Please modify to your needs!
*/ */
final class Version20210519090349 extends AbstractMigration final class Version20220111213438 extends AbstractMigration
{ {
public function getDescription(): string public function getDescription(): string
{ {
@ -20,12 +20,12 @@ final class Version20210519090349 extends AbstractMigration
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
// this up() migration is auto-generated, please modify it to your needs // 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 public function down(Schema $schema): void
{ {
// this down() migration is auto-generated, please modify it to your needs // this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
} }
} }