4 ms·
All of them. It would be part of your migration process. Let's say you want users to have multiple emails, your scripts would be as follows: multiple_emails.u
by zepolen 8y ago
All of them. It would be part of your migration process.
Let's say you want users to have multiple emails, your scripts would be as follows:
multiple_emails.up.sql:
CREATE TABLE user_emails (
user_id INT NOT NULL REFERENCES (users.id),
email VARCHAR NOT NULL
);
INSERT INTO user_emails SELECT id, email FROM users;
ALTER TABLE users DROP COLUMN email;
multiple_emails.down.sql:
ALTER TABLE users ADD COLUMN email VARCHAR;
INSERT INTO users SELECT id, email FROM users;
DROP TABLE user_emails;