{ "id": "a1af6caa-ef04-4d68-ab28-68ba8ebbaf0b", "prevId": "6f6d04f6-92de-4c28-8736-75fafbfa3aef", "version": "7", "dialect": "postgresql", "tables": { "shared.account": { "name": "account", "schema": "shared", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "account_id": { "name": "account_id", "type": "text", "primaryKey": false, "notNull": true }, "provider_id": { "name": "provider_id", "type": "text", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "access_token": { "name": "access_token", "type": "text", "primaryKey": false, "notNull": false }, "refresh_token": { "name": "refresh_token", "type": "text", "primaryKey": false, "notNull": false }, "id_token": { "name": "id_token", "type": "text", "primaryKey": false, "notNull": false }, "access_token_expires_at": { "name": "access_token_expires_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "refresh_token_expires_at": { "name": "refresh_token_expires_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "scope": { "name": "scope", "type": "text", "primaryKey": false, "notNull": false }, "password": { "name": "password", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true } }, "indexes": {}, "foreignKeys": { "account_user_id_user_id_fk": { "name": "account_user_id_user_id_fk", "tableFrom": "account", "tableTo": "user", "schemaTo": "shared", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "shared.apikey": { "name": "apikey", "schema": "shared", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": false }, "start": { "name": "start", "type": "text", "primaryKey": false, "notNull": false }, "prefix": { "name": "prefix", "type": "text", "primaryKey": false, "notNull": false }, "key": { "name": "key", "type": "text", "primaryKey": false, "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "refill_interval": { "name": "refill_interval", "type": "integer", "primaryKey": false, "notNull": false }, "refill_amount": { "name": "refill_amount", "type": "integer", "primaryKey": false, "notNull": false }, "last_refill_at": { "name": "last_refill_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "enabled": { "name": "enabled", "type": "boolean", "primaryKey": false, "notNull": false, "default": true }, "rate_limit_enabled": { "name": "rate_limit_enabled", "type": "boolean", "primaryKey": false, "notNull": false, "default": true }, "rate_limit_time_window": { "name": "rate_limit_time_window", "type": "integer", "primaryKey": false, "notNull": false, "default": 86400000 }, "rate_limit_max": { "name": "rate_limit_max", "type": "integer", "primaryKey": false, "notNull": false, "default": 10 }, "request_count": { "name": "request_count", "type": "integer", "primaryKey": false, "notNull": false }, "remaining": { "name": "remaining", "type": "integer", "primaryKey": false, "notNull": false }, "last_request": { "name": "last_request", "type": "timestamp", "primaryKey": false, "notNull": false }, "expires_at": { "name": "expires_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "permissions": { "name": "permissions", "type": "text", "primaryKey": false, "notNull": false }, "metadata": { "name": "metadata", "type": "text", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": { "apikey_user_id_user_id_fk": { "name": "apikey_user_id_user_id_fk", "tableFrom": "apikey", "tableTo": "user", "schemaTo": "shared", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "shared.session": { "name": "session", "schema": "shared", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "expires_at": { "name": "expires_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "token": { "name": "token", "type": "text", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "ip_address": { "name": "ip_address", "type": "text", "primaryKey": false, "notNull": false }, "user_agent": { "name": "user_agent", "type": "text", "primaryKey": false, "notNull": false }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true } }, "indexes": {}, "foreignKeys": { "session_user_id_user_id_fk": { "name": "session_user_id_user_id_fk", "tableFrom": "session", "tableTo": "user", "schemaTo": "shared", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "session_token_unique": { "name": "session_token_unique", "nullsNotDistinct": false, "columns": [ "token" ] } }, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "shared.user": { "name": "user", "schema": "shared", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "name": { "name": "name", "type": "text", "primaryKey": false, "notNull": true }, "email": { "name": "email", "type": "text", "primaryKey": false, "notNull": true }, "email_verified": { "name": "email_verified", "type": "boolean", "primaryKey": false, "notNull": true }, "image": { "name": "image", "type": "text", "primaryKey": false, "notNull": false }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "username": { "name": "username", "type": "text", "primaryKey": false, "notNull": false }, "display_username": { "name": "display_username", "type": "text", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": { "user_email_unique": { "name": "user_email_unique", "nullsNotDistinct": false, "columns": [ "email" ] }, "user_username_unique": { "name": "user_username_unique", "nullsNotDistinct": false, "columns": [ "username" ] } }, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "shared.verification": { "name": "verification", "schema": "shared", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "identifier": { "name": "identifier", "type": "text", "primaryKey": false, "notNull": true }, "value": { "name": "value", "type": "text", "primaryKey": false, "notNull": true }, "expires_at": { "name": "expires_at", "type": "timestamp", "primaryKey": false, "notNull": true }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "habit_tracker.habit": { "name": "habit", "schema": "habit_tracker", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "name": { "name": "name", "type": "varchar(255)", "primaryKey": false, "notNull": true }, "description": { "name": "description", "type": "text", "primaryKey": false, "notNull": false }, "frequency_type": { "name": "frequency_type", "type": "varchar(20)", "primaryKey": false, "notNull": true }, "target_count": { "name": "target_count", "type": "integer", "primaryKey": false, "notNull": true, "default": 1 }, "interval_days": { "name": "interval_days", "type": "integer", "primaryKey": false, "notNull": false }, "active": { "name": "active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "deleted_at": { "name": "deleted_at", "type": "timestamp", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": { "habit_user_id_user_id_fk": { "name": "habit_user_id_user_id_fk", "tableFrom": "habit", "tableTo": "user", "schemaTo": "shared", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": { "freqency_type_check": { "name": "freqency_type_check", "value": "\"habit_tracker\".\"habit\".\"frequency_type\" IN ('daily', 'interval', 'multi_daily')" }, "target_count_check": { "name": "target_count_check", "value": "\"habit_tracker\".\"habit\".\"target_count\" > 0" }, "interval_days_check": { "name": "interval_days_check", "value": "(\"habit_tracker\".\"habit\".\"frequency_type\" = 'interval' AND \"habit_tracker\".\"habit\".\"interval_days\" IS NOT NULL AND \"habit_tracker\".\"habit\".\"interval_days\" > 0) OR (\"habit_tracker\".\"habit\".\"frequency_type\" != 'interval' AND \"habit_tracker\".\"habit\".\"interval_days\" IS NULL)" } }, "isRLSEnabled": false }, "habit_tracker.habit_completion": { "name": "habit_completion", "schema": "habit_tracker", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "habit_id": { "name": "habit_id", "type": "uuid", "primaryKey": false, "notNull": true }, "notes": { "name": "notes", "type": "text", "primaryKey": false, "notNull": false }, "completed_at": { "name": "completed_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "deleted_at": { "name": "deleted_at", "type": "timestamp", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": { "habit_completion_habit_id_habit_id_fk": { "name": "habit_completion_habit_id_habit_id_fk", "tableFrom": "habit_completion", "tableTo": "habit", "schemaTo": "habit_tracker", "columnsFrom": [ "habit_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, "intake_tracker.daily_summary": { "name": "daily_summary", "schema": "intake_tracker", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "intake_metric_id": { "name": "intake_metric_id", "type": "uuid", "primaryKey": false, "notNull": true }, "date": { "name": "date", "type": "date", "primaryKey": false, "notNull": true }, "total_value": { "name": "total_value", "type": "numeric(10, 2)", "primaryKey": false, "notNull": true }, "entry_count": { "name": "entry_count", "type": "integer", "primaryKey": false, "notNull": true }, "first_entry_at": { "name": "first_entry_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "last_entry_at": { "name": "last_entry_at", "type": "timestamp", "primaryKey": false, "notNull": false }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "deleted_at": { "name": "deleted_at", "type": "timestamp", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": { "daily_summary_intake_metric_id_intake_metric_id_fk": { "name": "daily_summary_intake_metric_id_intake_metric_id_fk", "tableFrom": "daily_summary", "tableTo": "intake_metric", "schemaTo": "intake_tracker", "columnsFrom": [ "intake_metric_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "daily_summary_intake_metric_id_date_unique": { "name": "daily_summary_intake_metric_id_date_unique", "nullsNotDistinct": false, "columns": [ "intake_metric_id", "date" ] } }, "policies": {}, "checkConstraints": { "positive_total_check": { "name": "positive_total_check", "value": "\"intake_tracker\".\"daily_summary\".\"total_value\" > 0" }, "positive_count_check": { "name": "positive_count_check", "value": "\"intake_tracker\".\"daily_summary\".\"entry_count\" > 0" } }, "isRLSEnabled": false }, "intake_tracker.intake_metric": { "name": "intake_metric", "schema": "intake_tracker", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, "metric_type": { "name": "metric_type", "type": "varchar(50)", "primaryKey": false, "notNull": true }, "unit": { "name": "unit", "type": "varchar(20)", "primaryKey": false, "notNull": true }, "display_name": { "name": "display_name", "type": "varchar(100)", "primaryKey": false, "notNull": true }, "target_value": { "name": "target_value", "type": "numeric(10, 2)", "primaryKey": false, "notNull": false }, "min_value": { "name": "min_value", "type": "numeric(10, 2)", "primaryKey": false, "notNull": false }, "max_value": { "name": "max_value", "type": "numeric(10, 2)", "primaryKey": false, "notNull": false }, "is_cumulative": { "name": "is_cumulative", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "active": { "name": "active", "type": "boolean", "primaryKey": false, "notNull": true, "default": true }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "deleted_at": { "name": "deleted_at", "type": "timestamp", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": { "intake_metric_user_id_user_id_fk": { "name": "intake_metric_user_id_user_id_fk", "tableFrom": "intake_metric", "tableTo": "user", "schemaTo": "shared", "columnsFrom": [ "user_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { "intake_metric_user_id_metric_type_unique": { "name": "intake_metric_user_id_metric_type_unique", "nullsNotDistinct": false, "columns": [ "user_id", "metric_type" ] } }, "policies": {}, "checkConstraints": { "positive_target_check": { "name": "positive_target_check", "value": "\"intake_tracker\".\"intake_metric\".\"target_value\" IS NULL OR \"intake_tracker\".\"intake_metric\".\"target_value\" > 0" }, "positive_min_check": { "name": "positive_min_check", "value": "\"intake_tracker\".\"intake_metric\".\"min_value\" IS NULL OR \"intake_tracker\".\"intake_metric\".\"min_value\" >= 0" }, "positive_max_check": { "name": "positive_max_check", "value": "\"intake_tracker\".\"intake_metric\".\"max_value\" IS NULL OR \"intake_tracker\".\"intake_metric\".\"max_value\" >= 0" }, "min_max_check": { "name": "min_max_check", "value": "\"intake_tracker\".\"intake_metric\".\"min_value\" IS NULL OR \"intake_tracker\".\"intake_metric\".\"max_value\" IS NULL OR \"intake_tracker\".\"intake_metric\".\"min_value\" <= \"intake_tracker\".\"intake_metric\".\"max_value\"" } }, "isRLSEnabled": false }, "intake_tracker.intake_record": { "name": "intake_record", "schema": "intake_tracker", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, "notNull": true, "default": "gen_random_uuid()" }, "intake_metric_id": { "name": "intake_metric_id", "type": "uuid", "primaryKey": false, "notNull": true }, "value": { "name": "value", "type": "numeric(10, 2)", "primaryKey": false, "notNull": false }, "recorded_at": { "name": "recorded_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "notes": { "name": "notes", "type": "text", "primaryKey": false, "notNull": false }, "updated_at": { "name": "updated_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "created_at": { "name": "created_at", "type": "timestamp", "primaryKey": false, "notNull": true, "default": "now()" }, "deleted_at": { "name": "deleted_at", "type": "timestamp", "primaryKey": false, "notNull": false } }, "indexes": {}, "foreignKeys": { "intake_record_intake_metric_id_intake_metric_id_fk": { "name": "intake_record_intake_metric_id_intake_metric_id_fk", "tableFrom": "intake_record", "tableTo": "intake_metric", "schemaTo": "intake_tracker", "columnsFrom": [ "intake_metric_id" ], "columnsTo": [ "id" ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, "checkConstraints": { "positive_value_check": { "name": "positive_value_check", "value": "\"intake_tracker\".\"intake_record\".\"value\" > 0" }, "recorded_at_not_future_check": { "name": "recorded_at_not_future_check", "value": "\"intake_tracker\".\"intake_record\".\"recorded_at\" <= NOW()" } }, "isRLSEnabled": false } }, "enums": {}, "schemas": { "shared": "shared", "habit_tracker": "habit_tracker", "intake_tracker": "intake_tracker" }, "sequences": {}, "roles": {}, "policies": {}, "views": {}, "_meta": { "columns": {}, "schemas": {}, "tables": {} } }