Skip to content
Merged

Dev #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public/bundles/
tests/
var/
vendor/
node_modules/
.editorconfig
#.env.*.local
#.env.local
#.env.local.php
#.env.test
.env.*.local
.env.local
.env.local.php
.env.test
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ COMPOSER = $(PHP_CONT) composer
SYMFONY = $(PHP) bin/console
PHPUNIT = $(PHP) bin/phpunit


# Node.js / npm
NODE = $(PHP_CONT) node
NPM = $(PHP_CONT) npm


# Misc
.DEFAULT_GOAL = help
.PHONY : help build up start down logs sh composer vendor sf cc
Expand Down Expand Up @@ -48,6 +54,15 @@ logs: ## Show live logs
sh: ## Connect to the PHP FPM container
@$(PHP_CONT) sh

node: ## Check Node.js version inside container
@$(NODE) -v

npm: ## Check npm version inside container
@$(NPM) -v

npm-install: ## Run npm install inside container
@$(NODE_CONT) npm install

perms: ## Connect to the PHP FPM container
@$(PHP_CONT) chown www-data ./var/cache -R
@$(PHP_CONT) chmod 0777 ./var/cache -R
Expand Down
8 changes: 7 additions & 1 deletion docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ RUN set -eux; \
chmod +x bin/console; sync; \
fi

# --- Node.js & npm ---
RUN apk add --no-cache nodejs npm
COPY package.json package-lock.json ./
RUN npm install


COPY --link docker/php/healthcheck.sh /usr/local/bin/healthcheck
RUN chmod +x bin/phpunit; sync;
RUN chmod +x healthcheck; sync;
Expand All @@ -89,4 +95,4 @@ RUN composer dump-env dev;

RUN install-php-extensions \
xdebug \
;
;
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public function up(Schema $schema): void
if (!$sm->tablesExist(['storage'])) {
$this->addSql(<<<'SQL'
CREATE TABLE storage (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
id SERIAL PRIMARY KEY,
full_path VARCHAR(255) NOT NULL,
type VARCHAR(50) NOT NULL,
uid VARCHAR(100) NOT NULL,
file_type VARCHAR(20) NOT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
created_at TIMESTAMP NOT NULL
)
SQL);
}

}

public function down(Schema $schema): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,50 @@ final class Version20250701024108Updatestorage extends AbstractMigration
{
public function getDescription(): string
{
return 'Обновление таблиц storage и tasks: удаление uid, task_type; добавление полей с датами и временем';
return 'Обновление таблиц storage и tasks: удаление uid, task_type; добавление полей с датами и временем (PostgreSQL совместимость)';
}

public function up(Schema $schema): void
{
$sm = $this->connection->createSchemaManager();

if ($sm->tablesExist(['storage']) && $sm->introspectTable('storage')->hasColumn('uid')) {
$this->addSql('ALTER TABLE storage DROP uid');
$this->addSql('ALTER TABLE storage DROP COLUMN uid');
}

if ($sm->tablesExist(['tasks'])) {
$columns = $sm->introspectTable('tasks')->getColumns();

if (isset($columns['task_type'])) {
$this->addSql('ALTER TABLE tasks DROP task_type');
$this->addSql('ALTER TABLE tasks DROP COLUMN task_type');
}

$addColumnsSql = [];

if (!isset($columns['date'])) {
$addColumnsSql[] = 'ADD date VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN date TEXT DEFAULT NULL';
}
if (!isset($columns['time'])) {
$addColumnsSql[] = 'ADD time VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN time TEXT DEFAULT NULL';
}
if (!isset($columns['start_date'])) {
$addColumnsSql[] = 'ADD start_date VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN start_date TEXT DEFAULT NULL';
}
if (!isset($columns['start_time'])) {
$addColumnsSql[] = 'ADD start_time VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN start_time TEXT DEFAULT NULL';
}
if (!isset($columns['end_date'])) {
$addColumnsSql[] = 'ADD end_date VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN end_date TEXT DEFAULT NULL';
}
if (!isset($columns['end_time'])) {
$addColumnsSql[] = 'ADD end_time VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN end_time TEXT DEFAULT NULL';
}
if (!isset($columns['repeat'])) {
$addColumnsSql[] = 'ADD `repeat` VARCHAR(255) DEFAULT NULL';
$addColumnsSql[] = 'ADD COLUMN "repeat" TEXT DEFAULT NULL';
}

if (!empty($addColumnsSql)) {
$this->addSql('ALTER TABLE tasks '.implode(', ', $addColumnsSql));
$this->addSql('ALTER TABLE tasks ' . implode(', ', $addColumnsSql));
}
}
}
Expand All @@ -66,19 +66,19 @@ public function down(Schema $schema): void
if ($sm->tablesExist(['tasks'])) {
$this->addSql(<<<'SQL'
ALTER TABLE tasks
ADD task_type VARCHAR(255) NOT NULL,
DROP date,
DROP time,
DROP start_date,
DROP start_time,
DROP end_date,
DROP end_time,
DROP `repeat`
ADD COLUMN task_type VARCHAR(255) NOT NULL,
DROP COLUMN date,
DROP COLUMN time,
DROP COLUMN start_date,
DROP COLUMN start_time,
DROP COLUMN end_date,
DROP COLUMN end_time,
DROP COLUMN "repeat"
SQL);
}

if ($sm->tablesExist(['storage']) && ! $sm->introspectTable('storage')->hasColumn('uid')) {
$this->addSql('ALTER TABLE storage ADD uid VARCHAR(100) NOT NULL');
$this->addSql('ALTER TABLE storage ADD COLUMN uid VARCHAR(100) NOT NULL');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public function down(Schema $schema): void
$table = $schema->getTable('tasks');
$adds = [];
if (!$table->hasColumn('notification_id')) {
$adds[] = 'ADD notification_id INT DEFAULT NULL';
$adds[] = 'ADD notification_id INTEGER DEFAULT NULL';
}
if (!$table->hasColumn('due_date')) {
$adds[] = 'ADD due_date DATETIME DEFAULT NULL';
$adds[] = 'ADD due_date TIMESTAMP DEFAULT NULL';
}
if (!$table->hasColumn('date')) {
$adds[] = 'ADD date VARCHAR(255) DEFAULT NULL';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Version20250706023331Createlanguagestables extends AbstractMigration
{
public function getDescription(): string
{
return 'Creates language and language_page_translation tables for multilingual page support.';
return 'Creates language and language_page_translation tables for multilingual page support (PostgreSQL).';
}

public function up(Schema $schema): void
Expand All @@ -24,31 +24,26 @@ public function up(Schema $schema): void
if (!$sm->tablesExist(['language'])) {
$this->addSql(<<<'SQL'
CREATE TABLE language (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
id SERIAL PRIMARY KEY,
prefix VARCHAR(10) NOT NULL,
name VARCHAR(100) NOT NULL,
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
name VARCHAR(100) NOT NULL
)
SQL);
}

if (!$sm->tablesExist(['language_page_translation'])) {
$this->addSql(<<<'SQL'
CREATE TABLE language_page_translation (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
language_id INT NOT NULL,
id SERIAL PRIMARY KEY,
language_id INTEGER NOT NULL,
page_name VARCHAR(100) NOT NULL,
page_translate JSON NOT NULL,
INDEX IDX_AFF4D9D182F1BAF4 (language_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
page_translate JSONB NOT NULL,
CONSTRAINT fk_language FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE
)
SQL);

$this->addSql(<<<'SQL'
ALTER TABLE language_page_translation
ADD CONSTRAINT FK_AFF4D9D182F1BAF4
FOREIGN KEY (language_id) REFERENCES language (id)
SQL);
// Индекс для ускорения поиска по language_id
$this->addSql('CREATE INDEX idx_language_translation_language_id ON language_page_translation (language_id)');
}
}

Expand All @@ -57,9 +52,6 @@ public function down(Schema $schema): void
$sm = $this->connection->createSchemaManager();

if ($sm->tablesExist(['language_page_translation'])) {
$this->addSql(<<<'SQL'
ALTER TABLE language_page_translation DROP FOREIGN KEY FK_AFF4D9D182F1BAF4
SQL);
$this->addSql('DROP TABLE language_page_translation');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function up(Schema $schema): void
foreach ($tables as $table) {
if ($this->tableExists($schema, $table)) {
if (!$this->columnExists($schema, $table, 'created_at')) {
$this->addSql("ALTER TABLE {$table} ADD created_at DATETIME DEFAULT NULL");
$this->addSql("ALTER TABLE {$table} ADD created_at TIMESTAMP DEFAULT NULL");
}
if (!$this->columnExists($schema, $table, 'updated_at')) {
$default = 'storage' === $table ? "DATETIME DEFAULT NULL" : 'DATETIME DEFAULT NULL';
$default = 'storage' === $table ? "TIMESTAMP DEFAULT NULL" : 'TIMESTAMP DEFAULT NULL';
$this->addSql("ALTER TABLE {$table} ADD updated_at {$default}");
}
if (!$this->columnExists($schema, $table, 'is_delete')) {
$this->addSql("ALTER TABLE {$table} ADD is_delete TINYINT(1) NOT NULL");
$this->addSql("ALTER TABLE {$table} ADD is_delete BOOLEAN NOT NULL");
}
}
}
Expand Down
Loading