Create a gist now

Instantly share code, notes, and snippets.

Example sql migration for late Beta Drupal 8 to 8.01
-- Commands run whilst in the new database, the original datbase is call 'old'
-- NOTE this is an example original table etc. will need to be investigate with describe etc.
INSERT INTO taxonomy_index SELECT * FROM old.taxonomy_index;
INSERT INTO taxonomy_term_data SELECT * FROM old.taxonomy_term_data;
INSERT INTO taxonomy_term_field_data SELECT * FROM old.taxonomy_term_field_data;
INSERT INTO taxonomy_term_hierarchy SELECT * FROM old.taxonomy_term_hierarchy;
INSERT INTO node SELECT nid, vid, type, uuid, 'en' FROM old.node;
INSERT INTO node__body SELECT * FROM old.node__body;
INSERT INTO node__comment SELECT * FROM old.node__comment;
INSERT INTO node__field_blog_tags SELECT * FROM old.node__field_blog_tags;
INSERT INTO node__field_image SELECT * FROM old.node__field_image;
INSERT INTO node__field_tags SELECT * FROM old.node__field_tags;
INSERT INTO node_field_data SELECT nid, vid, type, langcode, title, uid, status, created, changed, promote, sticky, NULL, default_langcode FROM old.node_field_data;
INSERT INTO node_field_revision SELECT nid, vid, langcode, title, uid, status, created, changed, promote, sticky, NULL, default_langcode FROM old.node_field_revision;
INSERT INTO node_revision SELECT * FROM old.node_revision;
INSERT INTO node_revision__body SELECT * FROM old.node_revision__body;
INSERT INTO node_revision__comment SELECT * FROM old.node_revision__comment;
INSERT INTO node_revision__field_blog_tags SELECT * FROM old.node_revision__field_blog_tags;
INSERT INTO node_revision__field_image SELECT * FROM old.node_revision__field_image;
INSERT INTO comment SELECT * FROM old.comment;
INSERT INTO comment__comment_body SELECT * FROM old.comment__comment_body;
INSERT INTO comment_entity_statistics SELECT * FROM old.comment_entity_statistics;
INSERT INTO comment_field_data SELECT * FROM old.comment_field_data;
-- Picked up some other comment bundles in previous mongrel site? eg. comment_node_blog
-- Setting the bundle comment in all cases fixes errors in the new site.
UPDATE comment__comment_body SET bundle = 'comment';
-- und has gone out of fashion, set my comments to default language
UPDATE comment__comment_body SET langcode = 'en' where langcode = 'und';
-- url aliases, I already had a couple eg. about so didn't need the first 2
INSERT into url_alias select * from old.url_alias where pid > 2;
-- just realised that url_aliases now start with the leading '/'
UPDATE url_alias SET source = CONCAT('/', source), alias = CONCAT('/', alias) WHERE pid > 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment