Answers.Body: <p>If you want to be future-proof, then yes - you should create a new UUID for each new row.</p>
  
  <p>You can use MySQL's <a href="https://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_uuid" rel="nofollow">uuid()</a> method for that.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-15T14:57:18.160Z
Answers.LastActivityDate: 2015-05-15T14:57:18.160Z
Answers.UserDisplayName: Brad Bell
Body: <p>I want to migrate some entries and its content to a new table in our plugin. Below is a simplified SQL that seems to do the trick.</p>
  
  <pre><code>insert into craft_myplugintable(id, field1, field2, field3, dateCreated, dateUpdated, uid)
  select entries.id, content.field_field1, content.field_field2, content.field_field3, entries.dateCreated, entries.dateUpdated, entries.uid
  from craft_elements elements
    join craft_entries entries on elements.id = entries.id
    join craft_entrytypes types on entries.typeId = types.id
    join craft_content content on entries.id = content.elementId
  where types.handle = 'mySection';
  
  update craft_elements elements
    join craft_myplugintable myplugin on elements.id = myplugin.id
  set type = 'Plugin_ElementType';
  </code></pre>
  
  <p>Is this method safe? Should i use a migration file and let craft set the UID? I'm not sure what the UID field is for. Keep in mind that we no longer need the entries, so they can be deleted if this is wrong.</p>
  
Tags: <plugin-development><migration>
Title: Migrating entries to custom element and UID
ThreadText: # Migrating entries to custom element and UID
  
  (Asked by: username_0 on 2015-05-15)
  
  I want to migrate some entries and its content to a new table in our plugin. Below is a simplified SQL that seems to do the trick.
  
  ```
  insert into craft_myplugintable(id, field1, field2, field3, dateCreated, dateUpdated, uid)
  select entries.id, content.field_field1, content.field_field2, content.field_field3, entries.dateCreated, entries.dateUpdated, entries.uid
  from craft_elements elements
    join craft_entries entries on elements.id = entries.id
    join craft_entrytypes types on entries.typeId = types.id
    join craft_content content on entries.id = content.elementId
  where types.handle = 'mySection';
  
  update craft_elements elements
    join craft_myplugintable myplugin on elements.id = myplugin.id
  set type = 'Plugin_ElementType';
  
  ```
  
  Is this method safe? Should i use a migration file and let craft set the UID? I'm not sure what the UID field is for. Keep in mind that we no longer need the entries, so they can be deleted if this is wrong.
  
  **Tags:** plugin-development, migration
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-05-15. Score: 1 | Accepted answer
  
  If you want to be future-proof, then yes - you should create a new UUID for each new row.
  
  You can use MySQL's [uuid()](https://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_uuid) method for that.
  
  
  ---
  
  