Questions tagged [yii-migrations]

This tag covers database migrations for Yii, a modern PHP framework that supports

For more information see the Yii documentation for database migrations.

19 questions
3
votes
1 answer

Yii2 why using status constant 10 instead of 1?

I'm just beginning developing with the Yii 2 Framework, and installed the officially advanced app . The migration script of the user table defines '10' as the default value for the column 'status'. 'status' =>…
mfgmicha
  • 3,784
  • 1
  • 25
  • 26
3
votes
1 answer

"Failed to open stream" error, when creating new migration

I'm trying to use the yii migration system but I'm stuck on this error when I execute this command: ./yiic migrate create basic_data_migrate I get this error: PHP Error[2]:…
Dhinesh.B
  • 461
  • 4
  • 10
  • 20
3
votes
5 answers

Create a column with primary key using migrations

I am using migrations in Yii to create a new column with. My code works fine however, I am unsure how to set a primary key? This is a part from my migration file: public function up() { $this->addColumn( 'competition_prizes', …
Zabs
  • 13,852
  • 45
  • 173
  • 297
2
votes
2 answers

CConsoleApplication.defaultController not defined when creating new migration

I'm trying to use the yii migration system but I'm stuck on this error when I execute this commande: yiic migrate create add_table_test I get this error: exception 'CException' with message 'Property CConsoleApplication.defaultController" is not…
Michaël
  • 1,120
  • 1
  • 15
  • 30
1
vote
3 answers

Yii2 Migration error - Unknown command: migrate\create Did you mean "migrate/create"?

I am learning database migration in Yii2. I am trying to create a new migration class create_news_table using command through composer. I installed composer globally and running command yii migrate/create create_news_table I copied this command…
Ninja Turtle
  • 1,293
  • 2
  • 24
  • 50
1
vote
1 answer

CDbCommand::createCommand() returns zero affected rows inside migration

This code works just fine (all database items updated as expected): foreach($idMap as $menuId=>$pageId) { $sql = "UPDATE `menus_items` SET link = '/content/show?id=".$pageId."' WHERE id = ".$menuId."; "; $affectedRows =…
trejder
  • 17,148
  • 27
  • 124
  • 216
1
vote
3 answers

"migration directory does not exist" error when running Yii-user extension's migrations

I have a Yii framework installed by Composer, webapp in public_html folder and all libraries in vendor folder: webroot | |_public_html | |_vendor | |_fierwebdesign | |_yii-user | |_migrations My configuration in console.php…
0
votes
1 answer

Fetch data for a select query in yii migrations

I am creating a parent child table using yii migration where there is a foreign key on the child table. I tried using execute but that did not help me fetching the data needed. Is there a way I can query the parent table and insert the parent id on…
Rebecca
  • 403
  • 2
  • 7
  • 29
0
votes
1 answer

How fix the error 'Exception' when execute yii migrate?

I try to run a yii2 basic project with docker in macOS BigSur. This is my docker-compose.yml: version: '2' services: php: image: yiisoftware/yii2-php:7.4-apache volumes: - ~/.composer-docker/cache:/root/.composer/cache:delegated …
0
votes
1 answer

How to switch PHP versions in environment variables?

Since I'm required to work on both PHP5.x and PHP7.x projects in Yii framework, I've installed WAMP. I've also set up my environment variables to link to both paths containing php.exe and for just working with the projects, that's just…
kurt
  • 11
  • 5
0
votes
0 answers

Yii2 migration configException error

Suddenly any of the migration command is not working in my project and i don't know why. following is the errors in cmd. C:\wamp64\www\project>yii migrate Exception 'yii\base\InvalidConfigException' with message 'Failed to instantiate component or…
Muhammad Umair
  • 103
  • 1
  • 12
0
votes
1 answer

work with two databases in yii 2

I have two database with these config file 'db' => require(__DIR__ . '/db.php'), 'db2' => require(__DIR__ . '/db2.php'), db.php file return [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;port=**;dbname=**', 'username' =>…
0
votes
1 answer

how to duplicate column a data to column b using yii migration

alter table user add column join_date datetime; UPDATE user SET join_date = date_created; By using the code above, I am able to add a new column to the table and set join_date column to have same data as those in date created. How can i perform…
CloudSeph
  • 863
  • 4
  • 15
  • 36
0
votes
1 answer

Error Running yii migrate after cloning

I'm using the basic template for Yii2. I created the project and uploaded it to github so other devs can clone and start contributing. After cloning and running composer install, I'm getting this error when I try to run yii migrate. λ php yii…
pollos
  • 3
  • 2
0
votes
0 answers

Can I use Yii2 migration without a SQL db component? (I'm using only Redis)

I'm trying to configure a new Yii2 project to work only using Redis Active Record (http://www.yiiframework.com/doc-2.0/yii-redis-activerecord.html). Redis is not supported like a regular db. My migration will setup the first user of the application.…
otaviofcs
  • 785
  • 2
  • 6
  • 16
1
2