Skip to content

Commit 6b0c8be

Browse files
authored
Merge pull request #305 from chaoss/feat/instance-db
Introduce a new operational forge_instance table
2 parents 5a4c4f7 + 69a123b commit 6b0c8be

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

collectoss/application/db/models/augur_operations.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# encoding: utf-8
2-
from sqlalchemy import BigInteger, SmallInteger, Column, Index, Integer, String, Table, text, UniqueConstraint, Boolean, ForeignKey, update, CheckConstraint, Sequence
2+
from sqlalchemy import BigInteger, SmallInteger, Column, Index, Integer, String, Table, text, UniqueConstraint, Boolean, ForeignKey, update, CheckConstraint, Sequence, DateTime, func
33
from sqlalchemy.dialects.postgresql import TIMESTAMP
44
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
55
from sqlalchemy.exc import IntegrityError
@@ -1072,6 +1072,20 @@ def get_by_id(session, client_id):
10721072
session.rollback()
10731073
raise e
10741074

1075+
class ForgeInstance(Base):
1076+
__tablename__ = "forge_instance"
1077+
__table_args__ = { "schema": "augur_operations" }
1078+
1079+
id = Column(Integer, primary_key=True, nullable=False, comment="Internal unique identifier for this forge instance")
1080+
# platform_type stores an integer that CollectOSS maps/will map to it's internal platform identifier Enum
1081+
# (as used in ContributorUUID) for identifying the API endpoints and tasks to use for collection
1082+
platform_type = Column(Integer, nullable=False, comment="Type specifier identifying the relevant platform API interface to CollectOSS")
1083+
name = Column(String, nullable=False, comment="User-specified name for this forge instance")
1084+
# https://stackoverflow.com/a/54800233
1085+
date_added = Column(DateTime(timezone=True), nullable=False, default=func.now())
1086+
domain_name = Column(String, nullable=False, comment="The base domain name (without the scheme) where this instance is hosted")
1087+
enabled = Column(Boolean, default=True, nullable=False, comment="denotes whether collection should run for this instance")
1088+
10751089

10761090
class Subscription(Base):
10771091
__tablename__ = "subscriptions"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""introduce empty instances table
2+
3+
Revision ID: 42
4+
Revises: 41
5+
Create Date: 2026-05-07 15:51:17.510641
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '42'
14+
down_revision = '41'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_table('forge_instance',
22+
sa.Column('id', sa.Integer(), nullable=False, comment='Internal unique identifier for this forge instance'),
23+
sa.Column('platform_type', sa.Integer(), nullable=False, comment='Type specifier identifying the relevant platform API interface to CollectOSS'),
24+
sa.Column('name', sa.String(), nullable=False, comment='User-specified name for this forge instance'),
25+
sa.Column('date_added', sa.DateTime(timezone=True), nullable=False),
26+
sa.Column('domain_name', sa.String(), nullable=False, comment='The base domain name (without the scheme) where this instance is hosted'),
27+
sa.Column('enabled', sa.Boolean(), nullable=False, comment='denotes whether collection should run for this instance'),
28+
sa.PrimaryKeyConstraint('id'),
29+
schema='augur_operations'
30+
)
31+
# ### end Alembic commands ###
32+
33+
34+
def downgrade():
35+
# ### commands auto generated by Alembic - please adjust! ###
36+
op.drop_table('forge_instance', schema='augur_operations')
37+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)