Fork me on GitHub
#sql
<
2023-11-06
>
Eugen14:11:52

help with migratus early feedback program anyone? We are working on some quality of life improvements for migratus + devops . We have some early work and would like some feedback . The PR is here https://github.com/yogthos/migratus/pull/252 . You should check out the guide https://github.com/yogthos/migratus/blob/3af6f4f9564b6e74970578d5913c008ab08decc6/examples/postgres/README.md What you can expect: • usage via cli even from babashka task • configuration via ENV, config file, etc • basic config and cli validation • status and list commands for migrations Everything is in progress, but if you do try it out, leave some comments on the PR. Thanks, cc @yogthos

pavlosmelissinos14:11:59

Postgres: I want to clone a table (including a. data and b. constraints/indexes/defaults etc) I've narrowed it down to: 1. CREATE TABLE x_clone LIKE x INCLUDING ALL, which takes care of b but not a 2. CREATE TABLE x_clone AS x, which takes care of a but not b What's the best way to combine them? Run 1 and then INSERT INTO the data row by row or run 2 first and add any schema-related stuff later? Happy to be told there's a third, better way 🙂 The table is smallish (much less than 1M rows) but the indexes are complex

igrishaev14:11:08

Cloning the data row by row in not necessarily. You just insert from select:

insert into table_b select * from table_a

pavlosmelissinos15:11:39

Oh, that's nice So is that what you'd recommend? CREATE TABLE x_clone LIKE x INCLUDING ALL, followed by insert into x_clone select * from x?

igrishaev15:11:52

Yes, the first query clones the schema and indexes, and the second one clones the data

👍 1