How to alter table to have uuid?

iddpanganibaniddpanganiban Community Edition User

We are trying to migrate this table from the dev server to production server, the table have a uuid as a column

Tagged:

Answers

  • marcothesanemarcothesane - Select Field - Administrator

    If your table is:

    CREATE TABLE migrate_me (
      id        UUID NOT NULL DEFAULT UUID_GENERATE()
    , fname VARCHAR(32)
    , lname  VARCHAR(32)
    );
    

    Then, if you use CSV files for the migration, export all columns to CSV, create the same table on the other side and perform a normal COPY migrate_me FROM '/data/migrate_me.csv' DELIMITER ',' /* or whatever applies */[...];.

    If you had no UUID at the source (I did not figure that out exactly from your question), like so:

    CREATE TABLE migrate_me (
      fname VARCHAR(32)
    , lname  VARCHAR(32)
    );
    

    , then also export all columns you have, create the table like so on the other side:

    CREATE TABLE migrate_me (
      id        UUID NOT NULL DEFAULT UUID_GENERATE()
    , fname VARCHAR(32)
    , lname  VARCHAR(32)
    );
    

    , and copy the CSV file like so:

    COPY migrate_me (
      fname
    , lname
    )
    FROM '/data/migrate_me.csv' DELIMITER ','
    [...]
    ;
    
  • iddpanganibaniddpanganiban Community Edition User

    thanks for the response sir @marcothesane

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file