Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add UniqueConstraint to 'name' and 'organization_id' in DataProfile m… #110

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading