flesh out schemas a bit

main
lza_menace 3 years ago
parent ad94349acb
commit e30185d85e

@ -23,5 +23,4 @@ def create_app():
app.register_blueprint(meta.bp)
app.register_blueprint(api.bp)
app.register_blueprint(filters.bp)
return cli(app)

@ -1,22 +1,17 @@
from datetime import datetime
from uuid import uuid4
import peewee as pw
from peewee import PostgresqlDatabase, SQL, ForeignKeyField
from xmrbackers import config
db = PostgresqlDatabase(
db = pw.PostgresqlDatabase(
config.DB_NAME,
user=config.DB_USER,
password=config.DB_PASS,
host=config.DB_HOST,
)
def rand_id():
return uuid4().hex
class Creator(pw.Model):
id = pw.AutoField()
@ -43,3 +38,45 @@ class Backer(pw.Model):
class Meta:
database = db
class SubscriptionMeta(pw.Model):
id = pw.AutoField()
create_date = pw.DateTimeField(default=datetime.now)
creator = pw.ForeignKeyField(Creator)
atomic_xmr = pw.BigIntegerField()
number_hours = pw.IntegerField()
def get_end_date(self) -> datetime:
# some timedelta shiz
pass
class Meta:
database = db
class Subscription(pw.Model):
id = pw.AutoField()
subscribe_date = pw.DateTimeField(default=datetime.now)
active = pw.BooleanField(default=True)
creator = pw.ForeignKeyField(Creator)
backer = pw.ForeignKeyField(Backer)
meta = pw.ForeignKeyField(SubscriptionMeta)
xmr_address = pw.CharField(unique=True)
xmr_acct_idx = pw.BigIntegerField(unique=True) # in case it gets many subscribers
xmr_addr_idx = pw.BigIntegerField(unique=True)
class Meta:
database = db
class TextPost(pw.Model):
id = pw.AutoField()
post_date = pw.DateTimeField(default=datetime.now)
hidden = pw.BooleanField(default=False)
content = pw.TextField()
title = pw.CharField()
last_edit_date = pw.DateTimeField(default=datetime.now)
creator = pw.ForeignKeyField(Creator)
class Meta:
database = db

Loading…
Cancel
Save