Complete and total rework ahead.

This commit is contained in:
Conrad Nelson 2025-09-03 16:33:52 -05:00
parent 559fd56f33
commit e420110fb3
95 changed files with 394 additions and 6351 deletions

26
crudkit/core/base.py Normal file
View file

@ -0,0 +1,26 @@
from sqlalchemy import Column, Integer, DateTime, Boolean, String, JSON, func
from sqlalchemy.orm import declarative_mixin, declarative_base
Base = declarative_base()
@declarative_mixin
class CRUDMixin:
id = Column(Integer, primary_key=True)
created_at = Column(DateTime, default=func.now())
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
def as_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class Version(Base):
__tablename__ = "versions"
id = Column(Integer, primary_key=True)
model_name = Column(String, nullable=False)
object_id = Column(Integer, nullable=False)
change_type = Column(String, nullable=False)
data = Column(JSON, nullable=True)
timestamp = Column(DateTime, default=func.now())
actor = Column(String, nullable=True)
metadata = Column(JSON, nullable=True)