zipperer / migrate_database_with_michael

0 stars 0 forks source link

Add default values for columns #25

Closed zipperer closed 5 months ago

zipperer commented 7 months ago

e.g. in mailing_list

country defaults to USA add_date defaults to NOW() / today modification_date defaults to NOW() / today

zipperer commented 6 months ago

add_date defaults to NOW() / today modification_date defaults to NOW() / today

We did an example of this in this issue

zipperer commented 6 months ago

country defaults to USA

I have provided a TEXT column with a default value

CREATE TABLE table_with_default_values (
  int_with_default_value INT DEFAULT 514,
  text_with_default_value TEXT DEFAULT 'USA'
);

INSERT INTO table_with_default_values (int_with_default_value) VALUES (2);
-- table includes row with int_with_default_value = 2 and text_with_default_value = 'USA'

INSERT INTO table_with_default_values (text_with_default_value) VALUES ('CAN');
-- table includes row with int_with_default_value = 514 and text_with_default_value = 'CAN'
zipperer commented 6 months ago

postgres documentation for default values

zipperer commented 5 months ago

I close this issue because we have used steps like these. See #35