New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create missing SQL sequences. #3469

Merged
merged 1 commit into from Oct 6, 2017

Conversation

Projects
None yet
2 participants
@jone
Member

jone commented Oct 4, 2017

When creating a new table with a sequence in a schema migration, the sequence is not created automatically. We haven't done that up to now.

  • This change introduces a helper "ensure_sequence_exists", which safely creates a sequences when it is missing.
  • An upgrade step makes sure all currently known sequences exist. The list is created with:
    git grep "Sequence(" | sed -e 's:.*Sequence(.::' -e 's:.).*::' | sort | uniq
  • The last two upgrade steps were updated to ensure the their sequences exist in order to improve the copy/paste experience for future migrations.

⚠️ Please do a careful review as I am no SQL / SQLAlchemy master.

Fixes 4teamwork/gever#114

@jone jone requested a review from 4teamwork/gever Oct 4, 2017

@jone

This comment has been minimized.

Show comment
Hide comment
@jone

jone Oct 5, 2017

Member

@lukasgraf It would be great if you could take a look at this one. I'm not 100% sure if my assumptions and interpretations are correct.

Member

jone commented Oct 5, 2017

@lukasgraf It would be great if you could take a look at this one. I'm not 100% sure if my assumptions and interpretations are correct.

@lukasgraf

This comment has been minimized.

Show comment
Hide comment
@lukasgraf
Member

lukasgraf commented Oct 5, 2017

@lukasgraf

Looks good to me! 👍

@lukasgraf

This comment has been minimized.

Show comment
Hide comment
@lukasgraf

lukasgraf Oct 5, 2017

Member

For cross-checking, current list of sequences on master:

og-core-master=# SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';
           relname
------------------------------
 activities_id_seq
 adresses_id_seq
 agendaitems_id_seq
 archived_address_id_seq
 archived_contact_id_seq
 archived_mail_address_id_seq
 archived_phonenumber_id_seq
 archived_url_id_seq
 committee_id_seq
 contacts_id_seq
 excerpts_id_seq
 generateddocument_id_seq
 locks_id_seq
 mail_adresses_id_seq
 meeting_id_seq
 member_id_seq
 membership_id_seq
 notification_defaults_id_seq
 notifications_id_seq
 org_roles_id_seq
 participation_roles_id_seq
 participations_id_seq
 periods_id_seq
 phonenumber_id_seq
 proposal_id_seq
 resources_id_seq
 submitteddocument_id_seq
 task_id_seq
 teams_id_seq
 urls_id_seq
 watchers_id_seq
(31 rows)
Member

lukasgraf commented Oct 5, 2017

For cross-checking, current list of sequences on master:

og-core-master=# SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';
           relname
------------------------------
 activities_id_seq
 adresses_id_seq
 agendaitems_id_seq
 archived_address_id_seq
 archived_contact_id_seq
 archived_mail_address_id_seq
 archived_phonenumber_id_seq
 archived_url_id_seq
 committee_id_seq
 contacts_id_seq
 excerpts_id_seq
 generateddocument_id_seq
 locks_id_seq
 mail_adresses_id_seq
 meeting_id_seq
 member_id_seq
 membership_id_seq
 notification_defaults_id_seq
 notifications_id_seq
 org_roles_id_seq
 participation_roles_id_seq
 participations_id_seq
 periods_id_seq
 phonenumber_id_seq
 proposal_id_seq
 resources_id_seq
 submitteddocument_id_seq
 task_id_seq
 teams_id_seq
 urls_id_seq
 watchers_id_seq
(31 rows)
@lukasgraf

This comment has been minimized.

Show comment
Hide comment
@lukasgraf

lukasgraf Oct 5, 2017

Member

proposal_history_id_seq - This sequence is only ever used by this name in an Upgrade-Step:

lukasgraf@helios ~/Plone/buildouts/opengever/og-seq-test $ grep -RI 'proposal_history_id_seq' opengever/
opengever//meeting/upgrades/to4210.py:            Column("id", Integer, Sequence("proposal_history_id_seq"),

(Created follow-up issue: #3477)

Member

lukasgraf commented Oct 5, 2017

proposal_history_id_seq - This sequence is only ever used by this name in an Upgrade-Step:

lukasgraf@helios ~/Plone/buildouts/opengever/og-seq-test $ grep -RI 'proposal_history_id_seq' opengever/
opengever//meeting/upgrades/to4210.py:            Column("id", Integer, Sequence("proposal_history_id_seq"),

(Created follow-up issue: #3477)

Create missing SQL sequences.
When creating a new table with a sequence in a schema migration, the
sequence is not created automatically.
We haven't done that up to now.

This change introduces a helper "ensure_sequence_exists", which safely
creates a sequences when it is missing.

An upgrade step makes sure all currently known sequences exist.

The last two upgrade steps were updated to ensure the their sequences
exist in order to improve the copy/paste experience for future migrations.

@lukasgraf lukasgraf merged commit 84f2e97 into master Oct 6, 2017

6 checks passed

CI Governor: test-docs-intern.cfg Task #173069 succeeded
Details
CI Governor: test-docs-public.cfg Task #173070 succeeded
Details
CI Governor: test-i18n-de.cfg Task #173071 succeeded
Details
CI Governor: test-plone-4.3.x.cfg Task #173072 succeeded
Details
CI Governor: test-qa.cfg Task #173073 succeeded
Details
CI Governor: test-xml-convention.cfg Task #173074 succeeded
Details

@lukasgraf lukasgraf deleted the jone-fix-sequences branch Oct 6, 2017

@lukasgraf

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment