出于集成測(cè)試目的,我正在嘗試為測(cè)試環(huán)境創(chuàng)建一個(gè) sqlite db,但是當(dāng)我運(yùn)行時(shí),php bin/console doctrine:schema:create --env=test我收到表已經(jīng)存在的錯(cuò)誤。我想是因?yàn)樗](méi)有真正創(chuàng)建一個(gè)新的測(cè)試數(shù)據(jù)庫(kù),而是繼續(xù)現(xiàn)有的數(shù)據(jù)庫(kù)??雌饋?lái)它不是從 env.test 讀取的。我doctrine.yaml在配置/測(cè)試中創(chuàng)建了一個(gè)這樣的:doctrine:dbal: driver: 'pdo_sqlite' url: 'sqlite:///%kernel.project_dir%/var/data/test.sqlite'創(chuàng)建sqlite測(cè)試數(shù)據(jù)庫(kù)我缺少什么?我在錯(cuò)誤中遇到的奇怪事情:In PDOConnection.php line 90: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_menu' already exists 為什么是 SQL?不應(yīng)該是 SQLite 的 IT,對(duì)嗎?在 config/packages/doctrine.yaml 中,我有:parameters:# Adds a fallback DATABASE_URL if the env var is not set.# This allows you to run cache:warmup even if your# environment variables are not available yet.# You should not need to change this value.env(DATABASE_URL): ''doctrine:dbal: # configure these for your database server connections: gui: driver: 'pdo_mysql' server_version: '5.7' charset: utf8mb4 default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci url: '%env(resolve:DATABASE_GUI_URL)%' upv6: driver: 'pdo_mysql' server_version: '5.7' charset: utf8mb4 default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci url: '%env(resolve:DATABASE_UPV6_URL)%'orm: auto_generate_proxy_classes: true # <- change to true proxy_dir: '%kernel.cache_dir%/doctrine/orm/Proxies' proxy_namespace: Proxies entity_managers: gui: connection: gui mappings: Gui: is_bundle: false type: annotation dir: '%kernel.project_dir%/src/Entity/Gui' prefix: 'App\Entity\Gui'
Symfony 4 sqlite 數(shù)據(jù)庫(kù)創(chuàng)建測(cè)試環(huán)境
函數(shù)式編程
2021-06-22 17:08:57