Skip to content

Remove defaulted id column once pkey has been changed #517

Answered by dantownsend
theelderbeever asked this question in Q&A
Discussion options

You must be logged in to vote

It's a hard one. Piccolo tables needs some kind of primary key, and it doesn't currently have syntax to support composite primary keys.

I came across this article which might help you. It's Citus instead of Timescale, but they're similar enough. Even so, 2 billion rows still meant 20 minutes of downtime which might still be unacceptable.

It's kind of a hack, but you could set primary_key=True on one of your other columns - even though it's not an actual primary key, Piccolo will think it is, and should be happy.

class MyTable(Table):
    my_column = Varchar(primary_key=True)

When you run piccolo migrations new my_app --auto it will generate a migration. If you run it nothing will happen, …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@theelderbeever
Comment options

Answer selected by theelderbeever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants