-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e450f9
commit fc7b13d
Showing
7 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from api import db | ||
from api.mixins import TimestampMixin | ||
|
||
|
||
class UserActivities(TimestampMixin, db.Model): | ||
|
||
__tablename__ = "user_activities" | ||
id = db.Column(db.Integer, primary_key=True) | ||
user_id = db.Column(db.Integer, db.ForeignKey("users.id")) | ||
user_flow_id = db.Column(db.Integer, db.ForeignKey("user_flows.id")) | ||
activity = db.Column(db.String(500)) | ||
started = db.Column(db.Boolean) | ||
started_on = db.Column(db.DateTime) | ||
succeeded = db.Column(db.Boolean) | ||
succeeded_on = db.Column(db.DateTime) | ||
completed = db.Column(db.Boolean) | ||
completed_on = db.Column(db.DateTime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from api import db | ||
from api.mixins import TimestampMixin | ||
|
||
|
||
class UserAttributes(TimestampMixin, db.Model): | ||
|
||
__tablename__ = "user_attributes" | ||
id = db.Column(db.Integer, primary_key=True) | ||
user_id = db.Column(db.Integer, db.ForeignKey("users.id")) | ||
user_phone = db.Column(db.String(50), nullable=False) | ||
field_name = db.Column(db.String(255)) | ||
field_value = db.Column(db.String(255)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from api import db | ||
from api.mixins import TimestampMixin | ||
|
||
|
||
class UserFlows(TimestampMixin, db.Model): | ||
|
||
__tablename__ = "user_flows" | ||
id = db.Column(db.Integer, primary_key=True) | ||
user_id = db.Column(db.Integer, db.ForeignKey("users.id")) | ||
user_phone = db.Column(db.String(50), nullable=False) | ||
flow_uuid = db.Column(db.String(255)) | ||
flow_name = db.Column(db.String(255)) | ||
flow_type = db.Column(db.String(255)) | ||
flow_run_status = db.Column(db.String(255)) | ||
flow_start_time = db.Column(db.DateTime) | ||
flow_end_time = db.Column(db.DateTime) | ||
is_active = db.Column(db.Boolean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from api import db | ||
from api.mixins import TimestampMixin | ||
|
||
|
||
class UserIndicatorResponses(TimestampMixin, db.Model): | ||
|
||
__tablename__ = "user_indicator_responses" | ||
id = db.Column(db.Integer, primary_key=True) | ||
user_id = db.Column(db.Integer, db.ForeignKey("users.id")) | ||
user_flow_id = db.Column(db.Integer, db.ForeignKey("user_flows.id")) | ||
indicator_question = db.Column(db.String(255)) | ||
indicator_question_response = db.Column(db.String(255)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from api import db | ||
from api.mixins import TimestampMixin | ||
|
||
|
||
class Users(TimestampMixin, db.Model): | ||
|
||
__tablename__ = "users" | ||
id = db.Column(db.Integer, primary_key=True) | ||
glific_user_id = db.Column(db.Integer) | ||
phone = db.Column(db.String(50), nullable=False) | ||
name = db.Column(db.String(255)) | ||
location = db.Column(db.String(500)) |
121 changes: 121 additions & 0 deletions
121
migrations/versions/f2990ee697ee_user_detail_based_tables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
"""User detail based tables. | ||
Revision ID: f2990ee697ee | ||
Revises: 70bea50174bf | ||
Create Date: 2024-04-19 19:35:08.841346 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "f2990ee697ee" | ||
down_revision = "70bea50174bf" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"users", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("glific_user_id", sa.Integer(), nullable=True), | ||
sa.Column("phone", sa.String(length=50), nullable=False), | ||
sa.Column("name", sa.String(length=255), nullable=True), | ||
sa.Column("location", sa.String(length=500), nullable=True), | ||
sa.Column("created_on", sa.DateTime(), nullable=True), | ||
sa.Column("updated_on", sa.DateTime(), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"user_attributes", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("user_phone", sa.String(length=50), nullable=False), | ||
sa.Column("field_name", sa.String(length=255), nullable=True), | ||
sa.Column("field_value", sa.String(length=255), nullable=True), | ||
sa.Column("created_on", sa.DateTime(), nullable=True), | ||
sa.Column("updated_on", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["users.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"user_flows", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("user_phone", sa.String(length=50), nullable=False), | ||
sa.Column("flow_uuid", sa.String(length=255), nullable=True), | ||
sa.Column("flow_name", sa.String(length=255), nullable=True), | ||
sa.Column("flow_type", sa.String(length=255), nullable=True), | ||
sa.Column("flow_run_status", sa.String(length=255), nullable=True), | ||
sa.Column("flow_start_time", sa.DateTime(), nullable=True), | ||
sa.Column("flow_end_time", sa.DateTime(), nullable=True), | ||
sa.Column("is_active", sa.Boolean(), nullable=True), | ||
sa.Column("created_on", sa.DateTime(), nullable=True), | ||
sa.Column("updated_on", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["users.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"user_activities", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("user_flow_id", sa.Integer(), nullable=True), | ||
sa.Column("activity", sa.String(length=500), nullable=True), | ||
sa.Column("started", sa.Boolean(), nullable=True), | ||
sa.Column("started_on", sa.DateTime(), nullable=True), | ||
sa.Column("succeeded", sa.Boolean(), nullable=True), | ||
sa.Column("succeeded_on", sa.DateTime(), nullable=True), | ||
sa.Column("completed", sa.Boolean(), nullable=True), | ||
sa.Column("completed_on", sa.DateTime(), nullable=True), | ||
sa.Column("created_on", sa.DateTime(), nullable=True), | ||
sa.Column("updated_on", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_flow_id"], | ||
["user_flows.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["users.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"user_indicator_responses", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("user_flow_id", sa.Integer(), nullable=True), | ||
sa.Column("indicator_question", sa.String(length=255), nullable=True), | ||
sa.Column( | ||
"indicator_question_response", sa.String(length=255), nullable=True | ||
), | ||
sa.Column("created_on", sa.DateTime(), nullable=True), | ||
sa.Column("updated_on", sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_flow_id"], | ||
["user_flows.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["users.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("user_indicator_responses") | ||
op.drop_table("user_activities") | ||
op.drop_table("user_flows") | ||
op.drop_table("user_attributes") | ||
op.drop_table("users") | ||
# ### end Alembic commands ### |