yii2-gii
yii2-gii copied to clipboard
gii/crud has been generate view based at the old structure of model (cached data)
This issue has originally been reported by @bscheshirwork at https://github.com/yiisoft/yii2/issues/14210. Moved here by @samdark.
What steps will reproduce the problem?
- gii: generate model
- gii: generate crud based at model
- change table schema (drop+create table in
dbusing migration mechanism) and
Yii::$app->db->schema->refresh();
- gii: generate model
- gii: generate crud based at model
What is the expected result?
new views (and search model) in previews & generate result
What do you get instead?
old views (same at previous)
Additional info
after console command
./yii cache/flush-schema
Flush cache schema for "db" connection? (yes|no) [no]:yes
Schema cache for component "db", was flushed.
all is ok.
| Q | A |
|---|---|
| Yii version | 2.0.? dev-master 55c0799 |
| PHP version | 7.1.5 |
| Operating system | alpine |
are you using APC cache?
I will install APCu and don't change configuration or settings of cache component (default yii2-advanced template settings)
https://github.com/bscheshirwork/docker-php/blob/master/yii2-alpine/Dockerfile#L67
'cache' => [
'class' => 'yii\caching\FileCache',
],
./yii cache/index
The following caches were found in the system:
* cache (yii\caching\FileCache)
So...
docker exec -ti dockerrun_php_1 php -i |grep 'apc.enable_cli'
apc.enable_cli => Off => Off
docker exec -ti dockerrun_php_1 php ./requirements.php
...
APC extension: WARNING!!!
Required by: ApcCache
This is can be as reason?
Console command migration and console command cache is not both use same CLI? Or use someone API?
If you flush cache on CLI but web is running in another container, that will have no effect. This is often the case with ApcCache, but can also occur with FileCache when files are located in different locations or containers.
That said, given that Gii is a dev tool we might add a flush schema cache call in the generator to ensure to always generate files from current schema.
Hm... backend db cache is a different/separate and don't flush after flush console db schema cache?
Console run migrate with
Yii::$app->db->schema->refresh();
Has no effect to backend caches Yii::$app->db->schema and/or frontend and any of this is isolate...
I must use
(new \yii\console\controllers\CacheController('cache', Yii::$app->module))->actionFlushSchema();
to clear all (is 3min for advances) version of db cache?
Oh... Its same command
$connection = Yii::$app->get($db, false);
...
$schema = $connection->getSchema();
$schema->refresh();
and run all console command in same container
But it's work... %)
What else? Gii cache in high level don't clear if low-level db cache flush? %)