Remove Org.created_at to maintain compatibility with old versions (the field was not being used).
This commit is contained in:
@@ -264,9 +264,7 @@ def create_org(org: Org, *, ctx: SessionContext | None = None) -> None:
|
||||
if org.uuid in _db.orgs:
|
||||
raise ValueError(f"Organization {org.uuid} already exists")
|
||||
with _db.transaction("admin:create_org", ctx):
|
||||
new_org = Org(
|
||||
display_name=org.display_name, created_at=datetime.now(timezone.utc)
|
||||
)
|
||||
new_org = Org(display_name=org.display_name)
|
||||
_db.orgs[org.uuid] = new_org
|
||||
new_org.uuid = org.uuid
|
||||
# Create Administration role with org admin permission
|
||||
@@ -885,10 +883,7 @@ def bootstrap(
|
||||
_db.permissions[perm_org_admin_uuid] = perm_org_admin
|
||||
|
||||
# Create organization
|
||||
new_org = Org(
|
||||
display_name=org_name,
|
||||
created_at=now,
|
||||
)
|
||||
new_org = Org(display_name=org_name)
|
||||
new_org.uuid = org_uuid
|
||||
_db.orgs[org_uuid] = new_org
|
||||
|
||||
|
||||
+3
-12
@@ -84,15 +84,9 @@ class Role(msgspec.Struct, dict=True, omit_defaults=True):
|
||||
|
||||
|
||||
class Org(msgspec.Struct, dict=True):
|
||||
"""Organization data structure.
|
||||
|
||||
Mutable fields: display_name
|
||||
Immutable fields: created_at (set at creation, never modified)
|
||||
uuid is derived from created_at using uuid7.
|
||||
"""
|
||||
"""Organization data structure."""
|
||||
|
||||
display_name: str
|
||||
created_at: datetime
|
||||
|
||||
def __post_init__(self):
|
||||
self.uuid: UUID = _UUID_UNSET # Convenience field, not serialized
|
||||
@@ -100,11 +94,8 @@ class Org(msgspec.Struct, dict=True):
|
||||
@classmethod
|
||||
def create(cls, display_name: str) -> "Org":
|
||||
"""Create a new Org with auto-generated uuid7."""
|
||||
org = cls(
|
||||
display_name=display_name,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
)
|
||||
org.uuid = uuid7.create(org.created_at)
|
||||
org = cls(display_name=display_name)
|
||||
org.uuid = uuid7.create()
|
||||
return org
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user