Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Feat/climsoft models #28

Merged
merged 7 commits into from
Sep 11, 2021
Merged

Conversation

Shaibujnr
Copy link
Contributor

@Shaibujnr Shaibujnr commented Sep 8, 2021

Resolves #2

TO EXECUTE DATABASE DDL For CLIMSOFT

mysql -u root -p < script.sql

Execute the following statements to add primary key columns to the 24 core tables

alter table observationfinal add primary key (recordedFrom,describedBy,obsDatetime, obsLevel);
alter table observationinitial add primary key (recordedFrom,describedBy,obsDatetime,qcStatus,acquisitionType, obsLevel);
alter table instrumentinspection add primary key (performedOn, inspectionDatetime);
alter table faultresolution add primary key (resolvedDatetime, associatedWith);
alter table stationelement add primary key (recordedFrom, describedBy, recordedWith, beginDate);
alter table stationlocationhistory add primary key (belongsTo, openingDatetime);
alter table stationqualifier add primary key (qualifier, qualifierBeginDate, qualifierEndDate, belongsTo);
alter table observationschedule add primary key (classifiedInto, startTime, endTime);
alter table physicalfeature add primary key (associatedWith, beginDate, classifiedInto, description);
alter table featuregeographicalposition add primary key (belongsTo, observedOn);
alter table paperarchive add primary key (belongsTo, formDatetime, classifiedInto);

GENERATE MODELS

sqlacodegen "mysql://root:{{password}}@localhost/mariadb_climsoft_db_v4" --outfile opencdms/models/climsoft/v4_1_1_core.py --tables=observationfinal,observationinitial,station,obselement,instrument,instrumentfaultreport,instrumentinspection,faultresolution,stationelement,stationlocationhistory,stationqualifier,observationschedule,obsscheduleclass,physicalfeature,physicalfeatureclass,featuregeographicalposition,synopfeature,paperarchive,flags,acquisitiontype,qctype,qcstatusdefinition,regkeys,data_forms

@faysal-ishtiaq
Copy link
Collaborator

I have gone through the PR and it looks good. However, when I followed the same process, there were some dissimilarities in the resultant file. So, I pushed a commit so that we can view the diff. Here is the commit

opencdms-dev/pyopencdms@1ad710e

Feel free to revert the commit

Copy link
Collaborator

@faysal-ishtiaq faysal-ishtiaq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. just let me know about the difference in this file opencdms/models/climsoft/v4_1_1_core.py. See this commit opencdms-dev/pyopencdms@1ad710e to see the diff

@isedwards
Copy link
Contributor

Thank you @faysal-ishtiaq - these are all of the known changes that @Shaibujnr has made manually in order to make the models match the output of alembic revision --autogenerate (see the comments from list item 4 onwards here).

This is mainly necessary so that SQLAlchemy's doesn't detect a difference and suggest a migration.

Could you revert 1ad710e for us and then I'll merge?

@faysal-ishtiaq
Copy link
Collaborator

Thank you @faysal-ishtiaq - these are all of the known changes that @Shaibujnr has made manually in order to make the models match the output of alembic revision --autogenerate (see the comments from list item 4 onwards here).

This is mainly necessary so that SQLAlchemy's doesn't detect a difference and suggest a migration.

Could you revert 1ad710e for us and then I'll merge?

reverted just now

.gitignore Outdated Show resolved Hide resolved
opencdms/models/__init__.py Outdated Show resolved Hide resolved
@isedwards isedwards merged commit eb7b66d into opencdms-dev:main Sep 11, 2021
@isedwards isedwards mentioned this pull request Sep 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create SQLAlchemy ORM models for Climsoft CDMS
3 participants