123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896 |
- <?php
- /**
- * @file
- * Install setup for the migration example module.
- *
- * Set up source data and destination configuration for the migration example
- * module. We do this in a separate module so migrate_example_advanced itself is
- * a pure migration module.
- */
- /**
- * Implements hook_schema().
- */
- function migrate_example_advanced_setup_schema() {
- $schema['migrate_example_advanced_account'] = migrate_example_advanced_schema_account();
- $schema['migrate_example_advanced_account_updates'] = migrate_example_advanced_schema_account_updates();
- $schema['migrate_example_advanced_categories'] = migrate_example_advanced_schema_categories();
- $schema['migrate_example_advanced_vintages'] = migrate_example_advanced_schema_vintages();
- $schema['migrate_example_advanced_variety_updates'] = migrate_example_advanced_schema_variety_updates();
- $schema['migrate_example_wine'] = migrate_example_advanced_schema_wine();
- $schema['migrate_example_advanced_updates'] = migrate_example_advanced_schema_updates();
- $schema['migrate_example_advanced_producer'] = migrate_example_advanced_schema_producer();
- $schema['migrate_example_advanced_category_wine'] = migrate_example_advanced_schema_category_wine();
- $schema['migrate_example_advanced_category_producer'] = migrate_example_advanced_schema_category_producer();
- $schema['migrate_example_advanced_comment'] = migrate_example_advanced_schema_comment();
- $schema['migrate_example_advanced_comment_updates'] = migrate_example_advanced_schema_comment_updates();
- $schema['migrate_example_advanced_files'] = migrate_example_advanced_schema_files();
- $schema['migrate_example_advanced_blobs'] = migrate_example_advanced_schema_blobs();
- $schema['migrate_example_advanced_table_source'] = migrate_example_advanced_schema_table_source();
- $schema['migrate_example_advanced_table_dest'] = migrate_example_advanced_schema_table_dest();
- return $schema;
- }
- /**
- * Implements hook_install().
- */
- function migrate_example_advanced_setup_install() {
- // Populate our tables.
- migrate_example_advanced_data_account();
- migrate_example_advanced_data_account_updates();
- migrate_example_advanced_data_categories();
- migrate_example_advanced_data_vintages();
- migrate_example_advanced_data_variety_updates();
- migrate_example_advanced_data_wine();
- migrate_example_advanced_data_updates();
- migrate_example_advanced_data_producer();
- migrate_example_advanced_data_category_wine();
- migrate_example_advanced_data_category_producer();
- migrate_example_advanced_data_comment();
- migrate_example_advanced_data_comment_updates();
- migrate_example_advanced_data_files();
- migrate_example_advanced_data_blobs();
- migrate_example_advanced_data_table_source();
- }
- function migrate_example_advanced_schema_wine() {
- return [
- 'description' => 'Wines of the world',
- 'fields' => [
- 'wineid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Wine ID',
- ],
- 'name' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- ],
- 'body' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Full description of the wine.',
- ],
- 'excerpt' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Abstract for this wine.',
- ],
- 'accountid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'ID of the author.',
- ],
- 'posted' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Original creation date',
- ],
- 'last_changed' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Last change date',
- ],
- 'variety' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Wine variety',
- ],
- 'region' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Wine region',
- ],
- 'rating' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Rating (100-point scale)',
- ],
- ],
- 'primary key' => ['wineid'],
- ];
- }
- function migrate_example_advanced_schema_updates() {
- return [
- 'description' => 'Updated wine ratings',
- 'fields' => [
- 'wineid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Wine ID',
- ],
- 'rating' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Rating (100-point scale)',
- ],
- ],
- 'primary key' => ['wineid'],
- ];
- }
- function migrate_example_advanced_schema_producer() {
- return [
- 'description' => 'Wine producers of the world',
- 'fields' => [
- 'producerid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Producer ID',
- ],
- 'name' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- ],
- 'body' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Full description of the producer.',
- ],
- 'excerpt' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Abstract for this producer.',
- ],
- 'accountid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Account ID of the author.',
- ],
- ],
- 'primary key' => ['producerid'],
- ];
- }
- function migrate_example_advanced_schema_categories() {
- return [
- 'description' => 'Categories',
- 'fields' => [
- 'categoryid' => [
- 'type' => 'int',
- 'not null' => TRUE,
- 'unsigned' => TRUE,
- 'description' => 'Category ID',
- ],
- 'type' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'Type of category: variety, region, best_with',
- ],
- 'name' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- ],
- 'details' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- ],
- 'category_parent' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Parent category, if any',
- ],
- 'ordering' => [
- 'type' => 'int',
- 'unsigned' => FALSE,
- 'not null' => FALSE,
- 'description' => 'Order in which to display categories',
- ],
- ],
- 'primary key' => ['categoryid'],
- ];
- }
- function migrate_example_advanced_schema_vintages() {
- return [
- 'description' => 'Wine vintages',
- 'fields' => [
- 'wineid' => [
- 'type' => 'int',
- 'not null' => TRUE,
- 'description' => 'Wine ID',
- ],
- 'vintage' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Vintage (year)',
- ],
- ],
- 'primary key' => ['wineid', 'vintage'],
- ];
- }
- function migrate_example_advanced_schema_variety_updates() {
- return [
- 'description' => 'Variety updates',
- 'fields' => [
- 'categoryid' => [
- 'type' => 'int',
- 'not null' => TRUE,
- 'unsigned' => TRUE,
- 'description' => 'Category ID',
- ],
- 'details' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- ],
- ],
- 'primary key' => ['categoryid'],
- ];
- }
- function migrate_example_advanced_schema_category_wine() {
- return [
- 'description' => 'Wine category assignments',
- 'fields' => [
- 'wineid' => [
- 'type' => 'int',
- 'not null' => TRUE,
- 'description' => 'Wine ID',
- ],
- 'categoryid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Category ID',
- ],
- ],
- 'primary key' => ['categoryid', 'wineid'],
- ];
- }
- function migrate_example_advanced_schema_category_producer() {
- return [
- 'description' => 'Producer category assignments',
- 'fields' => [
- 'producerid' => [
- 'type' => 'int',
- 'not null' => TRUE,
- 'description' => 'Producer ID',
- ],
- 'categoryid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Category ID',
- ],
- ],
- 'primary key' => ['categoryid', 'producerid'],
- ];
- }
- function migrate_example_advanced_schema_comment() {
- return [
- 'description' => 'Wine comments',
- 'fields' => [
- 'commentid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Comment ID',
- ],
- 'wineid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Wine ID that is being commented upon',
- ],
- 'comment_parent' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Parent comment ID in case of comment replies.',
- ],
- 'subject' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Comment subject',
- ],
- 'body' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Comment body',
- ],
- 'name' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Comment name (if anon)',
- ],
- 'mail' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Comment email (if anon)',
- ],
- 'accountid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Account ID (if any).',
- ],
- 'commenthost' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'IP/domain of host posted from',
- ],
- 'userpage' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'User homepage',
- ],
- 'posted' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Date comment posted',
- ],
- 'lastchanged' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Date comment last changed',
- ],
- ],
- 'primary key' => ['commentid'],
- ];
- }
- function migrate_example_advanced_schema_comment_updates() {
- return [
- 'description' => 'Wine comment updates',
- 'fields' => [
- 'commentid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Comment ID',
- ],
- 'subject' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Comment subject',
- ],
- ],
- 'primary key' => ['commentid'],
- ];
- }
- function migrate_example_advanced_schema_account() {
- return [
- 'description' => 'Wine accounts.',
- 'fields' => [
- 'accountid' => [
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Account ID',
- ],
- 'status' => [
- 'type' => 'int',
- 'not null' => TRUE,
- 'description' => 'Blocked_Allowed',
- ],
- 'posted' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'Registration date',
- ],
- 'last_access' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'Last access date',
- ],
- 'last_login' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'Last login date',
- ],
- 'name' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Account name (for login)',
- ],
- 'sex' => [
- 'type' => 'char',
- 'length' => 1,
- 'not null' => FALSE,
- 'description' => 'Gender',
- ],
- 'password' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Account password (raw)',
- ],
- 'mail' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Account email',
- ],
- 'original_mail' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Original account email',
- ],
- 'sig' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'Signature for comments',
- ],
- 'imageid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Image ID',
- ],
- 'positions' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Positions held',
- ],
- ],
- 'primary key' => ['accountid'],
- ];
- }
- function migrate_example_advanced_schema_account_updates() {
- return [
- 'description' => 'Wine account updates',
- 'fields' => [
- 'accountid' => [
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Account ID',
- ],
- 'sex' => [
- 'type' => 'char',
- 'length' => 1,
- 'not null' => FALSE,
- 'description' => 'Gender',
- ],
- ],
- 'primary key' => ['accountid'],
- ];
- }
- function migrate_example_advanced_schema_blobs() {
- return [
- 'description' => 'Wine blobs to be migrated to file entities',
- 'fields' => [
- 'imageid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Image ID',
- ],
- 'imageblob' => [
- 'type' => 'blob',
- 'size' => 'normal',
- 'description' => 'binary image data',
- ],
- ],
- 'primary key' => ['imageid'],
- ];
- }
- function migrate_example_advanced_schema_files() {
- return [
- 'description' => 'Wine and account files',
- 'fields' => [
- 'imageid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Image ID',
- ],
- 'url' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'Image URL',
- ],
- 'image_alt' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Image alt',
- ],
- 'image_title' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Image title',
- ],
- 'wineid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => FALSE,
- 'description' => 'Wine node this is associated with',
- ],
- ],
- 'primary key' => ['imageid'],
- ];
- }
- function migrate_example_advanced_schema_table_source() {
- return [
- 'description' => 'Source data to go into a custom Drupal table',
- 'fields' => [
- 'fooid' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Primary key',
- ],
- 'field1' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'First field',
- ],
- 'field2' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Second field',
- ],
- ],
- 'primary key' => ['fooid'],
- ];
- }
- function migrate_example_advanced_schema_table_dest() {
- return [
- 'description' => 'Custom Drupal table to receive source data directly',
- 'fields' => [
- 'recordid' => [
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Primary key',
- ],
- 'drupal_text' => [
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'description' => 'First field',
- ],
- 'drupal_int' => [
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'Second field',
- ],
- ],
- 'primary key' => ['recordid'],
- ];
- }
- function migrate_example_advanced_data_wine() {
- $fields = ['wineid', 'name', 'body', 'excerpt', 'accountid',
- 'posted', 'last_changed', 'variety', 'region', 'rating'];
- $query = db_insert('migrate_example_wine')
- ->fields($fields);
- $data = [
- [1, 'Montes Classic Cabernet Sauvignon', 'Intense ruby-red color', 'Great!', 9,
- strtotime('2010-01-02 03:04:05'), strtotime('2010-03-04 05:06:07'), 25, 17, 95],
- [2, 'Archeo Ruggero di Tasso Nero d\'Avola', 'Lots of berry character', 'Pair with red sauced dishes', 3,
- strtotime('2010-09-03 18:23:58'), strtotime('2010-09-03 18:23:58'), 26, 2, 85],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_updates() {
- $fields = ['wineid', 'rating'];
- $query = db_insert('migrate_example_advanced_updates')
- ->fields($fields);
- $data = [
- [1, 93],
- [2, NULL],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_producer() {
- $fields = ['producerid', 'name', 'body', 'excerpt', 'accountid'];
- $query = db_insert('migrate_example_advanced_producer')
- ->fields($fields);
- $data = [
- [1, 'Montes', 'Fine Chilean winery', 'Great!', 9],
- [2, 'Archeo', 'Sicilia!', NULL, 3],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_account() {
- $fields = ['accountid', 'status', 'posted', 'last_access', 'last_login',
- 'name', 'sex', 'password', 'mail', 'original_mail', 'sig', 'imageid', 'positions'];
- $query = db_insert('migrate_example_advanced_account')
- ->fields($fields);
- $data = [
- [1, 1, '2010-03-30 10:31:05', '2010-04-30 18:25:24', '2010-04-30 14:01:02',
- 'darren', 'M', 'dpass', 'ddarren@example.com', 'darren@example.com',
- 'All about the Australians', NULL, '5'],
- [3, 0, '2007-03-15 10:31:05', '2007-06-10 04:11:38', '2007-06-10 04:11:38',
- 'emily', 'F', 'insecure', 'emily@example.com', 'emily@example.com',
- 'Sommelier to the stars', NULL, '18'],
- [9, 1, '2004-02-29 10:31:05', '2004-02-29 10:31:05', '2004-02-29 10:31:05',
- 'fonzie', NULL, 'bike', 'thefonz@example.com', 'arthur@example.com',
- 'Aaay!', 1, '5,18'],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_account_updates() {
- $fields = ['accountid', 'sex'];
- $query = db_insert('migrate_example_advanced_account_updates')
- ->fields($fields);
- $data = [
- [1, NULL],
- [3, 'M'],
- [9, 'F'],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_comment() {
- $fields = ['commentid', 'wineid', 'comment_parent', 'subject', 'body',
- 'name', 'mail', 'accountid', 'commenthost', 'userpage', 'posted', 'lastchanged'];
- $query = db_insert('migrate_example_advanced_comment')
- ->fields($fields);
- $data = [
- [1, 1, NULL, 'im first', 'Tasty', 'grace', 'grace@example.com', 0,
- '123.456.78.9', 'http:://grace.example.com/',
- strtotime('2010-01-02 03:04:05'), strtotime('2010-04-05 06:07:08')],
- [2, 1, NULL, 'im second', 'Delicious', 'horace', 'horace@example.com', 0,
- 'example.com', NULL,
- strtotime('2010-02-02 03:04:05'), strtotime('2010-05-05 06:07:08')],
- [3, 1, NULL, 'im parent', 'Don\'t care for it', 'irene', 'irene@example.com', 0,
- '254.0.2.5', 'http:://www.example.com/irene',
- strtotime('2010-03-02 03:04:05'), strtotime('2010-03-02 03:04:05')],
- [4, 1, 3, 'im child', 'But it\'s so good!', 'emily', NULL, 3,
- '58.29.126.1', 'http:://www.wine.com/',
- strtotime('2010-01-02 03:04:05'), strtotime('2010-01-02 03:04:05')],
- [5, 1, 4, 'im grandchild', 'Right on, Emily!', 'thefonz@example.com', NULL, 9,
- '123.456.78.9', NULL,
- strtotime('2010-06-02 03:04:05'), strtotime('2010-06-02 03:04:05')],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_comment_updates() {
- $fields = ['commentid', 'subject'];
- $query = db_insert('migrate_example_advanced_comment_updates')
- ->fields($fields);
- $data = [
- [1, 'I am first'],
- [2, 'I am second'],
- [3, 'I am parent'],
- [4, ''],
- [5, 'I am Spartacus'],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_categories() {
- $fields = ['categoryid', 'type', 'name', 'category_parent', 'details', 'ordering'];
- $query = db_insert('migrate_example_advanced_categories')
- ->fields($fields);
- $data = [
- [1, 'variety', 'White wine', NULL, 'White wines are generally simpler and sweeter than red', 3],
- [3, 'variety', 'Red wine', NULL, 'Red wines are generally more complex and "dry" than white', 1],
- [8, 'variety', 'Riesling', 1, 'Associated with Germany', 2],
- [9, 'variety', 'Chardonnay', 1, 'One of the most popular whites', 1],
- [13, 'variety', 'Merlot', 3, 'Very drinkable', 4],
- [14, 'variety', 'Syrah', 3, 'A.k.a. shiraz', -3],
- [25, 'variety', 'Cabernet Sauvignon', 3, 'A basic', -5],
- [26, 'variety', "Nero d'Avola", 3, 'Sicilian specialty', 2],
- [2, 'region', 'Italy', NULL, 'Largest producer of wine', 5],
- [11, 'region', 'Tuscany', 2, NULL, 2],
- [18, 'region', 'Chianti', 11, NULL, -1],
- [19, 'region', 'Elba', 11, NULL, 5],
- [4, 'region', 'France', NULL, 'C\'est bon', 6],
- [5, 'region', 'Bordeaux', 4, NULL, 1],
- [6, 'region', 'Barsac', 5, NULL, 3],
- [7, 'region', 'Pomerol', 5, NULL, 2],
- [16, 'region', 'Chile', NULL, NULL, 3],
- [17, 'region', 'Colchagua Valley', 16, NULL, 1],
- [20, 'region', 'California', NULL, NULL, 5],
- [21, 'region', 'Redwood Valley', 20, NULL, 1],
- [10, 'best_with', 'Beef', NULL, NULL, 5],
- [12, 'best_with', 'Pork', NULL, NULL, -3],
- [15, 'best_with', 'Chicken', NULL, NULL, -5],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_vintages() {
- $fields = ['wineid', 'vintage'];
- $query = db_insert('migrate_example_advanced_vintages')
- ->fields($fields);
- $data = [
- [1, 2006],
- [1, 2007],
- [2, 2001],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_variety_updates() {
- $fields = ['categoryid', 'details'];
- $query = db_insert('migrate_example_advanced_variety_updates')
- ->fields($fields);
- $data = [
- [1, 'White wines are simpler and sweeter than red'],
- [3, 'Red wines are generally more complex and dry than white'],
- [8, 'Usually associated with Germany'],
- [9, NULL],
- [13, 'Common, very drinakable'],
- [14, 'AKA Shiraz'],
- [25, 'Basic'],
- [26, 'A specialty of Sicily'],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_category_wine() {
- $fields = ['wineid', 'categoryid'];
- $query = db_insert('migrate_example_advanced_category_wine')
- ->fields($fields);
- $data = [
- [1, 12],
- [1, 15],
- [2, 10],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_category_producer() {
- $fields = ['producerid', 'categoryid'];
- $query = db_insert('migrate_example_advanced_category_producer')
- ->fields($fields);
- $data = [
- [1, 17],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_files() {
- $fields = ['imageid', 'url', 'image_alt', 'image_title', 'wineid'];
- $query = db_insert('migrate_example_advanced_files')
- ->fields($fields);
- $data = [
- [1, 'http://placekitten.com/200/200', NULL, NULL, NULL],
- [2, 'http://cyrve.com/files/penguin.jpeg', 'Penguin alt', 'Penguin title', 1],
- [3, 'http://cyrve.com/files/rioja.jpeg', 'Rioja alt', 'Rioja title', 2],
- [4, 'http://cyrve.com/files/boutisse_0.jpeg', 'Boutisse alt', 'Boutisse title', 2],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_blobs() {
- $blob = file_get_contents('core/misc/druplicon.png');
- $fields = ['imageid', 'imageblob'];
- $query = db_insert('migrate_example_advanced_blobs')
- ->fields($fields);
- $data = [
- [1, $blob],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
- function migrate_example_advanced_data_table_source() {
- $fields = ['fooid', 'field1', 'field2'];
- $query = db_insert('migrate_example_advanced_table_source')
- ->fields($fields);
- $data = [
- [3, 'Some sample data', 58],
- [15, 'Whatever', 2],
- [646, 'More sample data', 34989],
- ];
- foreach ($data as $row) {
- $query->values(array_combine($fields, $row));
- }
- $query->execute();
- }
|