I have a table order with such fields id, name, email, order_id etc.
I want create new table user and transfer name, email data from order table and create relation oneToMany (user -> order) and add new column to order table user_id which relate to user table I wrote migration script for a new table
class UserMigration implements Migration, RenameExtensionAwareInterface
{
/**
* @param Schema $schema
* @param QueryBag $queries
* @return void
*/
public function up(Schema $schema, QueryBag $queries)
{
$table = $schema->createTable('user');
$table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('name', 'string', ['length' => 65]);
$table->addColumn('email', 'string', ['notnull' => false, 'length' => 129]);
$table->addColumn('createdAt', 'datetime');
$table->setPrimaryKey(['id']);
}
}
But I can’t find information how to correct get data fromn exits table and insert into new and in table order add FK(user_id). I used this doc https://github.com/orocrm/platform/tree/master/src/Oro/Bundle/MigrationBundle
if both user and order are your own entities - you should check doctrine documentation about migrations and fixtures, if you'd like to create relation from magento order, you should use extend extension in your migration, see examples in other orocrm bundle's migrations.