Skip to content

Commit

Permalink
Merge pull request #110 from DocShow-AI/unique_names
Browse files Browse the repository at this point in the history
add UniqueConstraint to 'name' and 'organization_id' in DataProfile m…
  • Loading branch information
liberty-rising authored Dec 11, 2023
2 parents 46b8ee2 + 3e56436 commit b3df18e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/models/data_profile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from sqlalchemy import Column, Integer, String, ForeignKey
from pydantic import BaseModel
from .base import Base
from sqlalchemy import UniqueConstraint


class DataProfile(Base):

"""
DataProfile Model
-----------------
Expand All @@ -20,11 +20,15 @@ class DataProfile(Base):

__tablename__ = "data_profiles"
id = Column(Integer, primary_key=True)
name = Column(String)
name = Column(String, unique=True)
file_type = Column(String)
organization_id = Column(Integer, ForeignKey("organizations.id"))
description = Column(String) # New description column

__table_args__ = (
UniqueConstraint("name", "organization_id", name="uq_name_organization_id"),
)

def to_dict(self):
"""
Converts the DataProfile instance into a dictionary.
Expand Down

0 comments on commit b3df18e

Please sign in to comment.