refactor: remove Vendor.owner_user_id column

- Remove owner_user_id column and owner relationship from Vendor model
- Update User model ownership checks to use company relationship
- Add migration to drop owner_user_id column from vendors table

Ownership is now determined solely via vendor.company.owner_user_id

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-02 19:39:08 +01:00
parent 14054bfd6d
commit 5ba4603ac9
4 changed files with 72 additions and 246 deletions

View File

@@ -50,10 +50,6 @@ class Vendor(Base, TimestampMixin):
name = Column(String, nullable=False) # Non-nullable name column for the vendor (brand name)
description = Column(Text) # Optional text description column for the vendor
owner_user_id = Column(
Integer, ForeignKey("users.id"), nullable=True
) # Foreign key to user ID of the vendor's owner (DEPRECATED - use company.owner_user_id instead)
# Letzshop URLs - multi-language support (brand-specific marketplace feeds)
letzshop_csv_url_fr = Column(String) # URL for French CSV in Letzshop
letzshop_csv_url_en = Column(String) # URL for English CSV in Letzshop
@@ -73,9 +69,6 @@ class Vendor(Base, TimestampMixin):
company = relationship(
"Company", back_populates="vendors"
) # Relationship with Company model for the parent company
owner = relationship(
"User", back_populates="owned_vendors"
) # Relationship with User model for the vendor's owner (legacy)
vendor_users = relationship(
"VendorUser", back_populates="vendor"
) # Relationship with VendorUser model for users in this vendor