DataONEorg / bookkeeper

Bookkeeper keeps track of DataONE product subscriptions and quotas for researchers using the extended services.
Other
1 stars 2 forks source link

SubscriptionId should not be null #36

Closed gothub closed 4 years ago

gothub commented 4 years ago

It's possible to create a quota db entry with a null subscription, if the subscription attribute is omitted from the JSON object sent via the POST /quotas (QuotasResource.create()) REST endpoint.

SInce quotas.subscriptionId in the quotas table is a foreign key to the subscriptions table, this field should not be null.

So,

csjx commented 4 years ago

Hi @gothub - I made the subscriptionId nullable because we use the quotas table to satisfy two use cases: 1) Provide a list of generic quotas associated with a given product, and then 2) associate a specific quota with a specific subscription. Since quotas are only created or modified by bookkeeper admin subjects, we can control scenario (2) above in the controller logic. So, unless I'm missing something, I think we need to back out your changes in commit c4e9581. Otherwise our SQL script that populates the standard quotas will fail.

gothub commented 4 years ago

OK, the commit has been reverted in commit fd7628f62e2532c8c66521c733022d43eb4a2524