diff --git a/warehouse/migrations/versions/1430c9aefcd7_add_framework_jupyter_trove_classifier.py b/warehouse/migrations/versions/1430c9aefcd7_add_framework_jupyter_trove_classifier.py new file mode 100644 index 000000000000..bbe62e4a1afe --- /dev/null +++ b/warehouse/migrations/versions/1430c9aefcd7_add_framework_jupyter_trove_classifier.py @@ -0,0 +1,45 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Create `Framework::Jupyter` as required on pypi-legace issue 210 + +Revision ID: 1430c9aefcd7 +Revises: ad81a3452b5d +Create Date: 2017-04-06 22:03:40.917628 +""" + +from alembic import op +import sqlalchemy as sa + + +revision = '1430c9aefcd7' +down_revision = 'ad81a3452b5d' +classifier = "Framework :: Jupyter" + +def upgrade(): + op.execute( + """ + INSERT into trove_classifiers (classifier, l2, l3, l4, l5) VALUES ('{classifier}', 0, 0, 0, 0); + UPDATE trove_classifiers set l2=id where classifier='{classifier}'; + """.format(classifier=classifier) + ) + + pass + + +def downgrade(): + op.execute( + """ + DELETE from release_classifiers where trove_id=(SELECT id from trove_classifiers where classifier='{classifier}'); + DELETE FROM trove_classifiers where classifier='{classifier}'; + """.format(classifier=classifier) + ) diff --git a/warehouse/migrations/versions/ad81a3452b5d_autoincrement_trove_classifiers_ids.py b/warehouse/migrations/versions/ad81a3452b5d_autoincrement_trove_classifiers_ids.py new file mode 100644 index 000000000000..7c545d5ef25d --- /dev/null +++ b/warehouse/migrations/versions/ad81a3452b5d_autoincrement_trove_classifiers_ids.py @@ -0,0 +1,47 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Autoincrement trove classifier id when inserting (if id not given). + +Revision ID: ad81a3452b5d +Revises: 5b3f9e687d94 +Create Date: 2017-04-04 21:00:25.205245 +""" + +from alembic import op + +revision = 'ad81a3452b5d' +down_revision = '5b3f9e687d94' + +def upgrade(): + """ + Autoincrement the trove classifier ID when a new one get inserted. + """ + op.execute( + """CREATE SEQUENCE trove_classifiers_seq; + SELECT setval('trove_classifiers_seq', + (SELECT max(id) from trove_classifiers) + ); + ALTER TABLE trove_classifiers + ALTER COLUMN id + SET DEFAULT nextval('trove_classifiers_seq'); + ALTER SEQUENCE trove_classifiers_seq + OWNED BY trove_classifiers.id; + """) + + +def downgrade(): + op.execute( + """ALTER TABLE trove_classifiers + ALTER COLUMN id SET DEFAULT 1; + DROP SEQUENCE trove_classifiers_seq; + """)