crossid / accessbot

Streamline resource access grants with AI-Powered chatbot
https://www.crossid.io
Other
2 stars 0 forks source link

All DB tables must have org_id key #20

Closed asaf closed 8 months ago

asaf commented 9 months ago

Important when using DBs such as Azure CosmosDB where _org_id is the distribution key required for table colocation.

ErezSha commented 9 months ago

Some context for distribution key: Composite foreign key

class Book(Base):
    __tablename__ = 'books'
    title = Column(String(20), primary_key=True)
    author_firstName = Column(String(20))
    author_lastName = Column(String(20))
    __table_args__ = (ForeignKeyConstraint([author_firstName, author_lastName], [Author.firstName, Author.lastName]),{})

composite primary key

class Book(Base):
    __tablename__ = 'books'
    title = Column(String(20), primary_key=True)
    author_firstName = Column(String(20), primary_key=True)

creating distributed tables

SELECT create_distributed_table('org', 'id');  //create_distributed_table_concurrently()
SELECT create_distributed_table('request', 'org_id', colocate_with => 'org');
SELECT create_distributed_table('message', 'org_id', colocate_with => 'org');
ErezSha commented 9 months ago

@asaf This is currently an issue, because org_id is nullable on both request and message tables. Primary key can't be nullable. We'll have to decide what we want to do about the "global" org before we can commit anything for this issue.

asaf commented 8 months ago

@ErezSha what's left here? agreed not to allow null org_id as global is going to be a tenant, Please make sure all org_id fields are not nullable and resolve the ticket.