|
1 | 1 | from diracx.db.sql.job.db import JobDBBase |
| 2 | +from diracx.db.sql.job.schema import InputData, Jobs |
2 | 3 | from diracx.db.sql.utils import Column |
3 | 4 | from sqlalchemy import ( |
4 | 5 | ForeignKey, |
| 6 | + Index, |
5 | 7 | Integer, |
6 | 8 | String, |
| 9 | + Text, |
7 | 10 | ) |
8 | 11 |
|
9 | 12 |
|
| 13 | +# Create a new external table for Gubbins-specific categories |
| 14 | +class GubbinsCategories(JobDBBase): |
| 15 | + """External table for Gubbins-specific categories""" |
| 16 | + |
| 17 | + __tablename__ = "GubbinsCategories" |
| 18 | + |
| 19 | + category_id = Column("CategoryID", Integer, primary_key=True, autoincrement=True) |
| 20 | + category_name = Column("CategoryName", String(255), nullable=False) |
| 21 | + description = Column("Description", Text, default="") |
| 22 | + |
| 23 | + __table_args__ = (Index("CategoryName", "CategoryName"),) |
| 24 | + |
| 25 | + |
| 26 | +# Create a new Jobs table with modified schema (replacing the original) |
| 27 | +class GubbinsJobs(Jobs): |
| 28 | + """Custom Jobs table with modified column specifications and foreign key to GubbinsCategories""" |
| 29 | + |
| 30 | + __tablename__ = "Jobs" |
| 31 | + |
| 32 | + # Modified: job_name with VARCHAR(512) instead of VARCHAR(128) |
| 33 | + job_name = Column("JobName", String(512), default="Unknown") |
| 34 | + |
| 35 | + # New foreign key constraint to GubbinsCategories table |
| 36 | + category_id = Column( |
| 37 | + "CategoryID", Integer, ForeignKey("GubbinsCategories.CategoryID") |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +# Extended InputData table with Adler checksum column |
| 42 | +class GubbinsInputData(InputData): |
| 43 | + """Extended InputData table with Adler checksum support""" |
| 44 | + |
| 45 | + __tablename__ = "InputData" |
| 46 | + |
| 47 | + # New column for Adler checksum |
| 48 | + adler_checksum = Column("AdlerChecksum", String(75), nullable=True) |
| 49 | + |
| 50 | + |
10 | 51 | # You need to inherit from the declarative_base of the parent DB |
11 | 52 | class GubbinsInfo(JobDBBase): |
12 | 53 | """An extra table with respect to Vanilla diracx JobDB""" |
13 | 54 |
|
14 | | - __tablename__ = "GubbinsJobs" |
| 55 | + __tablename__ = "GubbinsInfo" |
15 | 56 |
|
16 | 57 | job_id = Column( |
17 | 58 | "JobID", Integer, ForeignKey("Jobs.JobID", ondelete="CASCADE"), primary_key=True |
|
0 commit comments