modify schema primary keys to be nullable+defaulted

This fixes SQLAlchemy warnings related to primary keys not
having an auto_increment or nullable.

We've done this by making all foreign primary keys nullable.

In ApiRateLimit's case, we can set a default str to act as
a null, which seems a bit more sensible.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-06-04 00:31:15 -07:00
parent e5df083d45
commit d7481b9649
5 changed files with 42 additions and 11 deletions

View file

@ -19,11 +19,9 @@ def test_api_rate_key_creation():
assert rate.WindowStart == 1
def test_api_rate_key_null_ip_raises_exception():
from aurweb.db import session
with pytest.raises(IntegrityError):
create(ApiRateLimit, Requests=10, WindowStart=1)
session.rollback()
def test_api_rate_key_ip_default():
api_rate_limit = create(ApiRateLimit, Requests=10, WindowStart=1)
assert api_rate_limit.IP == str()
def test_api_rate_key_null_requests_raises_exception():