Skip to content

Commit

Permalink
Setting versions II: sqlalchemy strikes back (#46)
Browse files Browse the repository at this point in the history
* documentation

* in progress

* .

* ready for PR

* lint

* cr

* ready for cr

* cl fix
  • Loading branch information
bentheiii authored Jan 6, 2022
1 parent 84130a5 commit 260c194
Show file tree
Hide file tree
Showing 29 changed files with 2,107 additions and 1,845 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# Heksher Changelog
## Next (REQ alembic upgrade)
## 0.5.0 (REQ alembic upgrade)
### Removed
* old api endpoint POST /api/v1/rules/query has been removed and replaced with GET /api/v1/rules/query
* old api endpoint POST /api/v1/rules/query has been removed and replaced with GET /api/v1/query
### Changed
* the rename api endpoint has been changed to PUT /api/v1/<name>/name.
* the method of the endpoint /api/v1/rules/search has been changed to GET.
* All setting now must have a default value.
* Setting declarations are now versioned.
* `HEKSHER_STARTUP_CONTEXT_FEATURES` is now optional.
* The inputs value for add_rule, value for patch_rule, value for put rule metadata key, value for
put setting metadata key, are now required.
### Deprecated
* The api endpoint PATCH /api/v1/rules/<rule> to change a rule's value is now deprecated, new users
should use PUT /api/v1/rules/<rule>/value
### Added
* declarations are now tolerant of subtypes (to account for previous type upgrade)
* documentation
* Added endpoint PUT /api/v1/settings/<name>/configurable_features
* The api endpoint PUT /api/v1/rules/<rule>/value to change a rule's value
* The api endpoint GET /api/v1/rules/query to query rules (replaces the old query endpoint)
* The api endpoint GET /api/v1/query to query rules (replaces the old query endpoint)
* POST /api/v1/rules now returns the rule location in the header
### Fixed
* A bug where patching a context feature's index using "to_before" would use the incorrect target.
### Internal
* a new script to test and correctly report coverage
* tools/mk_revision.py to easily create alembic revisions
* all db logic refactored to avoid multiple connections
* Many more column are now strictly non-nullable
## 0.4.1
### Removed
* removed the alembic extra, it's now a requirement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
""""added setting versioning + default is now required"
Revision ID: 83f0f272313f
Revises: 7713520cb02b
Create Date: 2022-01-04 14:04:46.416415
"""
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = '83f0f272313f'
down_revision = '7713520cb02b'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('conditions', 'rule',
existing_type=sa.INTEGER(),
nullable=False)
op.alter_column('conditions', 'context_feature',
existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('configurable', 'setting',
existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('configurable', 'context_feature',
existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('rule_metadata', 'rule',
existing_type=sa.INTEGER(),
nullable=False)
op.alter_column('rules', 'setting',
existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('setting_aliases', 'setting',
existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('setting_metadata', 'setting',
existing_type=sa.VARCHAR(),
nullable=False)
op.add_column('settings', sa.Column('version', sa.String(), nullable=True))
op.execute("UPDATE settings SET version = '1.0'")
op.alter_column('settings', 'default_value',
existing_type=sa.VARCHAR(),
nullable=False)
op.alter_column('settings', 'default_value',
existing_type=sa.VARCHAR(),
nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('settings', 'default_value',
existing_type=sa.VARCHAR(),
nullable=True)
op.drop_column('settings', 'version')
op.alter_column('setting_metadata', 'setting',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('setting_aliases', 'setting',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('rules', 'setting',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('rule_metadata', 'rule',
existing_type=sa.INTEGER(),
nullable=True)
op.alter_column('configurable', 'context_feature',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('configurable', 'setting',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('conditions', 'context_feature',
existing_type=sa.VARCHAR(),
nullable=True)
op.alter_column('conditions', 'rule',
existing_type=sa.INTEGER(),
nullable=True)
# ### end Alembic commands ###
Loading

0 comments on commit 260c194

Please sign in to comment.