diff --git a/server/schema.py b/server/schema.py index 27b80bd..95f93cf 100644 --- a/server/schema.py +++ b/server/schema.py @@ -1,251 +1,625 @@ -from peewee import * +# generated from pwiz, manually checked +# comments are generated from \dt -database = MySQLDatabase('arxiv', **{'charset': 'utf8', 'sql_mode': 'PIPES_AS_CONCAT', 'use_unicode': True, 'host': 'arxiv-nush-database-1', 'user': 'root', 'password': 'admin'}) +from peewee import * -class UnknownField(object): - def __init__(self, *_, **__): pass +database = PostgresqlDatabase('arxiv', **{'host': 'database', 'user': 'postgres', 'password': 'admin'}) class BaseModel(Model): class Meta: database = database -class Researchevent(BaseModel): - about = CharField(null=True) - conf_doi = CharField(column_name='confDoi', null=True) - end_date = DateTimeField() - event_id = CharField(column_name='eventId') - format = CharField(null=True) - is_competition = IntegerField(column_name='isCompetition', constraints=[SQL("DEFAULT 0")]) - is_conference = IntegerField(column_name='isConference', constraints=[SQL("DEFAULT 0")]) - name = CharField() - start_date = DateTimeField() +""" +Table "arxiv.researchevent" + Column | Type | Collation | Nullable | Default +---------------+-------------------------+-----------+----------+--------------------------------------------------- + numeventid | bigint | | not null | nextval('researchevent_numeventid_seq'::regclass) + eventid | character varying(15) | | not null | + year | integer | | not null | + name | character varying(100) | | not null | + about | character varying(5000) | | | + start_date | date | | not null | + end_date | date | | not null | + format | character varying(10) | | | + iscompetition | boolean | | not null | false + isconference | boolean | | not null | false + confdoi | character varying(200) | | | +Indexes: + "idx_16464_primary" PRIMARY KEY, btree (numeventid) + "idx_16464_eventid_2" UNIQUE, btree (eventid, year) +Referenced by: + TABLE "awardtypes" CONSTRAINT "awardtypes_ibfk_1" FOREIGN KEY (numeventid) REFERENCES researchevent(numeventid) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "organises" CONSTRAINT "organises_ibfk_3" FOREIGN KEY (numeventid) REFERENCES researchevent(numeventid) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "submission" CONSTRAINT "submission_ibfk_1" FOREIGN KEY (numeventid) REFERENCES researchevent(numeventid) ON UPDATE CASCADE ON DELETE CASCADE +""" +class ResearchEvent(BaseModel): + about = CharField(max_length=5000, null=True) + conf_DOI = CharField(column_name='confdoi', max_length=200, null=True) + end_date = DateField() + event_id = CharField(column_name='eventid', max_length=15) + event_format = CharField(column_name='format', null=True, max_length=10) + is_competition = BooleanField(column_name="iscompetition", default=False) + is_conference = BooleanField(column_name="isconference", default=False) + name = CharField(max_length=100) + num_event_id = BigAutoField(column_name='numeventid') + start_date = DateField() year = IntegerField() class Meta: table_name = 'researchevent' indexes = ( - (('event_id', 'year'), True), + (('eventid', 'year'), True), ) - primary_key = CompositeKey('event_id', 'year') - + schema = 'arxiv' + + +""" +Table "arxiv.submission" + Column | Type | Collation | Nullable | Default +-------------+-------------------------+-----------+----------+------------------------------------------- + subid | bigint | | not null | nextval('submission_subid_seq'::regclass) + numeventid | bigint | | not null | + code | character varying(20) | | not null | + subtitle | character varying(200) | | not null | + subabstract | character varying(2000) | | not null | +Indexes: + "idx_16479_primary" PRIMARY KEY, btree (subid) + "idx_16479_numeventid" UNIQUE, btree (numeventid, code) +Foreign-key constraints: + "submission_ibfk_1" FOREIGN KEY (numeventid) REFERENCES researchevent(numeventid) ON UPDATE CASCADE ON DELETE CASCADE +Referenced by: + TABLE "accomplishment" CONSTRAINT "accomplishment_ibfk_1" FOREIGN KEY (subid) REFERENCES submission(subid) ON UPDATE CASCADE ON DELETE SET NULL + TABLE "submits" CONSTRAINT "submits_ibfk_3" FOREIGN KEY (subid) REFERENCES submission(subid) ON UPDATE CASCADE ON DELETE CASCADE +""" class Submission(BaseModel): - code = CharField() - event = ForeignKeyField(column_name='eventId', field='event_id', model=Researchevent) - sub_abstract = CharField(column_name='subAbstract') - sub_title = CharField(column_name='subTitle') - year = ForeignKeyField(backref='researchevent_year_set', column_name='year', field='year', model=Researchevent) + code = CharField(max_length=20) + num_event_id = ForeignKeyField(column_name='numeventid', field='numeventid', model=ResearchEvent) + sub_abstract = CharField(column_name='subabstract', max_length=2000) + sub_id = BigAutoField(column_name='subid') + sub_title = CharField(column_name='subtitle', max_length=200) class Meta: table_name = 'submission' indexes = ( - (('event', 'year', 'code'), True), + (('numeventid', 'code'), True), ) - primary_key = CompositeKey('code', 'event', 'year') - + schema = 'arxiv' + +""" +Table "arxiv.accomplishment" + Column | Type | Collation | Nullable | Default +---------+------------------------+-----------+----------+--------- + accid | integer | | not null | + isaward | boolean | | not null | false + name | character varying(100) | | | + prize | character varying(100) | | | + subid | bigint | | | +Indexes: + "idx_16386_primary" PRIMARY KEY, btree (accid) + "idx_16386_subid" btree (subid) +Foreign-key constraints: + "accomplishment_ibfk_1" FOREIGN KEY (subid) REFERENCES submission(subid) ON UPDATE CASCADE ON DELETE SET NULL +Referenced by: + TABLE "publication" CONSTRAINT "publication_ibfk_1" FOREIGN KEY (accid) REFERENCES accomplishment(accid) ON UPDATE CASCADE ON DELETE CASCADE + +""" class Accomplishment(BaseModel): - acc_id = AutoField(column_name='accId') - code = ForeignKeyField(column_name='code', field='code', model=Submission, null=True) - event = ForeignKeyField(backref='submission_event_set', column_name='eventId', field='event', model=Submission, null=True) - is_award = IntegerField(column_name='isAward', constraints=[SQL("DEFAULT 0")]) - name = CharField(null=True) - prize = CharField(null=True) - year = ForeignKeyField(backref='submission_year_set', column_name='year', field='year', model=Submission, null=True) + acc_id = AutoField(column_name='accid') + is_award = BooleanField(column_name='isaward', default=False) + name = CharField(max_length=100, null=True) + prize = CharField(max_length=100, null=True) + sub_id = ForeignKeyField(column_name='subid', field='subid', model=Submission, null=True) class Meta: table_name = 'accomplishment' - indexes = ( - (('event', 'year', 'code'), False), - ) - -class Awardtypes(BaseModel): - award_type = CharField(column_name='awardType') - event = ForeignKeyField(column_name='eventId', field='event_id', model=Researchevent) - year = ForeignKeyField(backref='researchevent_year_set', column_name='year', field='year', model=Researchevent) + schema = 'arxiv' + +""" +Table "arxiv.awardtypes" + Column | Type | Collation | Nullable | Default +------------+------------------------+-----------+----------+---------------------------------------- + id | bigint | | not null | nextval('awardtypes_id_seq'::regclass) + numeventid | bigint | | not null | + awardtype | character varying(100) | | not null | +Indexes: + "idx_16391_primary" PRIMARY KEY, btree (id) + "idx_16391_numeventid" UNIQUE, btree (numeventid, awardtype) +Foreign-key constraints: + "awardtypes_ibfk_1" FOREIGN KEY (numeventid) REFERENCES researchevent(numeventid) ON UPDATE CASCADE ON DELETE CASCADE +""" +class AwardTypes(BaseModel): + award_type = CharField(max_length=100, column_name='awardtype') + id = BigAutoField() + num_event_id = ForeignKeyField(column_name='numeventid', field='numeventid', model=ResearchEvent) class Meta: table_name = 'awardtypes' indexes = ( - (('event', 'year', 'award_type'), True), + (('numeventid', 'awardtype'), True), ) - primary_key = CompositeKey('award_type', 'event', 'year') - + schema = 'arxiv' + +""" +Table "arxiv.department" + Column | Type | Collation | Nullable | Default +--------+-----------------------+-----------+----------+----------------------- + deptid | character(2) | | not null | + name | character varying(50) | | not null | ''::character varying +Indexes: + "idx_16395_primary" PRIMARY KEY, btree (deptid) +Referenced by: + TABLE "nushteacher" CONSTRAINT "nushteacher_ibfk_1" FOREIGN KEY (deptid) REFERENCES department(deptid) ON UPDATE CASCADE ON DELETE SET NULL + TABLE "project" CONSTRAINT "project_ibfk_1" FOREIGN KEY (deptid) REFERENCES department(deptid) ON UPDATE CASCADE ON DELETE SET NULL +""" class Department(BaseModel): - dept_id = CharField(column_name='deptId', primary_key=True) - name = CharField(constraints=[SQL("DEFAULT ''")]) + dept_id = FixedCharField(max_length=2, column_name='deptid', primary_key=True) + name = CharField(max_length=50, default='') class Meta: table_name = 'department' - + schema = 'arxiv' + +""" +Table "arxiv.student" + Column | Type | Collation | Nullable | Default +--------+------------------------+-----------+----------+--------- + email | character varying(255) | | not null | + name | character varying(100) | | | +Indexes: + "idx_16475_primary" PRIMARY KEY, btree (email) +Referenced by: + TABLE "externalstudent" CONSTRAINT "externalstudent_ibfk_1" FOREIGN KEY (email) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "nushstudent" CONSTRAINT "nushstudent_ibfk_1" FOREIGN KEY (email) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "submits" CONSTRAINT "submits_ibfk_1" FOREIGN KEY (studentemail) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "works_on" CONSTRAINT "works_on_ibfk_2" FOREIGN KEY (studentemail) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE +""" class Student(BaseModel): - email = CharField(primary_key=True) - name = CharField(null=True) + email = CharField(max_length=255, primary_key=True) + name = CharField(max_length=100, null=True) class Meta: table_name = 'student' - + schema = 'arxiv' + +""" +Table "arxiv.institution" + Column | Type | Collation | Nullable | Default +-------------+------------------------+-----------+----------+----------------------- + instid | character varying(10) | | not null | + name | character varying(100) | | not null | ''::character varying + address | character varying(150) | | not null | ''::character varying + isschool | boolean | | not null | false + isinstitute | boolean | | not null | false + isorganiser | boolean | | not null | false + ispublisher | boolean | | not null | false +Indexes: + "idx_16407_primary" PRIMARY KEY, btree (instid) +Referenced by: + TABLE "externalteacher" CONSTRAINT "externalteacher_ibfk_1" FOREIGN KEY (schid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE SET NULL + TABLE "organises" CONSTRAINT "organises_ibfk_2" FOREIGN KEY (instid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "publishedby" CONSTRAINT "publishedby_ibfk_2" FOREIGN KEY (instid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "works_at" CONSTRAINT "works_at_ibfk_2" FOREIGN KEY (instid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE CASCADE +""" class Institution(BaseModel): - address = CharField(constraints=[SQL("DEFAULT ''")]) - inst_id = CharField(column_name='instId', primary_key=True) - is_institute = IntegerField(column_name='isInstitute', constraints=[SQL("DEFAULT 0")]) - is_organiser = IntegerField(column_name='isOrganiser', constraints=[SQL("DEFAULT 0")]) - is_publisher = IntegerField(column_name='isPublisher', constraints=[SQL("DEFAULT 0")]) - is_school = IntegerField(column_name='isSchool', constraints=[SQL("DEFAULT 0")]) - name = CharField(constraints=[SQL("DEFAULT ''")]) + address = CharField(max_length=150, default='') + inst_id = CharField(max_length=10, primary_key=True, column_name='instid') + is_institute = BooleanField(default=False, column_name='isinstitute') + is_organiser = BooleanField(default=False, column_name='isorganiser') + is_publisher = BooleanField(default=False, column_name='ispublisher') + is_school = BooleanField(default=False, column_name='isschool') + name = CharField(max_length=100, default='') class Meta: table_name = 'institution' - -class Externalteacher(BaseModel): - email = CharField(primary_key=True) - name = CharField(null=True) - sch = ForeignKeyField(column_name='schId', field='inst_id', model=Institution, null=True) + schema = 'arxiv' + +""" +Table "arxiv.externalteacher" + Column | Type | Collation | Nullable | Default +--------+------------------------+-----------+----------+--------- + email | character varying(255) | | not null | + name | character varying(100) | | | + schid | character varying(10) | | | +Indexes: + "idx_16404_primary" PRIMARY KEY, btree (email) + "idx_16404_schid" btree (schid) +Foreign-key constraints: + "externalteacher_ibfk_1" FOREIGN KEY (schid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE SET NULL +Referenced by: + TABLE "externalstudent" CONSTRAINT "externalstudent_ibfk_2" FOREIGN KEY (emergencyemail) REFERENCES externalteacher(email) ON UPDATE CASCADE ON DELETE SET NULL +""" +class ExternalTeacher(BaseModel): + email = CharField(max_length=255, primary_key=True) + name = CharField(max_length=100, null=True) + sch_id = ForeignKeyField(column_name='schid', field='instid', model=Institution, null=True) class Meta: table_name = 'externalteacher' - -class Externalstudent(BaseModel): + schema = 'arxiv' + +""" +Table "arxiv.externalstudent" + Column | Type | Collation | Nullable | Default +----------------+------------------------+-----------+----------+--------- + email | character varying(255) | | not null | + emergencyemail | character varying(255) | | | +Indexes: + "idx_16399_primary" PRIMARY KEY, btree (email) + "idx_16399_emergencyemail" btree (emergencyemail) +Foreign-key constraints: + "externalstudent_ibfk_1" FOREIGN KEY (email) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE + "externalstudent_ibfk_2" FOREIGN KEY (emergencyemail) REFERENCES externalteacher(email) ON UPDATE CASCADE ON DELETE SET NULL +""" +class ExternalStudent(BaseModel): email = ForeignKeyField(column_name='email', field='email', model=Student, primary_key=True) - emergency_email = ForeignKeyField(column_name='emergencyEmail', field='email', model=Externalteacher, null=True) + emergency_email = ForeignKeyField(column_name='emergencyemail', field='email', model=ExternalTeacher, null=True) class Meta: table_name = 'externalstudent' - + schema = 'arxiv' + +""" +Table "arxiv.journal" + Column | Type | Collation | Nullable | Default +--------+------------------------+-----------+----------+--------- + issn | integer | | not null | + name | character varying(100) | | not null | +Indexes: + "idx_16416_primary" PRIMARY KEY, btree (issn) +Referenced by: + TABLE "publication" CONSTRAINT "publication_ibfk_2" FOREIGN KEY (journissn) REFERENCES journal(issn) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "publishedby" CONSTRAINT "publishedby_ibfk_1" FOREIGN KEY (issn) REFERENCES journal(issn) ON UPDATE CASCADE ON DELETE CASCADE +""" class Journal(BaseModel): - issn = AutoField() - name = CharField() + issn = IntegerField(primary_key=True) + name = CharField(max_length=100) class Meta: table_name = 'journal' + schema = 'arxiv' + +""" +Table "arxiv.researchmentor" + Column | Type | Collation | Nullable | Default +--------+------------------------+-----------+----------+--------- + email | character varying(255) | | not null | + name | character varying(100) | | | +Indexes: + "idx_16472_primary" PRIMARY KEY, btree (email) +Referenced by: + TABLE "mentors" CONSTRAINT "mentors_ibfk_2" FOREIGN KEY (mentoremail) REFERENCES researchmentor(email) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "works_at" CONSTRAINT "works_at_ibfk_1" FOREIGN KEY (mentoremail) REFERENCES researchmentor(email) ON UPDATE CASCADE ON DELETE CASCADE +""" +class ResearchMentor(BaseModel): + email = CharField(max_length=255, primary_key=True) + name = CharField(max_length=100, null=True) -class Nushteacher(BaseModel): - dept = ForeignKeyField(column_name='deptId', field='dept_id', model=Department, null=True) - email = CharField(primary_key=True) - is_admin = IntegerField(column_name='isAdmin', constraints=[SQL("DEFAULT 0")]) - is_mentor = IntegerField(column_name='isMentor', constraints=[SQL("DEFAULT 0")]) - name = CharField(constraints=[SQL("DEFAULT ''")]) - pfp = TextField(null=True) - pwd = CharField(null=True) + class Meta: + table_name = 'researchmentor' + schema = 'arxiv' + +""" +Table "arxiv.nushteacher" + Column | Type | Collation | Nullable | Default +----------+------------------------+-----------+----------+----------------------- + email | character varying(255) | | not null | + pwd | character varying(20) | | | + name | character varying(100) | | not null | ''::character varying + pfp | bytea | | | + isadmin | boolean | | not null | false + ismentor | boolean | | not null | false + deptid | character(2) | | | +Indexes: + "idx_16429_primary" PRIMARY KEY, btree (email) + "idx_16429_deptid" btree (deptid) +Foreign-key constraints: + "nushteacher_ibfk_1" FOREIGN KEY (deptid) REFERENCES department(deptid) ON UPDATE CASCADE ON DELETE SET NULL +Referenced by: + TABLE "project" CONSTRAINT "project_ibfk_2" FOREIGN KEY (teacheremail) REFERENCES nushteacher(email) ON UPDATE CASCADE ON DELETE SET NULL +""" +class NUSHTeacher(BaseModel): + dept_id = ForeignKeyField(column_name='deptid', field='deptid', model=Department, null=True) + email = CharField(max_length=255, primary_key=True) + is_admin = BooleanField(column_name="isadmin", default=False) + is_mentor = BooleanField(column_name="ismentor", default=False) + name = CharField(max_length=100, default='') + pfp = BlobField(null=True) + pwd = CharField(max_length=20, null=True) class Meta: table_name = 'nushteacher' - + schema = 'arxiv' + +""" +Table "arxiv.project" + Column | Type | Collation | Nullable | Default +--------------+-------------------------+-----------+----------+--------- + pcode | character varying(20) | | not null | + title | character varying(200) | | not null | + abstract | character varying(2000) | | | + reportpdf | bytea | | | + year | integer | | | + deptid | character(2) | | | + teacheremail | character varying(255) | | | +Indexes: + "idx_16442_primary" PRIMARY KEY, btree (pcode) + "idx_16442_deptid" btree (deptid) + "idx_16442_teacheremail" btree (teacheremail) +Foreign-key constraints: + "project_ibfk_1" FOREIGN KEY (deptid) REFERENCES department(deptid) ON UPDATE CASCADE ON DELETE SET NULL + "project_ibfk_2" FOREIGN KEY (teacheremail) REFERENCES nushteacher(email) ON UPDATE CASCADE ON DELETE SET NULL +Referenced by: + TABLE "mentors" CONSTRAINT "mentors_ibfk_1" FOREIGN KEY (pcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "projectcontinuation" CONSTRAINT "projectcontinuation_ibfk_1" FOREIGN KEY (prevpcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "projectcontinuation" CONSTRAINT "projectcontinuation_ibfk_2" FOREIGN KEY (nextpcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "submits" CONSTRAINT "submits_ibfk_2" FOREIGN KEY (pcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + TABLE "works_on" CONSTRAINT "works_on_ibfk_1" FOREIGN KEY (pcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE +""" class Project(BaseModel): - abstract = CharField(null=True) - dept = ForeignKeyField(column_name='deptId', field='dept_id', model=Department, null=True) - pcode = CharField(primary_key=True) - report_pdf = TextField(column_name='reportPdf', null=True) - teacher_email = ForeignKeyField(column_name='teacherEmail', field='email', model=Nushteacher, null=True) - title = CharField() + abstract = CharField(max_length=2000, null=True) + dept_id = ForeignKeyField(column_name='deptid', field='deptid', model=Department, null=True) + project_code = CharField(column_name='pcode', primary_key=True, max_length=20) + report_pdf = BlobField(null=True, column_name='reportpdf') + teacher_email = ForeignKeyField(column_name='teacheremail', field='email', model=NUSHTeacher, null=True) + title = CharField(max_length=200) year = IntegerField(null=True) class Meta: table_name = 'project' - -class Researchmentor(BaseModel): - email = CharField(primary_key=True) - name = CharField(null=True) - - class Meta: - table_name = 'researchmentor' - + schema = 'arxiv' + +""" +Table "arxiv.mentors" + Column | Type | Collation | Nullable | Default +-------------+------------------------+-----------+----------+------------------------------------- + id | bigint | | not null | nextval('mentors_id_seq'::regclass) + mentoremail | character varying(255) | | not null | + pcode | character varying(20) | | not null | +Indexes: + "idx_16420_primary" PRIMARY KEY, btree (id) + "idx_16420_mentoremail" btree (mentoremail) + "idx_16420_pcode_2" UNIQUE, btree (pcode, mentoremail) +Foreign-key constraints: + "mentors_ibfk_1" FOREIGN KEY (pcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + "mentors_ibfk_2" FOREIGN KEY (mentoremail) REFERENCES researchmentor(email) ON UPDATE CASCADE ON DELETE CASCADE +""" class Mentors(BaseModel): - mentor_email = ForeignKeyField(column_name='mentorEmail', field='email', model=Researchmentor) - pcode = ForeignKeyField(column_name='pcode', field='pcode', model=Project) + id = BigAutoField() + mentor_email = ForeignKeyField(column_name='mentoremail', field='email', model=ResearchMentor) + project_code = ForeignKeyField(column_name='pcode', field='pcode', model=Project) class Meta: table_name = 'mentors' - primary_key = False - -class Nushstudent(BaseModel): - about = CharField(null=True) + indexes = ( + (('pcode', 'mentoremail'), True), + ) + schema = 'arxiv' + +""" +Table "arxiv.nushstudent" + Column | Type | Collation | Nullable | Default +----------+-------------------------+-----------+----------+--------- + email | character varying(255) | | not null | + pwd | character varying(20) | | | + pfp | bytea | | | + about | character varying(1000) | | | + gradyear | integer | | | + nush_sid | character varying(8) | | | +Indexes: + "idx_16424_primary" PRIMARY KEY, btree (email) +Foreign-key constraints: + "nushstudent_ibfk_1" FOREIGN KEY (email) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE +""" +class NUSHStudent(BaseModel): + about = CharField(max_length=255, null=True) email = ForeignKeyField(column_name='email', field='email', model=Student, primary_key=True) - grad_year = IntegerField(column_name='gradYear', null=True) - nush_sid = CharField(null=True) - pfp = TextField(null=True) - pwd = CharField(null=True) + grad_year = IntegerField(column_name='gradyear', null=True) + nush_student_id = CharField(column_name='nush_sid', max_length=8, null=True) + pfp = BlobField(null=True) + pwd = CharField(max_length=20, null=True) class Meta: table_name = 'nushstudent' - + schema = 'arxiv' + +""" +Table "arxiv.organises" + Column | Type | Collation | Nullable | Default +------------+-----------------------+-----------+----------+--------------------------------------- + id | bigint | | not null | nextval('organises_id_seq'::regclass) + numeventid | bigint | | not null | + instid | character varying(10) | | not null | +Indexes: + "idx_16438_primary" PRIMARY KEY, btree (id) + "idx_16438_instid" btree (instid) + "idx_16438_numeventid" UNIQUE, btree (numeventid, instid) +Foreign-key constraints: + "organises_ibfk_2" FOREIGN KEY (instid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE CASCADE + "organises_ibfk_3" FOREIGN KEY (numeventid) REFERENCES researchevent(numeventid) ON UPDATE CASCADE ON DELETE CASCADE +""" class Organises(BaseModel): - event = ForeignKeyField(column_name='eventId', field='event_id', model=Researchevent) - inst = ForeignKeyField(column_name='instId', field='inst_id', model=Institution) - year = ForeignKeyField(backref='researchevent_year_set', column_name='year', field='year', model=Researchevent) + id = BigAutoField() + inst_id = ForeignKeyField(column_name='instid', field='instid', model=Institution) + num_event_id = ForeignKeyField(column_name='numeventid', field='numeventid', model=ResearchEvent) class Meta: table_name = 'organises' indexes = ( - (('event', 'year', 'inst'), True), + (('numeventid', 'instid'), True), ) - primary_key = CompositeKey('event', 'inst', 'year') - -class Projectcontinuation(BaseModel): - next_pcode = ForeignKeyField(column_name='nextPcode', field='pcode', model=Project) - prev_pcode = ForeignKeyField(backref='project_prev_pcode_set', column_name='prevPcode', field='pcode', model=Project) + schema = 'arxiv' + +""" +Table "arxiv.projectcontinuation" + Column | Type | Collation | Nullable | Default +-----------+-----------------------+-----------+----------+------------------------------------------------- + id | bigint | | not null | nextval('projectcontinuation_id_seq'::regclass) + prevpcode | character varying(20) | | not null | + nextpcode | character varying(20) | | not null | +Indexes: + "idx_16448_primary" PRIMARY KEY, btree (id) + "idx_16448_nextpcode" btree (nextpcode) + "idx_16448_prevpcode_2" UNIQUE, btree (prevpcode, nextpcode) +Foreign-key constraints: + "projectcontinuation_ibfk_1" FOREIGN KEY (prevpcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + "projectcontinuation_ibfk_2" FOREIGN KEY (nextpcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE +""" +class ProjectContinuation(BaseModel): + id = BigAutoField() + next_project_code = ForeignKeyField(column_name='nextpcode', field='pcode', model=Project) + prev_project_code = ForeignKeyField(backref='project_prev_code_set', column_name='prevpcode', field='pcode', model=Project) class Meta: table_name = 'projectcontinuation' - primary_key = False - + indexes = ( + (('prevpcode', 'nextpcode'), True), + ) + schema = 'arxiv' + +""" +Table "arxiv.publication" + Column | Type | Collation | Nullable | Default +-----------+------------------------+-----------+----------+--------- + accid | integer | | not null | + pubtitle | character varying(200) | | not null | + doi | character varying(200) | | | + isjournal | boolean | | not null | false + url | character varying(300) | | | + journissn | integer | | | +Indexes: + "idx_16452_primary" PRIMARY KEY, btree (accid) + "idx_16452_journissn" btree (journissn) +Foreign-key constraints: + "publication_ibfk_1" FOREIGN KEY (accid) REFERENCES accomplishment(accid) ON UPDATE CASCADE ON DELETE CASCADE + "publication_ibfk_2" FOREIGN KEY (journissn) REFERENCES journal(issn) ON UPDATE CASCADE ON DELETE CASCADE +""" class Publication(BaseModel): - acc = ForeignKeyField(column_name='accId', field='acc_id', model=Accomplishment, primary_key=True) - doi = CharField(null=True) - is_journal = IntegerField(column_name='isJournal', constraints=[SQL("DEFAULT 0")]) - journ_issn = ForeignKeyField(column_name='journISSN', field='issn', model=Journal, null=True) - pub_title = CharField(column_name='pubTitle') - url = CharField(null=True) + acc_id = ForeignKeyField(column_name='accid', field='accid', model=Accomplishment, primary_key=True) + doi = CharField(max_length=200, null=True) + is_journal = BooleanField(column_name="isjournal", default=False) + journal_issn = ForeignKeyField(column_name='journissn', field='issn', model=Journal, null=True) + title = CharField(max_length=200, column_name='pubtitle') + url = CharField(max_length=300, null=True) class Meta: table_name = 'publication' - -class Publishedby(BaseModel): - inst = ForeignKeyField(column_name='instId', field='inst_id', model=Institution) + schema = 'arxiv' + +""" +Table "arxiv.publishedby" + Column | Type | Collation | Nullable | Default +--------+-----------------------+-----------+----------+----------------------------------------- + id | bigint | | not null | nextval('publishedby_id_seq'::regclass) + issn | integer | | not null | + instid | character varying(10) | | not null | +Indexes: + "idx_16459_primary" PRIMARY KEY, btree (id) + "idx_16459_instid" btree (instid) + "idx_16459_issn_2" UNIQUE, btree (issn, instid) +Foreign-key constraints: + "publishedby_ibfk_1" FOREIGN KEY (issn) REFERENCES journal(issn) ON UPDATE CASCADE ON DELETE CASCADE + "publishedby_ibfk_2" FOREIGN KEY (instid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE CASCADE +""" +class PublishedBy(BaseModel): + id = BigAutoField() + inst_id = ForeignKeyField(column_name='instid', field='instid', model=Institution) issn = ForeignKeyField(column_name='issn', field='issn', model=Journal) class Meta: table_name = 'publishedby' indexes = ( - (('issn', 'inst'), True), + (('issn', 'instid'), True), ) - primary_key = CompositeKey('inst', 'issn') - + schema = 'arxiv' + +""" +Table "arxiv.submits" + Column | Type | Collation | Nullable | Default +--------------+------------------------+-----------+----------+------------------------------------- + id | bigint | | not null | nextval('submits_id_seq'::regclass) + studentemail | character varying(255) | | not null | + pcode | character varying(20) | | not null | + subid | bigint | | not null | +Indexes: + "idx_16486_primary" PRIMARY KEY, btree (id) + "idx_16486_pcode" btree (pcode) + "idx_16486_studentemail_2" UNIQUE, btree (studentemail, pcode, subid) + "idx_16486_subid" btree (subid) +Foreign-key constraints: + "submits_ibfk_1" FOREIGN KEY (studentemail) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE + "submits_ibfk_2" FOREIGN KEY (pcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + "submits_ibfk_3" FOREIGN KEY (subid) REFERENCES submission(subid) ON UPDATE CASCADE ON DELETE CASCADE +""" class Submits(BaseModel): - code = ForeignKeyField(column_name='code', field='code', model=Submission) - event = ForeignKeyField(backref='submission_event_set', column_name='eventId', field='event', model=Submission) - pcode = ForeignKeyField(column_name='pcode', field='pcode', model=Project) - student_email = ForeignKeyField(column_name='studentEmail', field='email', model=Student) - year = ForeignKeyField(backref='submission_year_set', column_name='year', field='year', model=Submission) + id = BigAutoField() + project_code = ForeignKeyField(column_name='pcode', field='pcode', model=Project) + student_email = ForeignKeyField(column_name='studentemail', field='email', model=Student) + sub_id = ForeignKeyField(column_name='subid', field='subid', model=Submission) class Meta: table_name = 'submits' indexes = ( - (('event', 'year', 'code'), False), - (('student_email', 'pcode', 'event', 'year', 'code'), True), + (('studentemail', 'pcode', 'subid'), True), ) - primary_key = CompositeKey('code', 'event', 'pcode', 'student_email', 'year') - + schema = 'arxiv' + +""" +Table "arxiv.works_at" + Column | Type | Collation | Nullable | Default +-------------+------------------------+-----------+----------+-------------------------------------- + id | bigint | | not null | nextval('works_at_id_seq'::regclass) + mentoremail | character varying(255) | | not null | + instid | character varying(10) | | not null | + dept | character varying(100) | | | + role | character varying(100) | | | + officeaddr | character varying(100) | | | +Indexes: + "idx_16491_primary" PRIMARY KEY, btree (id) + "idx_16491_instid" btree (instid) + "idx_16491_mentoremail" UNIQUE, btree (mentoremail, instid) +Foreign-key constraints: + "works_at_ibfk_1" FOREIGN KEY (mentoremail) REFERENCES researchmentor(email) ON UPDATE CASCADE ON DELETE CASCADE + "works_at_ibfk_2" FOREIGN KEY (instid) REFERENCES institution(instid) ON UPDATE CASCADE ON DELETE CASCADE +""" class WorksAt(BaseModel): - dept = CharField(null=True) - inst = ForeignKeyField(column_name='instId', field='inst_id', model=Institution) - mentor_email = ForeignKeyField(column_name='mentorEmail', field='email', model=Researchmentor) - office_addr = CharField(column_name='officeAddr', null=True) - role = CharField(null=True) + dept = CharField(max_length=100, null=True) + id = BigAutoField() + inst_id = ForeignKeyField(column_name='instid', field='instid', model=Institution) + mentor_email = ForeignKeyField(column_name='mentoremail', field='email', model=ResearchMentor) + office_addr = CharField(column_name='officeaddr', max_length=100, null=True) + role = CharField(max_length=100, null=True) class Meta: table_name = 'works_at' indexes = ( - (('mentor_email', 'inst'), True), + (('mentoremail', 'instid'), True), ) - primary_key = CompositeKey('inst', 'mentor_email') - + schema = 'arxiv' + +""" +Table "arxiv.works_on" + Column | Type | Collation | Nullable | Default +--------------+------------------------+-----------+----------+-------------------------------------- + id | bigint | | not null | nextval('works_on_id_seq'::regclass) + studentemail | character varying(255) | | not null | + pcode | character varying(20) | | not null | +Indexes: + "idx_16498_primary" PRIMARY KEY, btree (id) + "idx_16498_pcode" btree (pcode) + "idx_16498_studentemail" UNIQUE, btree (studentemail, pcode) +Foreign-key constraints: + "works_on_ibfk_1" FOREIGN KEY (pcode) REFERENCES project(pcode) ON UPDATE CASCADE ON DELETE CASCADE + "works_on_ibfk_2" FOREIGN KEY (studentemail) REFERENCES student(email) ON UPDATE CASCADE ON DELETE CASCADE +""" class WorksOn(BaseModel): - pcode = ForeignKeyField(column_name='pcode', field='pcode', model=Project) - student_email = ForeignKeyField(column_name='studentEmail', field='email', model=Student) + id = BigAutoField() + project_code = ForeignKeyField(column_name='pcode', field='pcode', model=Project) + student_email = ForeignKeyField(column_name='studentemail', field='email', model=Student) class Meta: table_name = 'works_on' indexes = ( - (('student_email', 'pcode'), True), + (('studentemail', 'pcode'), True), ) - primary_key = CompositeKey('pcode', 'student_email') + schema = 'arxiv'