Skip to main content
Question

How to alter table to have uuid?

  • July 16, 2021
  • 2 replies
  • 13 views

iddpanganiban
Forum|alt.badge.img+1

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

2 replies

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • July 16, 2021

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 ','
[...]
;

iddpanganiban
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • July 22, 2021

thanks for the response sir @marcothesane