mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-02-23 15:49:50 +01:00
refactor DB
This commit is contained in:
0
euclid/database/models/__init__.py
Normal file
0
euclid/database/models/__init__.py
Normal file
10
euclid/database/models/app.py
Normal file
10
euclid/database/models/app.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.base_models import BaseModel
|
||||
from database.models.user import User
|
||||
|
||||
|
||||
class App(BaseModel):
|
||||
user = ForeignKeyField(User, backref='apps')
|
||||
app_type = CharField()
|
||||
status = CharField(default='started')
|
||||
9
euclid/database/models/architecture.py
Normal file
9
euclid/database/models/architecture.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class Architecture(ProgressStep):
|
||||
architecture = TextField()
|
||||
class Meta:
|
||||
db_table = 'architecture'
|
||||
0
euclid/database/models/components/__init__.py
Normal file
0
euclid/database/models/components/__init__.py
Normal file
24
euclid/database/models/components/base_models.py
Normal file
24
euclid/database/models/components/base_models.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from peewee import *
|
||||
from datetime import datetime
|
||||
from uuid import uuid4
|
||||
|
||||
from const import db
|
||||
|
||||
|
||||
# Establish connection to the database
|
||||
database = PostgresqlDatabase(
|
||||
db.DB_NAME,
|
||||
user=db.DB_USER,
|
||||
password=db.DB_PASSWORD,
|
||||
host=db.DB_HOST,
|
||||
port=db.DB_PORT
|
||||
)
|
||||
|
||||
|
||||
class BaseModel(Model):
|
||||
id = UUIDField(primary_key=True, default=uuid4)
|
||||
created_at = DateTimeField(default=datetime.now)
|
||||
updated_at = DateTimeField(default=datetime.now)
|
||||
|
||||
class Meta:
|
||||
database = database
|
||||
16
euclid/database/models/components/progress_step.py
Normal file
16
euclid/database/models/components/progress_step.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from peewee import *
|
||||
|
||||
from playhouse.postgres_ext import BinaryJSONField
|
||||
|
||||
from database.models.components.base_models import BaseModel
|
||||
from database.models.app import App
|
||||
|
||||
|
||||
class ProgressStep(BaseModel):
|
||||
app = ForeignKeyField(App, primary_key=True)
|
||||
step = CharField()
|
||||
data = BinaryJSONField(null=True)
|
||||
messages = BinaryJSONField(null=True)
|
||||
app_data = BinaryJSONField()
|
||||
completed = BooleanField(default=False)
|
||||
completed_at = DateTimeField(null=True)
|
||||
8
euclid/database/models/development.py
Normal file
8
euclid/database/models/development.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class Development(ProgressStep):
|
||||
class Meta:
|
||||
db_table = 'development'
|
||||
10
euclid/database/models/development_planning.py
Normal file
10
euclid/database/models/development_planning.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class DevelopmentPlanning(ProgressStep):
|
||||
architecture = TextField()
|
||||
|
||||
class Meta:
|
||||
db_table = 'development_planning'
|
||||
12
euclid/database/models/development_steps.py
Normal file
12
euclid/database/models/development_steps.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from peewee import *
|
||||
|
||||
from playhouse.postgres_ext import BinaryJSONField
|
||||
|
||||
from database.models.components.base_models import BaseModel
|
||||
from database.models.app import App
|
||||
|
||||
|
||||
class DevelopmentSteps(BaseModel):
|
||||
app = ForeignKeyField(App, primary_key=True)
|
||||
hash_id = CharField(unique=True, null=False)
|
||||
messages = BinaryJSONField(null=True)
|
||||
6
euclid/database/models/environment_setup.py
Normal file
6
euclid/database/models/environment_setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class EnvironmentSetup(ProgressStep):
|
||||
class Meta:
|
||||
db_table = 'environment_setup'
|
||||
13
euclid/database/models/project_description.py
Normal file
13
euclid/database/models/project_description.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from peewee import *
|
||||
|
||||
from playhouse.postgres_ext import BinaryJSONField
|
||||
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class ProjectDescription(ProgressStep):
|
||||
prompt = TextField()
|
||||
summary = TextField()
|
||||
|
||||
class Meta:
|
||||
db_table = 'project_description'
|
||||
8
euclid/database/models/user.py
Normal file
8
euclid/database/models/user.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.base_models import BaseModel
|
||||
|
||||
|
||||
class User(BaseModel):
|
||||
email = CharField(unique=True)
|
||||
password = CharField()
|
||||
9
euclid/database/models/user_stories.py
Normal file
9
euclid/database/models/user_stories.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class UserStories(ProgressStep):
|
||||
user_stories = TextField()
|
||||
class Meta:
|
||||
db_table = 'user_stories'
|
||||
9
euclid/database/models/user_tasks.py
Normal file
9
euclid/database/models/user_tasks.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.progress_step import ProgressStep
|
||||
|
||||
|
||||
class UserTasks(ProgressStep):
|
||||
user_tasks = TextField()
|
||||
class Meta:
|
||||
db_table = 'user_tasks'
|
||||
Reference in New Issue
Block a user