Initial commit: AuroraMusic monorepo
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: aurora-db
|
||||
Version: 0.1.0
|
||||
Requires-Python: >=3.10
|
||||
Requires-Dist: sqlalchemy>=2.0
|
||||
Requires-Dist: psycopg[binary]>=3.2.3
|
||||
@@ -0,0 +1,14 @@
|
||||
__init__.py
|
||||
base.py
|
||||
models.py
|
||||
pyproject.toml
|
||||
session.py
|
||||
./__init__.py
|
||||
./base.py
|
||||
./models.py
|
||||
./session.py
|
||||
aurora_db.egg-info/PKG-INFO
|
||||
aurora_db.egg-info/SOURCES.txt
|
||||
aurora_db.egg-info/dependency_links.txt
|
||||
aurora_db.egg-info/requires.txt
|
||||
aurora_db.egg-info/top_level.txt
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
sqlalchemy>=2.0
|
||||
psycopg[binary]>=3.2.3
|
||||
@@ -0,0 +1 @@
|
||||
aurora_db
|
||||
@@ -0,0 +1,5 @@
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
@@ -0,0 +1,60 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint, func
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from .base import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
email: Mapped[str] = mapped_column(String(255), unique=True, index=True, nullable=False)
|
||||
hashed_password: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||
display_name: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
songs: Mapped[list["Song"]] = relationship(back_populates="owner", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class Song(Base):
|
||||
__tablename__ = "songs"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"))
|
||||
|
||||
title: Mapped[str] = mapped_column(String(200), nullable=False)
|
||||
prompt: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
lyrics: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
mode: Mapped[str] = mapped_column(String(20), default="instrumental") # instrumental | vocals
|
||||
|
||||
status: Mapped[str] = mapped_column(String(20), default="pending") # pending|processing|completed|failed
|
||||
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
audio_path: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
||||
duration_seconds: Mapped[float | None] = mapped_column(nullable=True)
|
||||
cover_seed: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
is_public: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
like_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
owner: Mapped["User"] = relationship(back_populates="songs")
|
||||
likes: Mapped[list["Like"]] = relationship(back_populates="song", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class Like(Base):
|
||||
__tablename__ = "likes"
|
||||
__table_args__ = (UniqueConstraint("user_id", "song_id", name="uq_like_user_song"),)
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"))
|
||||
song_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("songs.id", ondelete="CASCADE"))
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
song: Mapped["Song"] = relationship(back_populates="likes")
|
||||
@@ -0,0 +1,15 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=68"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "aurora-db"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = ["sqlalchemy>=2.0", "psycopg[binary]>=3.2.3"]
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["aurora_db"]
|
||||
|
||||
[tool.setuptools.package-dir]
|
||||
aurora_db = "."
|
||||
@@ -0,0 +1,10 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
|
||||
def make_engine(database_url: str):
|
||||
return create_engine(database_url, pool_pre_ping=True)
|
||||
|
||||
|
||||
def make_sessionmaker(engine):
|
||||
return sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
Reference in New Issue
Block a user