Re: adding an auto increment column to an existing table

2017-01-18 Thread Chris Withers
On 17/01/2017 15:07, mike bayer wrote: Because there's no data in a brand new table, the server default isn't needed to create the not-null column. No needed, but it is created, isn't that the point of autoincrement=True? for postgresql, autoincrement=True means that if the column is

Re: adding an auto increment column to an existing table

2017-01-10 Thread Chris Withers
Okay, so this worked: op.execute(CreateSequence(Sequence("observation_id_seq"))) op.add_column('observation', sa.Column( 'id', sa.Integer(), nullable=False, server_default=sa.text("nextval('observation_id_seq'::regclass)") )) op.drop_constraint('observation_pkey',

adding an auto increment column to an existing table

2017-01-10 Thread Chris Withers
So, I screwed up and realised I really want an auto-incrementing integer as the primary key for a bunch of tables. I've changed my models, got all the tests passing and now I need to get the migrations done, I have: op.add_column('observation', sa.Column('id', sa.Integer(),