class TaskInfo(_TableLayout): """ Task table with the required fields to help the user work with their task nodes. """ node_name = _Field.TextField() name = _Field.TextField() state = _Field.TextField() type = _Field.TextField()
class NodeRegister(_TableLayout): """ Table to identify nodes """ name = _Field.TextField(unique=True, pk=True) status = _Field.TextField() port = _Field.IntField() def __eq__(self, other): return self.name == other.name def __hash__(self): return hash(self.name)
class TaskRegister(_TableLayout): """ Task table with the required fields to help the user work with their task nodes. """ node = _Field.ForeignKeyField(NodeRegister) # -- The name of this task name = _Field.TextField() # -- The current state of the task state = _Field.TextField(default='pending') # -- The endpoint that we use to construct # requests for the task endpoint = _Field.TextField() # -- The type of this task type = _Field.TextField() @classmethod def unqiue_constraints(cls): return (('node', 'name'), )
class TableDefinition(_TableLayout): """ Table describing the migrations that we've gone through for our tables. """ table_name = _Field.TextField() table_layout = _Field.JSONField() @classmethod def register_table(cls, interface, table: _TableLayout) -> None: """ Based on the layout of the table, we have to convert everything to json """ interface.create(TableDefinition, table_name=table.db_name(), table_layout=table.db_layout())
class SomeRelation(_TableLayout): test = _Field.ForeignKeyField(TestTable) foo = _Field.TextField(null=True)
class NullOk(_TableLayout): blarg = _Field.TextField(null=True)
class MyTable(_TableLayout): numba = _Field.IntField(unique=True) foo = _Field.TextField()
class MyTable(_TableLayout): numba = _Field.IntField() foo = _Field.TextField()