"""
@deprecated
棄用：改從fullstack直接抓elasticsearch資料並存入postgres
"""
import datetime
# from peewee import *
from playhouse.postgres_ext import *

db = PostgresqlExtDatabase('prisma', user='username',
                           password='password', host='pg', port=5432)


class BaseModel(Model):
    class Meta:
        database = db


class Page(Model):
    class Meta:
        database = db
        table_name = "Page"
    title = TextField()
    template = TextField()
    props = JSONField()
    createdAt = DateTimeField(null=True)
    updatedAt = DateTimeField()
    symbolName = TextField(null=True)


def test():
    p = Page.create(
        title="ABC",
        template="ABC",
        props={'k1': 'v1'},
        #     symbolName = "$BA",
        updatedAt=datetime.datetime.now()
    )
