problemy s rozbehnutim nextras/migrations
- ikoon
- Člen | 80
Zdravim
Mam problem rozbehnut nextras/migrations. Po hodinach skusania a googlenia
som dospel k tomuto:
bin/console:
#!/usr/bin/env php
<?php
require __DIR__ . '/../vendor/autoload.php';
$configurator = App\Bootstrap::boot();
$container = $configurator->createContainer();
$application = $container->getByType(Contributte\Console\Application::class);
exit($application->run());
common.neon:
extensions:
dbal: Nextras\Dbal\Bridges\NetteDI\DbalExtension
console: Contributte\Console\DI\ConsoleExtension(%consoleMode%)
migrations: Nextras\Migrations\Bridges\NetteDI\MigrationsExtension
migrations:
dir: %appDir%/../migrations # migrations base directory
driver: mysql # pgsql or mysql
dbal: nextras # nextras, nette, doctrine or dibi
withDummyData: %debugMode%
console:
name: Acme Project
version: 1.0
catchExceptions: true
autoExit: true
url: https://contributte.com
composer.json:
"require":
"php": ">= 7.2",
"nette/application": "^3.1",
"nette/bootstrap": "^3.1",
"nette/caching": "^3.1",
"nette/database": "^3.1",
"nette/di": "^3.0",
"nette/finder": "^2.5",
"nette/forms": "^3.1",
"nette/http": "^3.1",
"nette/mail": "^3.1",
"nette/robot-loader": "^3.3",
"nette/security": "^3.1",
"nette/utils": "^3.2",
"latte/latte": "^2.9",
"tracy/tracy": "^2.9",
"contributte/translation": "^0.9.3",
"nextras/migrations": "^3.2",
"contributte/console": "^0.9.2",
"nextras/dbal": "^4.0"
Po spusteni php bin/console migration:create:
In Connection.php line 80:
SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)
In Connection.php line 80:
SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)
Kde robim chybu? Nette mi normalne s databazou funguje.
Vdaka
Editoval ikoon (8. 2. 2023 20:54)
- nightfish
- Člen | 516
@ikoon Alternativně asi můžeš přidat databázovou konfiguraci pro
nextras/dbal
, když jej máš také nainstalovaný, ale pak budeš
muset udržovat konfiguraci stejnou, jako pro Nette Database – osobně bych
se tedy této cestě spíš vyhnul.
dbal:
driver: mysqli
host: localhost
port: 3306
database: your-project
username: db-username
password: db-password
connectionTz: Europe/Prague
- ikoon
- Člen | 80
@nightfish
zmenil som to na nette a robi mi to to iste, nevie sa prihlasit na DB
In Connection.php line 80:
SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)
Exception trace:
at /home/user/projekt/vendor/nette/database/src/Database/Connection.php:80
PDO->__construct() at /home/user/projekt/vendor/nette/database/src/Database/Connection.php:80
Nette\Database\Connection->connect() at /home/user/projekt/vendor/nette/database/src/Database/Connection.php:68
Nette\Database\Connection->__construct() at /home/user/projekt/temp/cache/nette.configurator/Container_f16809c00b.php:276
Container_f16809c00b->createServiceDatabase__default__connection() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:210
Nette\DI\Container->createService() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:126
Nette\DI\Container->getService() at /home/user/projekt/temp/cache/nette.configurator/Container_f16809c00b.php:415
Container_f16809c00b->createServiceMigrations__dbal() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:210
Nette\DI\Container->createService() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:126
Nette\DI\Container->getService() at /home/user/projekt/temp/cache/nette.configurator/Container_f16809c00b.php:421
Container_f16809c00b->createServiceMigrations__driver() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:210
Nette\DI\Container->createService() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:126
Nette\DI\Container->getService() at /home/user/projekt/temp/cache/nette.configurator/Container_f16809c00b.php:396
Container_f16809c00b->createServiceMigrations__continueCommand() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:210
Nette\DI\Container->createService() at /home/user/projekt/vendor/nette/di/src/DI/Container.php:126
Nette\DI\Container->getService() at /home/user/projekt/vendor/contributte/console/src/CommandLoader/ContainerCommandLoader.php:41
Contributte\Console\CommandLoader\ContainerCommandLoader->get() at /home/user/projekt/vendor/symfony/console/Application.php:596
Symfony\Component\Console\Application->has() at /home/user/projekt/vendor/symfony/console/Application.php:792
Symfony\Component\Console\Application->all() at /home/user/projekt/vendor/symfony/console/Descriptor/ApplicationDescription.php:91
Symfony\Component\Console\Descriptor\ApplicationDescription->inspectApplication() at /home/user/projekt/vendor/symfony/console/Descriptor/ApplicationDescription.php:68
Symfony\Component\Console\Descriptor\ApplicationDescription->getCommands() at /home/user/projekt/vendor/symfony/console/Descriptor/TextDescriptor.php:200
Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication() at /home/user/projekt/vendor/symfony/console/Descriptor/Descriptor.php:55
Symfony\Component\Console\Descriptor\Descriptor->describe() at /home/user/projekt/vendor/symfony/console/Helper/DescriptorHelper.php:65
Symfony\Component\Console\Helper\DescriptorHelper->describe() at /home/user/projekt/vendor/symfony/console/Command/ListCommand.php:75
Symfony\Component\Console\Command\ListCommand->execute() at /home/user/projekt/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at /home/user/projekt/vendor/symfony/console/Application.php:1040
Symfony\Component\Console\Application->doRunCommand() at /home/user/projekt/vendor/symfony/console/Application.php:301
Symfony\Component\Console\Application->doRun() at /home/user/projekt/vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at /home/user/projekt/bin/console:8
- ikoon
- Člen | 80
@nightfish
Este otazka ak mozem. Dal som migrations:create structures users, ono to
vygenerovalo prazdny subor. Aj s parametrom –diff je prazny. Myslel som, ze
mi to bude generovat z existujucej DB strukturu. To mam rucne tam pisat, ako sa
vytvoria tabulky? Z „navodu“ som nejak nezmudrel.
- Marek Bartoš
- Nette Blogger | 1260
Zmena, vymazal som cache a uz to ide
Zapni si debug mód pro konzoli na localhostu, ušetříš si tak spoustu
trápení s cache.
Doporučuju přes env proměnnou https://github.com/…cs/README.md#…
Dal som migrations:create structures users, ono to vygenerovalo prazdny subor
Pro vytvoření diffu je potřeba databázová vrstva, která to umí. Což Nette ani Nextras nejsou. Je to tam teď víceméně jen pro Doctrine. Používá to diff z Doctrine, který porovnává aktuální strukturu databáze s entitami a generuje migrace pro synchronizaci databáze s aktuální strukturou entit.
Editoval Marek Bartoš (9. 2. 2023 18:33)