mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
a77705984e
With TREK_DB_URL set, TREK now boots on Postgres; without it nothing changes. - The database engine contract gains open, close, reopen and the schema bootstrap; DatabaseLifecycle delegates to the engine resolveEngine() picks. - An empty Postgres database gets server/assets/postgres/baseline.sql (generated from the entities by gen:pg-baseline, with the reference rows the migrations up to its cut insert: tour types, provider catalogues, addons, app settings) and every migration up to its cut recorded as executed, in one transaction. A database holding tables without TREK's history is refused before anything is written; a migrated one runs the newer-database refusal and its pending migrations, which refuse without a copy unless TREK_DB_PRE_MIGRATE_SNAPSHOT=false. - INTEGER columns are bigint on Postgres (SQLite's INTEGER is 64-bit: an epoch-millisecond column overflowed int4), and the engine's driver reads bigint and numeric back as numbers, refusing values past 2^53. - The two SQLite triggers are ported to PL/pgSQL; check:pg-baseline fails while a SQLite trigger has no port, and while the baseline drifts from the entities before a later migration freezes it. - Backups and restores on Postgres refuse until they can dump and load one. - Migration helpers read the catalog per engine (dialect/catalog.ts), and the email case index no longer needs group_concat. - CI runs check:pg-baseline and boots the image on postgres:17 twice.
826 lines
144 KiB
PL/PgSQL
826 lines
144 KiB
PL/PgSQL
-- The schema a fresh Postgres database starts from. Generated by `npm run gen:pg-baseline`; do not edit.
|
|
CREATE COLLATION IF NOT EXISTS nocase (provider = icu, locale = 'und-u-ks-level2', deterministic = false);
|
|
create table "addons" ("id" text null, "name" text not null, "description" text null, "type" text not null default 'global', "icon" text null default 'Puzzle', "enabled" boolean null default false, "config" jsonb null default '{}', "sort_order" bigint null default 0, primary key ("id"));
|
|
create table "app_settings" ("key" text null, "value" text null, primary key ("key"));
|
|
create table "document_providers" ("id" text null, "name" text not null, "description" text null, "icon" text null default 'FileText', "enabled" bigint null default 0, "sort_order" bigint null default 0, primary key ("id"));
|
|
create table "document_provider_fields" ("id" bigserial primary key, "provider_id" text not null, "field_key" text not null, "label" text not null, "input_type" text not null default 'text', "placeholder" text null, "hint" text null, "required" bigint null default 0, "secret" bigint null default 0, "sort_order" bigint null default 0);
|
|
alter table "document_provider_fields" add constraint "document_provider_fields_provider_id_field_key_unique" unique ("provider_id", "field_key");
|
|
create table "ferrata_tiles" ("tile_key" text not null, "payload" text not null, "fetched_at" bigint not null, primary key ("tile_key"));
|
|
create table "google_api_usage" ("day" text null, "calls" bigint not null default 0, primary key ("day"));
|
|
create table "google_place_photo_meta" ("place_id" text null, "attribution" text null, "fetched_at" bigint not null, "error_at" bigint null, primary key ("place_id"));
|
|
create table "migrations" ("id" bigserial primary key, "timestamp" bigint not null, "name" varchar(255) not null);
|
|
create table "paddle_region_requests" ("region_id" text not null, "name" text not null, "reason" text not null, "bytes" bigint null, "requested_by" text null, "requested_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "declined_at" text null, primary key ("region_id"));
|
|
alter table "paddle_region_requests" add constraint "paddle_region_requests_reason_check" check ("reason" in ('ask', 'too_large', 'limit'));
|
|
create table "paddle_regions" ("id" text not null, "name" text not null, "boundary" text null, "min_lat" double precision null, "min_lng" double precision null, "max_lat" double precision null, "max_lng" double precision null, "status" text not null default 'queued', "source_timestamp" text null, "imported_at" text null, "feature_count" bigint not null default 0, "error" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "origin" text not null default 'admin', primary key ("id"));
|
|
alter table "paddle_regions" add constraint "paddle_regions_status_check" check ("status" in ('queued', 'importing', 'ready', 'failed'));
|
|
alter table "paddle_regions" add constraint "paddle_regions_origin_check" check ("origin" in ('admin', 'auto'));
|
|
create table "paddle_features" ("id" bigserial primary key, "region_id" text not null, "osm_ref" text not null, "kind" text not null, "group_key" text null, "name" text null, "geometry" text not null, "tags" text not null, "tag_hash" text not null, "min_lat" double precision not null, "min_lng" double precision not null, "max_lat" double precision not null, "max_lng" double precision not null);
|
|
create index "idx_paddle_features_box" on "paddle_features" ("min_lat", "max_lat", "min_lng", "max_lng");
|
|
alter table "paddle_features" add constraint "idx_paddle_features_region_ref" unique ("region_id", "osm_ref");
|
|
create table "paddle_water_graphs" ("region_id" text null, "file" text not null, "rev" text not null, "bytes" bigint not null, "built_at" text not null, "stats" text not null, "min_lat" double precision not null, "min_lng" double precision not null, "max_lat" double precision not null, "max_lng" double precision not null, primary key ("region_id"));
|
|
create index "idx_paddle_water_graphs_box" on "paddle_water_graphs" ("min_lat", "max_lat", "min_lng", "max_lng");
|
|
alter table "paddle_water_graphs" add constraint "paddle_water_graphs_region_id_unique" unique ("region_id");
|
|
create table "photo_providers" ("id" text null, "name" text not null, "description" text null, "icon" text null default 'Image', "enabled" bigint null default 0, "sort_order" bigint null default 0, primary key ("id"));
|
|
create table "photo_provider_fields" ("id" bigserial primary key, "provider_id" text not null, "field_key" text not null, "label" text not null, "input_type" text not null default 'text', "placeholder" text null, "hint" text null, "required" bigint null default 0, "secret" bigint null default 0, "settings_key" text null, "payload_key" text null, "sort_order" bigint null default 0);
|
|
alter table "photo_provider_fields" add constraint "photo_provider_fields_provider_id_field_key_unique" unique ("provider_id", "field_key");
|
|
create table "place_contrib_log" ("id" bigserial primary key, "day" text not null, "contrib_key" text not null, "place_name" text not null, "field" text not null, "value_summary" text null, "result" text not null, "reason" text null);
|
|
create index "idx_place_contrib_log_day" on "place_contrib_log" ("day");
|
|
create table "place_details_cache" ("place_id" text not null, "lang" text not null default '', "expanded" bigint not null default 0, "payload_json" text not null, "fetched_at" bigint not null, primary key ("place_id", "lang", "expanded"));
|
|
create table "place_shadow_picks" ("id" bigserial primary key, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "query" text not null, "lang" text null, "bias_lat" double precision null, "bias_lng" double precision null, "source" text not null, "live_rank" bigint not null, "live_count" bigint not null, "picked_name" text not null, "picked_lat" double precision not null, "picked_lng" double precision not null, "picked_place_id" text null);
|
|
create index "idx_place_shadow_created" on "place_shadow_picks" ("created_at");
|
|
create table "plugin_actions" ("plugin_id" text not null, "action_key" text not null, "label" text not null, "hint" text null, "danger" bigint not null default 0, "sort_order" bigint not null default 0, "scope" text not null default 'user', primary key ("plugin_id", "action_key"));
|
|
create table "plugin_capability_audit" ("id" bigserial primary key, "plugin_id" text not null, "acting_user_id" bigint null, "method" text not null, "resource" text null, "code" text not null, "ts" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "prev_hash" text null, "hash" text not null);
|
|
create index "idx_plugin_audit_plugin" on "plugin_capability_audit" ("plugin_id", "id");
|
|
create table "plugin_egress_hosts" ("id" bigserial primary key, "plugin_id" text not null, "host" text not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_plugin_egress_hosts_plugin" on "plugin_egress_hosts" ("plugin_id");
|
|
alter table "plugin_egress_hosts" add constraint "plugin_egress_hosts_plugin_id_host_unique" unique ("plugin_id", "host");
|
|
create table "plugin_entity_metadata" ("id" bigserial primary key, "plugin_id" text not null, "entity_type" text not null, "entity_id" bigint not null, "key" text not null, "value" text null, "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_plugin_meta_entity" on "plugin_entity_metadata" ("plugin_id", "entity_type", "entity_id");
|
|
alter table "plugin_entity_metadata" add constraint "plugin_entity_metadata_plugin_id_entity_type_enti_ee00f_unique" unique ("plugin_id", "entity_type", "entity_id", "key");
|
|
create table "plugin_error_log" ("id" bigserial primary key, "plugin_id" text not null, "ts" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "level" text not null default 'error', "message" text null, "stack" text null);
|
|
create index "idx_plugin_error_log_plugin" on "plugin_error_log" ("plugin_id", "ts");
|
|
create table "plugin_meta_migrations" ("plugin_id" text not null, "migration_id" text not null, "applied_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("plugin_id", "migration_id"));
|
|
create table "plugin_oauth_state" ("state" text null, "plugin_id" text not null, "user_id" bigint not null, "verifier" text not null, "created_at" bigint not null, primary key ("state"));
|
|
create table "plugin_oauth_tokens" ("plugin_id" text not null, "user_id" bigint not null, "access_token" text null, "refresh_token" text null, "expires_at" bigint null, "scope" text null, "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("plugin_id", "user_id"));
|
|
create table "plugins" ("id" text null, "name" text not null, "description" text null, "type" text not null default 'integration', "icon" text null default 'Blocks', "version" text null, "api_version" bigint null default 1, "min_trek_version" text null, "permissions" text null default '[]', "granted_permissions" text null default '[]', "status" text not null default 'inactive', "config" text null default '{}', "source_repo" text null, "source_commit" text null, "sha256" text null, "crash_count" bigint not null default 0, "last_error" text null, "reviewed_at" text null, "sort_order" bigint not null default 0, "installed_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "enabled" bigint not null default 0, "capabilities" text not null default '{}', "author_pubkey" text null, "dependencies" text not null default '{}', "operator_egress" bigint not null default 0, "update_block_code" text null, "update_block_detail" text null, "update_block_version" text null, "trek_range" text null, "update_hold" bigint not null default 0, "trek_range_accepted_version" text null, "trek_range_accepted_host" text null, primary key ("id"));
|
|
create table "plugin_scheduled_tasks" ("id" bigserial primary key, "plugin_id" text not null, "name" text not null, "due_at" bigint not null, "payload" text not null default 'null', "every_ms" bigint null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_plugin_sched_due" on "plugin_scheduled_tasks" ("due_at");
|
|
alter table "plugin_scheduled_tasks" add constraint "plugin_scheduled_tasks_plugin_id_name_unique" unique ("plugin_id", "name");
|
|
create table "plugin_settings_fields" ("id" bigserial primary key, "plugin_id" text not null, "field_key" text not null, "label" text null, "input_type" text not null default 'text', "placeholder" text null, "hint" text null, "required" bigint not null default 0, "secret" bigint not null default 0, "scope" text not null default 'instance', "options" text null, "oauth_config" text null, "sort_order" bigint not null default 0, "default_value" text null);
|
|
alter table "plugin_settings_fields" add constraint "plugin_settings_fields_plugin_id_field_key_unique" unique ("plugin_id", "field_key");
|
|
create table "plugin_user_config" ("plugin_id" text not null, "user_id" bigint not null, "config" text not null default '{}', "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("plugin_id", "user_id"));
|
|
create table "plugin_user_erasure_queue" ("id" bigserial primary key, "plugin_id" text not null, "user_id" bigint not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_plugin_erasure_plugin" on "plugin_user_erasure_queue" ("plugin_id");
|
|
alter table "plugin_user_erasure_queue" add constraint "plugin_user_erasure_queue_plugin_id_user_id_unique" unique ("plugin_id", "user_id");
|
|
create table "route_usage_daily" ("day" text not null, "profile" text not null, "surface" text not null, "self_hosted" bigint not null, "requests" bigint not null default 0, "waypoints" bigint not null default 0, "km" double precision not null default 0, "failed" bigint not null default 0, primary key ("day", "profile", "surface", "self_hosted"));
|
|
create index "idx_route_usage_day" on "route_usage_daily" ("day");
|
|
create table "scheduler_leases" ("name" text not null, "owner" text not null, "expires_at" bigint not null, primary key ("name"));
|
|
create table "schema_version" ("id" bigserial primary key, "version" bigint not null);
|
|
create table "school_holiday_countries" ("code" text null, "name" text not null, primary key ("code"));
|
|
create table "school_holiday_regions" ("id" bigserial primary key, "name" text collate "nocase" not null, "revision" bigint not null default 1, "country" text not null);
|
|
alter table "school_holiday_regions" add constraint "school_holiday_regions_country_name_unique" unique ("country", "name");
|
|
create table "school_holiday_periods" ("id" bigserial primary key, "region_id" bigint not null, "name" text not null, "start_date" text not null, "end_date" text not null);
|
|
create index "idx_school_holiday_periods_region" on "school_holiday_periods" ("region_id");
|
|
alter table "school_holiday_periods" add constraint "school_holiday_periods_end_date_check" check (end_date >= start_date);
|
|
create table "storage_reclaim_marks" ("category" text not null, "key" text not null, "first_seen_at" text not null, "size" bigint not null, primary key ("category", "key"));
|
|
create table "storage_release_queue" ("category" text not null, "key" text not null, "due_at" text not null, primary key ("category", "key"));
|
|
create table "tour_types" ("key" text null, "label_key" text not null, "icon" text not null, "color" text not null, "routing_profile" text null, "is_sport" bigint not null default 1, "enabled" bigint not null default 1, "sort_order" bigint not null default 0, primary key ("key"));
|
|
create table "trek_photo_cache_meta" ("cache_key" text not null, "content_type" text not null default 'image/jpeg', "fetched_at" bigint not null, primary key ("cache_key"));
|
|
create index "idx_trek_photo_cache_meta_fetched_at" on "trek_photo_cache_meta" ("fetched_at");
|
|
create table "users" ("id" bigserial primary key, "username" text not null, "email" text not null, "password_hash" text not null, "role" text not null default 'user', "maps_api_key" text null, "unsplash_api_key" text null, "amap_api_key" text null, "openweather_api_key" text null, "avatar" text null, "oidc_sub" text null, "oidc_issuer" text null, "last_login" text null, "mfa_enabled" bigint null default 0, "mfa_secret" text null, "mfa_backup_codes" text null, "immich_url" text null, "immich_access_token" text null, "synology_url" text null, "synology_username" text null, "synology_password" text null, "synology_sid" text null, "must_change_password" bigint null default 0, "password_version" bigint not null default 0, "feed_token" text null, "is_guest" bigint not null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "immich_api_key" text null, "synology_skip_ssl" bigint not null default 0, "synology_did" text null, "first_seen_version" text not null default '0.0.0', "login_count" bigint not null default 0, "immich_auto_upload" bigint not null default 0, "airtrail_url" text null, "airtrail_api_key" text null, "airtrail_allow_insecure_tls" bigint null default 0, "airtrail_write_enabled" bigint null default 0, "display_name" text null, "immich_allow_insecure_tls" bigint not null default 0, "email_self_asserted" bigint not null default 0);
|
|
create index "idx_users_email" on "users" ("email");
|
|
create unique index "idx_users_feed_token" on "users" ("feed_token") where feed_token IS NOT NULL;
|
|
alter table "users" add constraint "users_email_unique" unique ("email");
|
|
alter table "users" add constraint "users_username_unique" unique ("username");
|
|
CREATE UNIQUE INDEX idx_users_email_lower ON users (lower(email));
|
|
create table "user_notice_dismissals" ("user_id" bigint not null, "notice_id" text not null, "dismissed_at" bigint not null, "dismissed_app_version" text null, primary key ("user_id", "notice_id"));
|
|
alter table "user_notice_dismissals" add constraint "user_notice_dismissals_user_id_notice_id_unique" unique ("user_id", "notice_id");
|
|
create table "trips" ("id" bigserial primary key, "user_id" bigint not null, "title" text not null, "description" text null, "start_date" text null, "end_date" text null, "currency" text null default 'EUR', "cover_image" text null, "is_archived" bigint null default 0, "reminder_days" bigint null default 3, "feed_token" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "reminder_sent_for" text null);
|
|
create index "idx_trips_user_id" on "trips" ("user_id");
|
|
create index "idx_trips_created_at" on "trips" ("created_at");
|
|
create unique index "idx_trips_feed_token" on "trips" ("feed_token") where feed_token IS NOT NULL;
|
|
create table "roadtrip_preferences" ("trip_id" bigint not null, "key" text not null, "value" text not null, primary key ("trip_id", "key"));
|
|
alter table "roadtrip_preferences" add constraint "roadtrip_preferences_trip_id_key_unique" unique ("trip_id", "key");
|
|
create table "days" ("id" bigserial primary key, "trip_id" bigint not null, "day_number" bigint not null, "date" text null, "notes" text null, "title" text null, "default_transport_mode" text null);
|
|
create index "idx_days_trip_id" on "days" ("trip_id");
|
|
alter table "days" add constraint "days_trip_id_day_number_unique" unique ("trip_id", "day_number");
|
|
create table "roadtrip_vias" ("id" bigserial primary key, "day_id" bigint not null, "after_order_index" bigint not null, "sequence" bigint not null default 0, "lat" double precision not null, "lng" double precision not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_roadtrip_vias_day" on "roadtrip_vias" ("day_id", "after_order_index", "sequence");
|
|
create table "day_notes" ("id" bigserial primary key, "day_id" bigint not null, "trip_id" bigint not null, "text" text not null, "time" text null, "icon" text null default '📝', "sort_order" double precision null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "color" text null);
|
|
create index "idx_day_notes_day_id" on "day_notes" ("day_id");
|
|
create index "idx_day_notes_trip_id" on "day_notes" ("trip_id");
|
|
create table "budget_category_order" ("trip_id" bigint not null, "category" text not null, "sort_order" bigint not null default 0, primary key ("trip_id", "category"));
|
|
alter table "budget_category_order" add constraint "budget_category_order_trip_id_category_unique" unique ("trip_id", "category");
|
|
create table "trip_members" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "added_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "invited_by" bigint null);
|
|
create index "idx_trip_members_trip_id" on "trip_members" ("trip_id");
|
|
create index "idx_trip_members_user_id" on "trip_members" ("user_id");
|
|
create index "idx_trip_members_invited_by" on "trip_members" ("invited_by");
|
|
alter table "trip_members" add constraint "trip_members_trip_id_user_id_unique" unique ("trip_id", "user_id");
|
|
create table "trip_member_removals" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "removed_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_trip_member_removals_user" on "trip_member_removals" ("user_id");
|
|
alter table "trip_member_removals" add constraint "trip_member_removals_trip_id_user_id_unique" unique ("trip_id", "user_id");
|
|
create table "trip_invite_tokens" ("id" bigserial primary key, "trip_id" bigint not null, "token" text not null, "expires_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "created_by" bigint null);
|
|
create index "idx_trip_invite_tokens_token" on "trip_invite_tokens" ("token");
|
|
create index "idx_trip_invite_tokens_created_by" on "trip_invite_tokens" ("created_by");
|
|
alter table "trip_invite_tokens" add constraint "trip_invite_tokens_token_unique" unique ("token");
|
|
alter table "trip_invite_tokens" add constraint "trip_invite_tokens_trip_id_unique" unique ("trip_id");
|
|
create table "trip_album_links" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "provider" text not null, "album_id" text not null, "album_name" text not null default '', "sync_enabled" bigint not null default 1, "last_synced_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "passphrase" text null default NULL);
|
|
create index "idx_trip_album_links_trip" on "trip_album_links" ("trip_id");
|
|
create index "idx_trip_album_links_user_id" on "trip_album_links" ("user_id");
|
|
alter table "trip_album_links" add constraint "trip_album_links_trip_id_user_id_provider_album_id_unique" unique ("trip_id", "user_id", "provider", "album_id");
|
|
create table "trek_photos" ("id" bigserial primary key, "provider" text not null, "asset_id" text null, "owner_id" bigint null, "file_path" text null, "thumbnail_path" text null, "width" bigint null, "height" bigint null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "passphrase" text null default NULL, "media_type" text not null default 'image', "duration_ms" bigint null, "taken_at" text null, "lat" double precision null, "lng" double precision null);
|
|
create index "idx_trek_photos_owner" on "trek_photos" ("owner_id");
|
|
create index "idx_trek_photos_geo" on "trek_photos" ("lat", "lng") where lat IS NOT NULL AND lng IS NOT NULL;
|
|
create unique index "idx_trek_photos_provider_asset" on "trek_photos" ("provider", "asset_id", "owner_id") where asset_id IS NOT NULL;
|
|
create table "trip_photos" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "photo_id" bigint not null, "shared" bigint not null default 1, "album_link_id" bigint null, "added_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_trip_photos_trip" on "trip_photos" ("trip_id");
|
|
create index "idx_trip_photos_user_id" on "trip_photos" ("user_id");
|
|
create index "idx_trip_photos_photo" on "trip_photos" ("photo_id");
|
|
create index "idx_trip_photos_album_link_id" on "trip_photos" ("album_link_id");
|
|
alter table "trip_photos" add constraint "trip_photos_trip_id_user_id_photo_id_unique" unique ("trip_id", "user_id", "photo_id");
|
|
create table "trek_photo_signals" ("id" bigserial primary key, "photo_id" bigint not null, "algo" bigint not null, "phash" text null, "sharpness" double precision null, "luma" double precision null, "clipped" double precision null, "orig_width" bigint null, "orig_height" bigint null, "computed_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "palette" text null, "busy" text null, "sal_x" double precision null, "sal_y" double precision null);
|
|
alter table "trek_photo_signals" add constraint "trek_photo_signals_photo_id_unique" unique ("photo_id");
|
|
create table "tour_drafts" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "payload" text not null, "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_tour_drafts_user" on "tour_drafts" ("user_id");
|
|
alter table "tour_drafts" add constraint "tour_drafts_trip_id_user_id_unique" unique ("trip_id", "user_id");
|
|
create table "todo_items" ("id" bigserial primary key, "trip_id" bigint not null, "name" text not null, "checked" bigint null default 0, "category" text null, "sort_order" bigint null default 0, "due_date" text null, "description" text null, "assigned_user_id" bigint null, "priority" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "reminded_at" text null);
|
|
create index "idx_todo_items_trip_id" on "todo_items" ("trip_id");
|
|
create index "idx_todo_items_assigned_user_id" on "todo_items" ("assigned_user_id");
|
|
create table "todo_category_assignees" ("id" bigserial primary key, "trip_id" bigint not null, "category_name" text not null, "user_id" bigint not null);
|
|
create index "idx_todo_category_assignees_user_id" on "todo_category_assignees" ("user_id");
|
|
alter table "todo_category_assignees" add constraint "todo_category_assignees_trip_id_category_name_user_id_unique" unique ("trip_id", "category_name", "user_id");
|
|
create table "tags" ("id" bigserial primary key, "user_id" bigint not null, "name" text not null, "color" text null default '#10b981', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_tags_user_id" on "tags" ("user_id");
|
|
create table "share_tokens" ("id" bigserial primary key, "trip_id" bigint not null, "token" text not null, "share_map" bigint null default 1, "share_bookings" bigint null default 1, "share_packing" bigint null default 0, "share_budget" bigint null default 0, "share_collab" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "expires_at" text null, "share_travel_only" bigint not null default 0, "share_hide_images" bigint not null default 0, "created_by" bigint not null);
|
|
create index "idx_share_tokens_trip_id" on "share_tokens" ("trip_id");
|
|
create index "idx_share_tokens_token" on "share_tokens" ("token");
|
|
create index "idx_share_tokens_created_by" on "share_tokens" ("created_by");
|
|
alter table "share_tokens" add constraint "share_tokens_token_unique" unique ("token");
|
|
create table "settings" ("id" bigserial primary key, "user_id" bigint not null, "key" text not null, "value" text null);
|
|
alter table "settings" add constraint "settings_user_id_key_unique" unique ("user_id", "key");
|
|
create table "push_subscriptions" ("id" bigserial primary key, "user_id" bigint not null, "endpoint" text not null, "p256dh" text not null, "auth" text not null, "vapid_public_key" text not null, "user_agent" text null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_success_at" text null, "failure_count" bigint not null default 0);
|
|
create index "idx_push_subscriptions_user" on "push_subscriptions" ("user_id");
|
|
alter table "push_subscriptions" add constraint "push_subscriptions_endpoint_unique" unique ("endpoint");
|
|
create table "password_reset_tokens" ("id" bigserial primary key, "user_id" bigint not null, "token_hash" text not null, "expires_at" text not null, "consumed_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "created_ip" text null);
|
|
create index "idx_prt_user" on "password_reset_tokens" ("user_id");
|
|
create index "idx_prt_hash" on "password_reset_tokens" ("token_hash");
|
|
alter table "password_reset_tokens" add constraint "password_reset_tokens_token_hash_unique" unique ("token_hash");
|
|
create table "packing_templates" ("id" bigserial primary key, "name" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "created_by" bigint not null);
|
|
create index "idx_packing_templates_created_by" on "packing_templates" ("created_by");
|
|
create table "packing_template_categories" ("id" bigserial primary key, "template_id" bigint not null, "name" text not null, "sort_order" bigint not null default 0);
|
|
create index "idx_packing_template_categories_template_id" on "packing_template_categories" ("template_id");
|
|
create table "packing_template_items" ("id" bigserial primary key, "category_id" bigint not null, "name" text not null, "sort_order" bigint not null default 0, "weight_grams" bigint null, "quantity" bigint not null default 1, "bag_name" text null);
|
|
create index "idx_packing_template_items_category_id" on "packing_template_items" ("category_id");
|
|
create table "packing_category_assignees" ("id" bigserial primary key, "trip_id" bigint not null, "category_name" text not null, "user_id" bigint not null);
|
|
create index "idx_packing_category_assignees_user_id" on "packing_category_assignees" ("user_id");
|
|
alter table "packing_category_assignees" add constraint "packing_category_assignees_trip_id_category_name_user_id_unique" unique ("trip_id", "category_name", "user_id");
|
|
create table "packing_bags" ("id" bigserial primary key, "trip_id" bigint not null, "name" text not null, "color" text not null default '#6366f1', "weight_limit_grams" bigint null, "sort_order" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "user_id" bigint null default NULL);
|
|
create index "idx_packing_bags_trip_id" on "packing_bags" ("trip_id");
|
|
create index "idx_packing_bags_user_id" on "packing_bags" ("user_id");
|
|
create table "packing_items" ("id" bigserial primary key, "trip_id" bigint not null, "name" text not null, "checked" bigint null default 0, "category" text null, "sort_order" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "weight_grams" bigint null, "bag_id" bigint null, "quantity" bigint not null default 1, "updated_at" text null, "is_private" bigint not null default 0, "owner_id" bigint null, "packed_quantity" bigint null);
|
|
create index "idx_packing_items_trip_id" on "packing_items" ("trip_id");
|
|
create index "idx_packing_items_bag_id" on "packing_items" ("bag_id");
|
|
create index "idx_packing_items_owner_id" on "packing_items" ("owner_id");
|
|
create table "packing_item_contributors" ("item_id" bigint not null, "user_id" bigint not null, "status" text not null default 'accepted', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("item_id", "user_id"));
|
|
create index "idx_packing_item_contributors_user_id" on "packing_item_contributors" ("user_id");
|
|
alter table "packing_item_contributors" add constraint "packing_item_contributors_item_id_user_id_unique" unique ("item_id", "user_id");
|
|
create table "packing_item_recipients" ("item_id" bigint not null, "user_id" bigint not null, primary key ("item_id", "user_id"));
|
|
create table "packing_bag_members" ("bag_id" bigint not null, "user_id" bigint not null, primary key ("bag_id", "user_id"));
|
|
create table "oauth_clients" ("id" text null, "user_id" bigint null, "name" text not null, "client_id" text not null, "client_secret_hash" text not null, "redirect_uris" text not null default '[]', "allowed_scopes" text not null default '[]', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "is_public" bigint not null default 0, "created_via" text not null default 'settings_ui', "allows_client_credentials" bigint not null default 0, primary key ("id"));
|
|
create index "idx_oauth_clients_user" on "oauth_clients" ("user_id");
|
|
alter table "oauth_clients" add constraint "idx_oauth_clients_client_id" unique ("client_id");
|
|
alter table "oauth_clients" add constraint "oauth_clients_client_id_unique" unique ("client_id");
|
|
create table "oauth_tokens" ("id" bigserial primary key, "client_id" text not null, "user_id" bigint not null, "access_token_hash" text not null, "refresh_token_hash" text not null, "scopes" text not null default '[]', "access_token_expires_at" text not null, "refresh_token_expires_at" text not null, "revoked_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "parent_token_id" bigint null, "audience" text null);
|
|
create index "idx_oauth_tokens_client_id" on "oauth_tokens" ("client_id");
|
|
create index "idx_oauth_tokens_user" on "oauth_tokens" ("user_id");
|
|
alter table "oauth_tokens" add constraint "idx_oauth_tokens_access" unique ("access_token_hash");
|
|
alter table "oauth_tokens" add constraint "idx_oauth_tokens_refresh" unique ("refresh_token_hash");
|
|
create index "idx_oauth_tokens_parent" on "oauth_tokens" ("parent_token_id");
|
|
alter table "oauth_tokens" add constraint "oauth_tokens_refresh_token_hash_unique" unique ("refresh_token_hash");
|
|
alter table "oauth_tokens" add constraint "oauth_tokens_access_token_hash_unique" unique ("access_token_hash");
|
|
create table "oauth_consents" ("id" bigserial primary key, "client_id" text not null, "user_id" bigint not null, "scopes" text not null default '[]', "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_oauth_consents_user_id" on "oauth_consents" ("user_id");
|
|
alter table "oauth_consents" add constraint "oauth_consents_client_id_user_id_unique" unique ("client_id", "user_id");
|
|
create table "notifications" ("id" bigserial primary key, "type" text not null, "scope" text not null, "target" bigint not null, "sender_id" bigint null, "recipient_id" bigint not null, "title_key" text not null, "title_params" text null default '{}', "text_key" text not null, "text_params" text null default '{}', "positive_text_key" text null, "negative_text_key" text null, "positive_callback" text null, "negative_callback" text null, "response" text null, "navigate_text_key" text null, "navigate_target" text null, "is_read" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_notifications_sender_id" on "notifications" ("sender_id");
|
|
create index "idx_notifications_target_scope" on "notifications" ("target", "scope");
|
|
create index "idx_notifications_recipient_created" on "notifications" ("recipient_id", "created_at");
|
|
create index "idx_notifications_recipient" on "notifications" ("recipient_id", "is_read", "created_at");
|
|
create table "notification_channel_preferences" ("user_id" bigint not null, "event_type" text not null, "channel" text not null, "enabled" bigint not null default 1, primary key ("user_id", "event_type", "channel"));
|
|
create index "idx_ncp_user" on "notification_channel_preferences" ("user_id");
|
|
alter table "notification_channel_preferences" add constraint "notification_channel_preferences_user_id_event_ty_8d673_unique" unique ("user_id", "event_type", "channel");
|
|
create table "mcp_tokens" ("id" bigserial primary key, "user_id" bigint not null, "name" text not null, "token_hash" text not null, "token_prefix" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_used_at" text null, "kind" text not null default 'mcp', "scope_mode" text not null default 'all', "api_scopes" text null);
|
|
create index "idx_mcp_tokens_user_id" on "mcp_tokens" ("user_id");
|
|
alter table "mcp_tokens" add constraint "idx_mcp_tokens_hash" unique ("token_hash");
|
|
create table "journeys" ("id" bigserial primary key, "user_id" bigint not null, "title" text not null, "subtitle" text null, "cover_gradient" text null, "status" text null default 'draft', "created_at" bigint not null, "updated_at" bigint not null, "cover_image" text null, "show_trip_tracks" bigint not null default 0, "show_verdict" bigint not null default 1, "show_mood" bigint not null default 1, "show_weather" bigint not null default 1, "status_override" text null, "photo_location" bigint not null default 0, "auto_prepare_recordings" bigint not null default 0);
|
|
create index "idx_journeys_user" on "journeys" ("user_id");
|
|
create table "trip_journal_links" ("id" bigserial primary key, "trip_id" bigint not null, "journey_id" bigint not null, "created_at" bigint not null, "linked_by" bigint null);
|
|
create index "idx_trip_journal_links_journey" on "trip_journal_links" ("journey_id");
|
|
create index "idx_trip_journal_links_linked_by" on "trip_journal_links" ("linked_by");
|
|
alter table "trip_journal_links" add constraint "trip_journal_links_trip_id_unique" unique ("trip_id");
|
|
create table "trip_journal_link_members" ("link_id" bigint not null, "user_id" bigint not null, "role" text not null default 'viewer', "hide_skeletons" bigint not null default 0, "added_at" bigint not null, primary key ("link_id", "user_id"));
|
|
create index "idx_trip_journal_link_members_user" on "trip_journal_link_members" ("user_id");
|
|
alter table "trip_journal_link_members" add constraint "trip_journal_link_members_link_id_user_id_unique" unique ("link_id", "user_id");
|
|
alter table "trip_journal_link_members" add constraint "trip_journal_link_members_role_check" check ("role" in ('viewer', 'editor'));
|
|
create table "journey_trips" ("journey_id" bigint not null, "trip_id" bigint not null, "added_at" bigint not null, primary key ("journey_id", "trip_id"));
|
|
create index "idx_journey_trips_journey" on "journey_trips" ("journey_id");
|
|
create index "idx_journey_trips_trip_id" on "journey_trips" ("trip_id");
|
|
alter table "journey_trips" add constraint "journey_trips_journey_id_trip_id_unique" unique ("journey_id", "trip_id");
|
|
create table "journey_share_tokens" ("id" bigserial primary key, "journey_id" bigint not null, "token" text not null, "share_timeline" bigint null default 1, "share_gallery" bigint null default 1, "share_map" bigint null default 1, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "newest_first" bigint not null default 0, "share_plan" bigint not null default 0, "share_recordings" bigint not null default 0, "created_by" bigint not null);
|
|
alter table "journey_share_tokens" add constraint "idx_journey_share_journey" unique ("journey_id");
|
|
create index "idx_journey_share_tokens_created_by" on "journey_share_tokens" ("created_by");
|
|
alter table "journey_share_tokens" add constraint "journey_share_tokens_token_unique" unique ("token");
|
|
create table "journey_photos" ("id" bigserial primary key, "journey_id" bigint not null, "photo_id" bigint not null, "caption" text null, "shared" bigint null default 0, "sort_order" bigint null default 0, "provider" text null, "asset_id" text null, "owner_id" bigint null, "created_at" bigint not null);
|
|
create index "idx_journey_photos_journey" on "journey_photos" ("journey_id");
|
|
create index "idx_journey_photos_photo_id" on "journey_photos" ("photo_id");
|
|
alter table "journey_photos" add constraint "journey_photos_journey_id_photo_id_unique" unique ("journey_id", "photo_id");
|
|
create table "journey_book_revisions" ("id" bigserial primary key, "journey_id" bigint not null, "version" bigint not null, "document" text not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_journey_book_revisions_journey" on "journey_book_revisions" ("journey_id");
|
|
create table "journey_recording_prep" ("id" bigserial primary key, "journey_id" bigint not null, "user_id" bigint not null, "last_attempt_at" text null, "last_success_at" text null, "last_error" text null);
|
|
create index "idx_journey_recording_prep_user" on "journey_recording_prep" ("user_id");
|
|
alter table "journey_recording_prep" add constraint "idx_journey_recording_prep_person" unique ("journey_id", "user_id");
|
|
create table "journey_recorded_days" ("id" bigserial primary key, "journey_id" bigint not null, "local_date" text not null, "source" text not null default 'dawarich', "source_kind" text not null, "utc_offset_minutes" bigint not null, "window_from" text not null, "window_to" text not null, "segments" text not null, "point_count" bigint not null, "distance_m" double precision null, "content_hash" text not null, "truncated" bigint not null default 0, "fetched_at" text not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "imported_by" bigint null);
|
|
create index "idx_journey_recorded_days_imported_by" on "journey_recorded_days" ("imported_by");
|
|
alter table "journey_recorded_days" add constraint "idx_journey_recorded_days_day" unique ("journey_id", "local_date", "source");
|
|
create table "journey_contributors" ("journey_id" bigint not null, "user_id" bigint not null, "role" text not null, "added_at" bigint not null, "hide_skeletons" bigint not null default 0, primary key ("journey_id", "user_id"));
|
|
create index "idx_journey_contributors_user" on "journey_contributors" ("user_id");
|
|
alter table "journey_contributors" add constraint "journey_contributors_journey_id_user_id_unique" unique ("journey_id", "user_id");
|
|
create table "journey_books" ("id" bigserial primary key, "journey_id" bigint not null, "title" text not null default '', "document" text not null, "version" bigint not null default 1, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_by" bigint null, "created_by" bigint null);
|
|
create index "idx_journey_books_journey" on "journey_books" ("journey_id");
|
|
create index "idx_journey_books_updated_by" on "journey_books" ("updated_by");
|
|
create index "idx_journey_books_created_by" on "journey_books" ("created_by");
|
|
create table "invite_tokens" ("id" bigserial primary key, "token" text not null, "max_uses" bigint not null default 1, "used_count" bigint not null default 0, "expires_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "trip_id" bigint null, "created_by" bigint not null);
|
|
create index "idx_invite_tokens_trip_id" on "invite_tokens" ("trip_id");
|
|
create index "idx_invite_tokens_created_by" on "invite_tokens" ("created_by");
|
|
alter table "invite_tokens" add constraint "invite_tokens_token_unique" unique ("token");
|
|
create table "idempotency_keys" ("key" text not null, "user_id" bigint not null, "method" text not null, "path" text not null, "status_code" bigint not null, "response_body" text not null, "created_at" bigint not null default CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) AS bigint), primary key ("key", "user_id", "method", "path"));
|
|
create index "idx_idempotency_keys_user_id" on "idempotency_keys" ("user_id");
|
|
create index "idx_idempotency_keys_created" on "idempotency_keys" ("created_at");
|
|
alter table "idempotency_keys" add constraint "idempotency_keys_key_user_id_method_path_unique" unique ("key", "user_id", "method", "path");
|
|
create table "hidden_regions" ("id" bigserial primary key, "user_id" bigint not null, "region_code" text not null, "country_code" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_hidden_regions_user" on "hidden_regions" ("user_id");
|
|
alter table "hidden_regions" add constraint "hidden_regions_user_id_region_code_unique" unique ("user_id", "region_code");
|
|
create table "hidden_countries" ("id" bigserial primary key, "user_id" bigint not null, "country_code" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_hidden_countries_user" on "hidden_countries" ("user_id");
|
|
alter table "hidden_countries" add constraint "hidden_countries_user_id_country_code_unique" unique ("user_id", "country_code");
|
|
create table "document_connections" ("id" bigserial primary key, "trip_id" bigint not null, "provider_id" text not null, "owner_user_id" bigint not null, "base_url" text not null, "secrets" text null, "settings" text not null default '{}', "allow_insecure_tls" bigint not null default 0, "capabilities" text null, "last_probe_at" text null, "last_probe_state" text not null default 'never', "last_probe_error" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_document_connections_trip" on "document_connections" ("trip_id");
|
|
create index "idx_document_connections_provider_id" on "document_connections" ("provider_id");
|
|
create index "idx_document_connections_owner" on "document_connections" ("owner_user_id");
|
|
alter table "document_connections" add constraint "document_connections_trip_id_provider_id_unique" unique ("trip_id", "provider_id");
|
|
create table "trip_document_links" ("id" bigserial primary key, "trip_id" bigint not null, "connection_id" bigint not null, "provider_id" text not null, "remote_scope_key" text not null, "remote_root_id" text null, "remote_root_path" text null, "remote_label" text not null default '', "direction" text not null default 'both', "delete_policy" text not null default 'unlink', "conflict_policy" text not null default 'manual', "sync_enabled" bigint not null default 1, "webhook_token" text null, "webhook_secret" text null, "webhook_subscription_id" text null, "remote_cursor" text null, "last_sync_at" text null, "last_sync_state" text not null default 'never', "last_sync_error" text null, "failure_count" bigint not null default 0, "next_attempt_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "created_by" bigint null);
|
|
create index "idx_trip_document_links_trip" on "trip_document_links" ("trip_id");
|
|
create index "idx_trip_document_links_connection_id" on "trip_document_links" ("connection_id");
|
|
create index "idx_trip_document_links_created_by" on "trip_document_links" ("created_by");
|
|
create index "idx_trip_document_links_due" on "trip_document_links" ("sync_enabled", "next_attempt_at");
|
|
create unique index "idx_trip_document_links_token" on "trip_document_links" ("webhook_token") where webhook_token IS NOT NULL;
|
|
alter table "trip_document_links" add constraint "trip_document_links_trip_id_connection_id_remote__1c36d_unique" unique ("trip_id", "connection_id", "remote_scope_key");
|
|
create table "dawarich_connections" ("user_id" bigint null, "url" text null, "api_key" text null, "allow_insecure_tls" bigint not null default 0, "sync_enabled" bigint not null default 1, "last_sync_at" text null, "last_sync_state" text not null default 'never', "last_sync_error" text null, "capabilities" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("user_id"));
|
|
create table "collections" ("id" bigserial primary key, "owner_id" bigint not null, "name" text not null, "description" text null, "color" text null default '#6366f1', "icon" text null default 'Bookmark', "cover_image" text null, "links" text null, "sort_order" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collections_owner_id" on "collections" ("owner_id");
|
|
create table "collection_tours" ("id" bigserial primary key, "collection_id" bigint not null, "name" text not null, "description" text null, "website" text null, "route_geometry" text null, "waypoints" text not null, "distance" double precision null, "elevation_gain" double precision null, "elevation_loss" double precision null, "duration" double precision null, "planned_duration_minutes" bigint null, "break_additional_minutes" bigint null, "difficulty" text null, "wanderer_ref" text null, "match_confidence" double precision null, "max_hiking_difficulty" bigint null, "bike_profile" text null, "run_profile" text null, "run_pace_seconds_per_km" bigint null, "ski_discipline" text null, "ski_technique" text null, "boat_type" text null, "water_context" text null, "paddle_speed_kmh" double precision null, "portage_speed_kmh" double precision null, "paddle_lake_style" text null, "track_marks" text null, "hiking_preferences" text null, "origin" text not null, "origin_file_name" text null, "track_started_at" text null, "track_ended_at" text null, "source_trip_title" text not null, "source_tour_name" text not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "ski_options" text null, "tour_type" text not null, "saved_by" bigint null);
|
|
create index "idx_collection_tours_collection" on "collection_tours" ("collection_id");
|
|
create index "idx_collection_tours_tour_type" on "collection_tours" ("tour_type");
|
|
create index "idx_collection_tours_saved_by" on "collection_tours" ("saved_by");
|
|
create table "collection_labels" ("id" bigserial primary key, "collection_id" bigint not null, "name" text not null, "color" text null default '#6366f1', "sort_order" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collection_labels_collection" on "collection_labels" ("collection_id");
|
|
create table "collection_members" ("id" bigserial primary key, "collection_id" bigint not null, "user_id" bigint not null, "status" text not null default 'pending', "role" text not null default 'editor', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collection_members_user" on "collection_members" ("user_id");
|
|
alter table "collection_members" add constraint "collection_members_collection_id_user_id_unique" unique ("collection_id", "user_id");
|
|
create table "collab_polls" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "question" text not null, "options" text not null, "multiple" bigint null default 0, "closed" bigint null default 0, "deadline" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collab_polls_trip" on "collab_polls" ("trip_id");
|
|
create index "idx_collab_polls_user_id" on "collab_polls" ("user_id");
|
|
create table "collab_poll_votes" ("id" bigserial primary key, "poll_id" bigint not null, "user_id" bigint not null, "option_index" bigint not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collab_poll_votes_user_id" on "collab_poll_votes" ("user_id");
|
|
alter table "collab_poll_votes" add constraint "collab_poll_votes_poll_id_user_id_option_index_unique" unique ("poll_id", "user_id", "option_index");
|
|
create table "collab_notes" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "category" text null default 'General', "title" text not null, "content" text null, "color" text null default '#6366f1', "pinned" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "website" text null);
|
|
create index "idx_collab_notes_trip" on "collab_notes" ("trip_id");
|
|
create index "idx_collab_notes_user_id" on "collab_notes" ("user_id");
|
|
create table "collab_messages" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "text" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "deleted" bigint null default 0, "origin" text null, "reply_to" bigint null);
|
|
create index "idx_collab_messages_trip" on "collab_messages" ("trip_id");
|
|
create index "idx_collab_messages_user_id" on "collab_messages" ("user_id");
|
|
create index "idx_collab_messages_reply_to" on "collab_messages" ("reply_to");
|
|
create table "collab_message_reactions" ("id" bigserial primary key, "message_id" bigint not null, "user_id" bigint not null, "emoji" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collab_reactions_msg" on "collab_message_reactions" ("message_id");
|
|
create index "idx_collab_message_reactions_user_id" on "collab_message_reactions" ("user_id");
|
|
alter table "collab_message_reactions" add constraint "collab_message_reactions_message_id_user_id_emoji_unique" unique ("message_id", "user_id", "emoji");
|
|
create table "collab_links" ("id" bigserial primary key, "trip_id" bigint not null, "user_id" bigint not null, "title" text not null, "url" text not null, "pinned" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collab_links_trip" on "collab_links" ("trip_id");
|
|
create index "idx_collab_links_user_id" on "collab_links" ("user_id");
|
|
create table "categories" ("id" bigserial primary key, "name" text not null, "color" text null default '#6366f1', "icon" text null default '📍', "user_id" bigint null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_categories_user_id" on "categories" ("user_id");
|
|
create table "places" ("id" bigserial primary key, "trip_id" bigint not null, "name" text not null, "description" text null, "lat" double precision null, "lng" double precision null, "address" text null, "category_id" bigint null, "price" double precision null, "currency" text null, "reservation_status" text null default 'none', "reservation_notes" text null, "reservation_datetime" text null, "place_time" text null, "end_time" text null, "duration_minutes" bigint null default 60, "notes" text null, "image_url" text null, "google_place_id" text null, "google_ftid" text null, "website" text null, "phone" text null, "transport_mode" text null default 'walking', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "osm_id" text null, "route_geometry" text null, "route_color" text null, "stop_type" text null, "fill_percent" bigint null, "amap_poi_id" text null, "source" text null, "email" text null, "opening_hours" text null);
|
|
create index "idx_places_trip_id" on "places" ("trip_id");
|
|
create index "idx_places_category_id" on "places" ("category_id");
|
|
create table "tours" ("place_id" bigint null, "distance" double precision null, "elevation_gain" double precision null, "elevation_loss" double precision null, "duration" double precision null, "difficulty" text null, "wanderer_ref" text null, "match_confidence" double precision null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "max_hiking_difficulty" bigint null default 2, "planned_duration_minutes" bigint null, "break_additional_minutes" bigint null, "derived_from_place_id" bigint null, "recorded_route_geometry" text null, "origin" text not null default 'trek', "origin_file_name" text null, "boat_type" text null, "water_context" text null, "paddle_speed_kmh" double precision null, "portage_speed_kmh" double precision null, "track_marks" text null, "paddle_lake_style" text null, "revision" bigint not null default 1, "hiking_preferences" text null, "taken_over_from_trip_title" text null, "taken_over_from_tour_name" text null, "bike_profile" text null, "run_profile" text null, "run_pace_seconds_per_km" bigint null, "ski_technique" text null, "track_started_at" text null, "track_ended_at" text null, "ski_discipline" text null, "ski_options" text null, "tour_type" text not null, primary key ("place_id"));
|
|
create index "idx_tours_tour_type" on "tours" ("tour_type");
|
|
create index "idx_tours_derived_from_place_id" on "tours" ("derived_from_place_id") where derived_from_place_id IS NOT NULL;
|
|
alter table "tours" add constraint "tours_run_pace_seconds_per_km_check" check (run_pace_seconds_per_km IS NULL OR (run_pace_seconds_per_km >= 120 AND run_pace_seconds_per_km <= 1200));
|
|
alter table "tours" add constraint "tours_revision_check" check (revision >= 1);
|
|
alter table "tours" add constraint "tours_origin_check" check ("origin" in ('trek', 'gpx', 'wanderer'));
|
|
alter table "tours" add constraint "tours_boat_type_check" check ("boat_type" in ('kayak', 'canoe', 'sup', 'other'));
|
|
alter table "tours" add constraint "tours_water_context_check" check ("water_context" in ('river', 'lake'));
|
|
alter table "tours" add constraint "tours_paddle_lake_style_check" check ("paddle_lake_style" in ('direct', 'shore'));
|
|
alter table "tours" add constraint "tours_bike_profile_check" check ("bike_profile" in ('touring', 'road', 'gravel', 'mtb'));
|
|
alter table "tours" add constraint "tours_run_profile_check" check ("run_profile" in ('running', 'trail'));
|
|
alter table "tours" add constraint "tours_ski_technique_check" check ("ski_technique" in ('classic', 'skating', 'unknown'));
|
|
alter table "tours" add constraint "tours_ski_discipline_check" check ("ski_discipline" in ('alpine', 'snowboard', 'cross_country', 'touring', 'snowshoe', 'winter_hike'));
|
|
create table "tour_waypoints" ("id" bigserial primary key, "place_id" bigint not null, "lat" double precision not null, "lng" double precision not null, "role" text not null, "sequence" bigint not null, "fixed_leg" text null, "lock" text null, "shaping" bigint not null default 0, "linked_place_id" bigint null, "station_key" text null, "name" text null, "stay_minutes" bigint null, "importance" text null, "protected" bigint not null default 0, "opening_hours" text null, "poi_category" text null, "stage_end" bigint not null default 0);
|
|
create index "idx_tour_waypoints_linked_place" on "tour_waypoints" ("linked_place_id") where linked_place_id IS NOT NULL;
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_place_id_sequence_unique" unique ("place_id", "sequence");
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_stage_end_check" check (stage_end IN (0, 1));
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_protected_check" check (protected IN (0, 1));
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_stay_minutes_check" check (stay_minutes IS NULL OR (stay_minutes >= 0 AND stay_minutes <= 1440));
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_shaping_check" check (shaping IN (0, 1));
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_importance_check" check ("importance" in ('optional', 'must'));
|
|
create table "tour_sources" ("place_id" bigint null, "provider" text not null, "instance" text not null, "external_id" text not null, "external_url" text null, "external_updated" text null, "content_hash" text not null, "local_hash" text not null, "imported_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "imported_by" bigint null, primary key ("place_id"));
|
|
create index "idx_tour_sources_imported_by" on "tour_sources" ("imported_by");
|
|
create index "idx_tour_sources_external" on "tour_sources" ("provider", "instance", "external_id");
|
|
create table "tour_source_hints" ("place_id" bigint null, "user_id" bigint not null, "state" text null, "changes" text null, "reason" text null, "external_updated" text null, "seen_hash" text null, "seen_updated" text null, "checked_at" text null, primary key ("place_id"));
|
|
create index "idx_tour_source_hints_user_id" on "tour_source_hints" ("user_id");
|
|
alter table "tour_source_hints" add constraint "tour_source_hints_state_check" check ("state" in ('possible_change', 'changed', 'unverifiable'));
|
|
alter table "tour_source_hints" add constraint "tour_source_hints_reason_check" check ("reason" in ('unavailable', 'no_change_time'));
|
|
create table "tour_packing_links" ("place_id" bigint null, "category" text null, "linked_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "linked_by" bigint null, primary key ("place_id"));
|
|
create index "idx_tour_packing_links_linked_by" on "tour_packing_links" ("linked_by");
|
|
create table "tour_obstacle_reviews" ("place_id" bigint not null, "obstacle_key" text not null, "decision" text not null, "note" text null, "route_fingerprint" text not null, "source_fingerprint" text not null, "obstacle_snapshot" text not null, "decided_at" text not null, "decided_by" bigint null, primary key ("place_id", "obstacle_key"));
|
|
alter table "tour_obstacle_reviews" add constraint "tour_obstacle_reviews_place_id_obstacle_key_unique" unique ("place_id", "obstacle_key");
|
|
alter table "tour_obstacle_reviews" add constraint "tour_obstacle_reviews_decision_check" check ("decision" in ('pass', 'portage', 'reroute', 'not_affected'));
|
|
create table "tour_change_steps" ("id" bigserial primary key, "place_id" bigint not null, "proposal_id" text not null, "base_revision" bigint not null, "revision" bigint not null, "changes" text not null, "before_state" text not null, "saved_by" bigint null, "saved_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "undone_revision" bigint null, "undone_by" bigint null, "undone_at" text null);
|
|
alter table "tour_change_steps" add constraint "tour_change_steps_place_id_revision_unique" unique ("place_id", "revision");
|
|
alter table "tour_change_steps" add constraint "tour_change_steps_undone_revision_check" check (undone_revision IS NULL OR undone_revision > revision);
|
|
alter table "tour_change_steps" add constraint "tour_change_steps_revision_check" check (revision = base_revision + 1);
|
|
alter table "tour_change_steps" add constraint "tour_change_steps_base_revision_check" check (base_revision >= 1);
|
|
create table "tour_activity_exclusions" ("id" bigserial primary key, "user_id" bigint not null, "place_id" bigint not null, "excluded_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_tour_activity_exclusions_place" on "tour_activity_exclusions" ("place_id");
|
|
alter table "tour_activity_exclusions" add constraint "tour_activity_exclusions_user_id_place_id_unique" unique ("user_id", "place_id");
|
|
create table "roadtrip_day_tracks" ("day_id" bigint null, "place_id" bigint not null, "stray_km" double precision null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("day_id"));
|
|
create index "idx_roadtrip_day_tracks_place" on "roadtrip_day_tracks" ("place_id");
|
|
create table "place_regions" ("place_id" bigint null, "country_code" text not null, "region_code" text not null, "region_name" text not null, primary key ("place_id"));
|
|
create index "idx_place_regions_country" on "place_regions" ("country_code");
|
|
create index "idx_place_regions_region" on "place_regions" ("region_code");
|
|
create table "place_ratings" ("id" bigserial primary key, "place_id" bigint not null, "user_id" bigint not null, "rating" bigint not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_place_ratings_place" on "place_ratings" ("place_id");
|
|
create index "idx_place_ratings_user_id" on "place_ratings" ("user_id");
|
|
alter table "place_ratings" add constraint "place_ratings_place_id_user_id_unique" unique ("place_id", "user_id");
|
|
create table "place_field_origin" ("place_id" bigint not null, "field" text not null, "origin" text not null, "value_hash" text not null, "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("place_id", "field"));
|
|
alter table "place_field_origin" add constraint "place_field_origin_place_id_field_unique" unique ("place_id", "field");
|
|
create table "place_contrib_outbox" ("id" bigserial primary key, "contrib_key" text not null, "field" text not null, "value" text not null, "place_id" bigint not null, "place_name" text not null, "lat" double precision null, "lng" double precision null, "country" text null, "cid" text not null, "attempts" bigint not null default 0, "eligible_at" text not null, "next_attempt_at" text not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_place_contrib_outbox_place" on "place_contrib_outbox" ("place_id");
|
|
create index "idx_place_contrib_outbox_due" on "place_contrib_outbox" ("next_attempt_at");
|
|
alter table "place_contrib_outbox" add constraint "place_contrib_outbox_contrib_key_field_unique" unique ("contrib_key", "field");
|
|
create table "place_tags" ("place_id" bigint not null, "tag_id" bigint not null, primary key ("place_id", "tag_id"));
|
|
create table "photos" ("id" bigserial primary key, "trip_id" bigint not null, "day_id" bigint null, "place_id" bigint null, "filename" text not null, "original_name" text not null, "file_size" bigint null, "mime_type" text null, "caption" text null, "taken_at" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_photos_trip_id" on "photos" ("trip_id");
|
|
create index "idx_photos_day_id" on "photos" ("day_id");
|
|
create index "idx_photos_place_id" on "photos" ("place_id");
|
|
create table "journey_entries" ("id" bigserial primary key, "journey_id" bigint not null, "source_trip_id" bigint null, "source_place_id" bigint null, "author_id" bigint not null, "type" text not null, "title" text null, "story" text null, "entry_date" text not null, "entry_time" text null, "location_name" text null, "location_lat" double precision null, "location_lng" double precision null, "mood" text null, "weather" text null, "tags" text null, "visibility" text null default 'private', "sort_order" bigint null default 0, "created_at" bigint not null, "updated_at" bigint not null, "pros_cons" text null, "stats_excluded" bigint not null default 0, "dismissed" bigint not null default 0, "country_code" text null, "source_assignment_id" bigint null, "is_draft" bigint not null default 0);
|
|
create index "idx_journey_entries_source_trip_id" on "journey_entries" ("source_trip_id");
|
|
create index "idx_journey_entries_source" on "journey_entries" ("source_place_id");
|
|
create index "idx_journey_entries_author_id" on "journey_entries" ("author_id");
|
|
create index "idx_journey_entries_source_assignment" on "journey_entries" ("source_place_id", "source_assignment_id");
|
|
create index "idx_journey_entries_order" on "journey_entries" ("journey_id", "entry_date", "sort_order");
|
|
create index "idx_journey_entries_journey" on "journey_entries" ("journey_id", "entry_date");
|
|
create table "journey_entry_stays" ("id" bigserial primary key, "journey_id" bigint not null, "entry_id" bigint not null, "source" text not null default 'dawarich', "source_visit_id" text not null, "name" text not null, "lat" double precision null, "lng" double precision null, "started_at" text not null, "ended_at" text not null, "duration_minutes" bigint not null default 0, "sort_order" bigint not null default 0, "user_id" bigint null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_journey_entry_stays_entry" on "journey_entry_stays" ("entry_id");
|
|
create index "idx_journey_entry_stays_user" on "journey_entry_stays" ("user_id");
|
|
alter table "journey_entry_stays" add constraint "idx_journey_entry_stays_stay" unique ("journey_id", "source", "user_id", "source_visit_id");
|
|
create table "journey_entry_photos" ("entry_id" bigint not null, "journey_photo_id" bigint not null, "sort_order" bigint null default 0, "created_at" bigint not null, primary key ("entry_id", "journey_photo_id"));
|
|
create index "idx_journey_entry_photos_entry" on "journey_entry_photos" ("entry_id");
|
|
create index "idx_journey_entry_photos_photo" on "journey_entry_photos" ("journey_photo_id");
|
|
alter table "journey_entry_photos" add constraint "journey_entry_photos_entry_id_journey_photo_id_unique" unique ("entry_id", "journey_photo_id");
|
|
create table "day_assignments" ("id" bigserial primary key, "day_id" bigint not null, "place_id" bigint not null, "order_index" bigint null default 0, "notes" text null, "reservation_status" text null default 'none', "reservation_notes" text null, "reservation_datetime" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "assignment_time" text null, "assignment_end_time" text null, "leg_transport_mode" text null, "incoming_leg_transport_mode" text null, "end_day" bigint not null default 0, "accommodation_id" bigint null, "route_excluded" bigint not null default 0, "tour_stage_key" text null);
|
|
create index "idx_day_assignments_day_id" on "day_assignments" ("day_id");
|
|
create index "idx_day_assignments_place_id" on "day_assignments" ("place_id");
|
|
create index "idx_day_assignments_accommodation_id" on "day_assignments" ("accommodation_id");
|
|
create index "idx_day_assignments_tour_stage" on "day_assignments" ("place_id", "tour_stage_key") where tour_stage_key IS NOT NULL;
|
|
create table "tour_station_visits" ("assignment_id" bigint not null, "station_key" text not null, "status" text not null, "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("assignment_id", "station_key"));
|
|
alter table "tour_station_visits" add constraint "tour_station_visits_assignment_id_station_key_unique" unique ("assignment_id", "station_key");
|
|
alter table "tour_station_visits" add constraint "tour_station_visits_status_check" check ("status" in ('visited', 'skipped'));
|
|
create table "tour_activities" ("id" bigserial primary key, "place_id" bigint not null, "track_place_id" bigint not null, "assignment_id" bigint null, "assigned_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "assigned_by" bigint null);
|
|
create index "idx_tour_activities_place" on "tour_activities" ("place_id");
|
|
create index "idx_tour_activities_assigned_by" on "tour_activities" ("assigned_by");
|
|
create unique index "idx_tour_activities_assignment" on "tour_activities" ("assignment_id") where assignment_id IS NOT NULL;
|
|
alter table "tour_activities" add constraint "tour_activities_track_place_id_unique" unique ("track_place_id");
|
|
create table "roadtrip_day_boundaries" ("trip_id" bigint not null, "day_number" bigint not null, "from_assignment_id" bigint not null, "to_assignment_id" bigint null, "fraction" double precision not null, primary key ("trip_id", "day_number"));
|
|
create index "idx_roadtrip_day_boundaries_from_assignment_id" on "roadtrip_day_boundaries" ("from_assignment_id");
|
|
create index "idx_roadtrip_day_boundaries_to_assignment_id" on "roadtrip_day_boundaries" ("to_assignment_id");
|
|
alter table "roadtrip_day_boundaries" add constraint "roadtrip_day_boundaries_trip_id_day_number_unique" unique ("trip_id", "day_number");
|
|
alter table "roadtrip_day_boundaries" add constraint "roadtrip_day_boundaries_fraction_check" check (fraction BETWEEN 0 AND 1);
|
|
alter table "roadtrip_day_boundaries" add constraint "roadtrip_day_boundaries_day_number_check" check (day_number >= 1);
|
|
create table "reservations" ("id" bigserial primary key, "trip_id" bigint not null, "day_id" bigint null, "end_day_id" bigint null, "place_id" bigint null, "assignment_id" bigint null, "title" text not null, "accommodation_id" text null, "reservation_time" text null, "reservation_end_time" text null, "location" text null, "confirmation_number" text null, "notes" text null, "status" text null default 'pending', "type" text null default 'other', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "metadata" text null, "day_plan_position" double precision null default NULL, "needs_review" bigint not null default 0, "external_source" text null, "external_id" text null, "external_owner_user_id" bigint null, "external_synced_at" text null, "sync_enabled" bigint null default 1, "external_hash" text null, "url" text null, "ingest_state" text not null default 'live');
|
|
create index "idx_reservations_trip_id" on "reservations" ("trip_id");
|
|
create index "idx_reservations_day_id" on "reservations" ("day_id");
|
|
create index "idx_reservations_end_day_id" on "reservations" ("end_day_id");
|
|
create index "idx_reservations_place_id" on "reservations" ("place_id");
|
|
create index "idx_reservations_assignment_id" on "reservations" ("assignment_id");
|
|
alter table "reservations" add constraint "idx_reservations_external" unique ("external_source", "external_id", "trip_id");
|
|
create table "trip_files" ("id" bigserial primary key, "trip_id" bigint not null, "place_id" bigint null, "reservation_id" bigint null, "filename" text not null, "original_name" text not null, "file_size" bigint null, "mime_type" text null, "description" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "note_id" bigint null, "starred" bigint null default 0, "deleted_at" text null, "message_id" bigint null, "uploaded_by" bigint null);
|
|
create index "idx_trip_files_trip_id" on "trip_files" ("trip_id");
|
|
create index "idx_trip_files_place_id" on "trip_files" ("place_id");
|
|
create index "idx_trip_files_reservation_id" on "trip_files" ("reservation_id");
|
|
create index "idx_trip_files_note_id" on "trip_files" ("note_id");
|
|
create index "idx_trip_files_message_id" on "trip_files" ("message_id");
|
|
create index "idx_trip_files_uploaded_by" on "trip_files" ("uploaded_by");
|
|
create table "document_sync_items" ("id" bigserial primary key, "link_id" bigint not null, "trip_id" bigint not null, "file_id" bigint null, "trek_doc_uid" text not null, "remote_id" text null, "remote_name" text null, "remote_version" text null, "remote_size" bigint null, "remote_modified_at" text null, "content_sha256" text null, "pushed_sha256" text null, "state" text not null default 'pending', "error_code" text null, "attempts" bigint not null default 0, "next_attempt_at" text null, "remote_missing_at" text null, "first_seen_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_seen_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "synced_at" text null, "remote_trashed_at" text null);
|
|
create index "idx_document_sync_items_file_id" on "document_sync_items" ("file_id");
|
|
create index "idx_document_sync_items_due" on "document_sync_items" ("link_id", "next_attempt_at");
|
|
create index "idx_document_sync_items_hash" on "document_sync_items" ("link_id", "content_sha256");
|
|
create index "idx_document_sync_items_trip_state" on "document_sync_items" ("trip_id", "state");
|
|
alter table "document_sync_items" add constraint "idx_document_sync_items_uid" unique ("link_id", "trek_doc_uid");
|
|
create unique index "idx_document_sync_items_file" on "document_sync_items" ("link_id", "file_id") where file_id IS NOT NULL;
|
|
create unique index "idx_document_sync_items_remote" on "document_sync_items" ("link_id", "remote_id") where remote_id IS NOT NULL;
|
|
create table "reservation_travelers" ("id" bigserial primary key, "reservation_id" bigint not null, "user_id" bigint not null);
|
|
create index "idx_reservation_travelers_res" on "reservation_travelers" ("reservation_id");
|
|
create index "idx_reservation_travelers_user" on "reservation_travelers" ("user_id");
|
|
alter table "reservation_travelers" add constraint "reservation_travelers_reservation_id_user_id_unique" unique ("reservation_id", "user_id");
|
|
create table "reservation_endpoints" ("id" bigserial primary key, "reservation_id" bigint not null, "role" text not null, "sequence" bigint not null default 0, "name" text not null, "code" text null, "lat" double precision not null, "lng" double precision not null, "timezone" text null, "local_time" text null, "local_date" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_reservation_endpoints_reservation_id" on "reservation_endpoints" ("reservation_id");
|
|
create table "reservation_day_positions" ("reservation_id" bigint not null, "day_id" bigint not null, "position" double precision not null, primary key ("reservation_id", "day_id"));
|
|
create index "idx_reservation_day_positions_day_id" on "reservation_day_positions" ("day_id");
|
|
alter table "reservation_day_positions" add constraint "reservation_day_positions_reservation_id_day_id_unique" unique ("reservation_id", "day_id");
|
|
create table "day_accommodations" ("id" bigserial primary key, "trip_id" bigint not null, "place_id" bigint null, "start_day_id" bigint not null, "end_day_id" bigint not null, "check_in" text null, "check_in_end" text null, "check_out" text null, "confirmation" text null, "notes" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_day_accommodations_trip_id" on "day_accommodations" ("trip_id");
|
|
create index "idx_day_accommodations_place_id" on "day_accommodations" ("place_id");
|
|
create index "idx_day_accommodations_start_day_id" on "day_accommodations" ("start_day_id");
|
|
create index "idx_day_accommodations_end_day_id" on "day_accommodations" ("end_day_id");
|
|
create table "collection_places" ("id" bigserial primary key, "collection_id" bigint not null, "owner_id" bigint not null, "name" text not null, "description" text null, "lat" double precision null, "lng" double precision null, "address" text null, "category_id" bigint null, "price" double precision null, "currency" text null, "notes" text null, "image_url" text null, "google_place_id" text null, "google_ftid" text null, "osm_id" text null, "website" text null, "phone" text null, "status" text not null default 'idea', "source_trip_id" bigint null, "source_place_id" bigint null, "links" text null, "sort_order" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "saved_by" bigint null);
|
|
create index "idx_collection_places_collection" on "collection_places" ("collection_id");
|
|
create index "idx_collection_places_owner_id" on "collection_places" ("owner_id");
|
|
create index "idx_collection_places_category_id" on "collection_places" ("category_id");
|
|
create index "idx_collection_places_saved_by" on "collection_places" ("saved_by");
|
|
create table "collection_place_ratings" ("id" bigserial primary key, "collection_place_id" bigint not null, "user_id" bigint not null, "rating" bigint not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_collection_place_ratings_place" on "collection_place_ratings" ("collection_place_id");
|
|
create index "idx_collection_place_ratings_user_id" on "collection_place_ratings" ("user_id");
|
|
alter table "collection_place_ratings" add constraint "collection_place_ratings_collection_place_id_user_id_unique" unique ("collection_place_id", "user_id");
|
|
create table "collection_place_tags" ("collection_place_id" bigint not null, "tag_id" bigint not null, primary key ("collection_place_id", "tag_id"));
|
|
create table "collection_place_labels" ("collection_place_id" bigint not null, "label_id" bigint not null, primary key ("collection_place_id", "label_id"));
|
|
create table "budget_settlements" ("id" bigserial primary key, "trip_id" bigint not null, "from_user_id" bigint not null, "to_user_id" bigint not null, "amount" double precision not null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "created_by_user_id" bigint null, "currency" text null, "exchange_rate" double precision not null default 1, "settled_at" text null, "note" text null);
|
|
create index "idx_budget_settlements_trip" on "budget_settlements" ("trip_id");
|
|
create index "idx_budget_settlements_from_user_id" on "budget_settlements" ("from_user_id");
|
|
create index "idx_budget_settlements_to_user_id" on "budget_settlements" ("to_user_id");
|
|
create index "idx_budget_settlements_created_by_user_id" on "budget_settlements" ("created_by_user_id");
|
|
create table "budget_items" ("id" bigserial primary key, "trip_id" bigint not null, "category" text not null default 'Other', "name" text not null, "total_price" double precision not null default 0, "persons" bigint null default NULL, "days" bigint null default NULL, "note" text null, "sort_order" bigint null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "paid_by_user_id" bigint null, "expense_date" text null default NULL, "reservation_id" bigint null default NULL, "currency" text null, "exchange_rate" double precision not null default 1, "ticket_json" text null, "place_id" bigint null default NULL);
|
|
create index "idx_budget_items_trip_id" on "budget_items" ("trip_id");
|
|
create index "idx_budget_items_paid_by_user_id" on "budget_items" ("paid_by_user_id");
|
|
create index "idx_budget_items_reservation_id" on "budget_items" ("reservation_id");
|
|
create index "idx_budget_items_place_id" on "budget_items" ("place_id");
|
|
create table "file_links" ("id" bigserial primary key, "file_id" bigint not null, "reservation_id" bigint null, "assignment_id" bigint null, "place_id" bigint null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "budget_item_id" bigint null);
|
|
create index "idx_file_links_reservation_id" on "file_links" ("reservation_id");
|
|
create index "idx_file_links_assignment_id" on "file_links" ("assignment_id");
|
|
create index "idx_file_links_place_id" on "file_links" ("place_id");
|
|
create index "idx_file_links_budget_item_id" on "file_links" ("budget_item_id");
|
|
alter table "file_links" add constraint "idx_file_links_file_budget" unique ("file_id", "budget_item_id");
|
|
alter table "file_links" add constraint "file_links_file_id_place_id_unique" unique ("file_id", "place_id");
|
|
alter table "file_links" add constraint "file_links_file_id_assignment_id_unique" unique ("file_id", "assignment_id");
|
|
alter table "file_links" add constraint "file_links_file_id_reservation_id_unique" unique ("file_id", "reservation_id");
|
|
create table "budget_item_payers" ("id" bigserial primary key, "budget_item_id" bigint not null, "user_id" bigint not null, "amount" double precision not null default 0);
|
|
create index "idx_budget_item_payers_item" on "budget_item_payers" ("budget_item_id");
|
|
create index "idx_budget_item_payers_user_id" on "budget_item_payers" ("user_id");
|
|
alter table "budget_item_payers" add constraint "budget_item_payers_budget_item_id_user_id_unique" unique ("budget_item_id", "user_id");
|
|
create table "budget_item_members" ("id" bigserial primary key, "budget_item_id" bigint not null, "user_id" bigint not null, "paid" bigint not null default 0, "amount" double precision null);
|
|
create index "idx_budget_item_members_item" on "budget_item_members" ("budget_item_id");
|
|
create index "idx_budget_item_members_user" on "budget_item_members" ("user_id");
|
|
alter table "budget_item_members" add constraint "budget_item_members_budget_item_id_user_id_unique" unique ("budget_item_id", "user_id");
|
|
create table "bucket_list" ("id" bigserial primary key, "user_id" bigint not null, "name" text not null, "lat" double precision null, "lng" double precision null, "country_code" text null, "notes" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "target_date" text null default NULL, "visited_at" text null, "visited_source" text null, "region_code" text null);
|
|
create index "idx_bucket_list_user_id" on "bucket_list" ("user_id");
|
|
create table "dawarich_visit_suggestions" ("id" bigserial primary key, "user_id" bigint not null, "source_visit_id" text not null, "trip_id" bigint null, "name" text not null, "lat" double precision null, "lng" double precision null, "started_at" text not null, "ended_at" text not null, "duration_minutes" bigint not null default 0, "local_date" text not null, "source_status" text not null default 'suggested', "confidence" double precision null, "confidence_band" text null, "country_code" text null, "state" text not null default 'new', "target" text null, "accepted_place_id" bigint null, "accepted_journal_entry_id" bigint null, "accepted_bucket_list_item_id" bigint null, "matched_bucket_list_item_id" bigint null, "source_hash" text not null, "accepted_hash" text null, "source_missing_at" text null, "first_seen_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_seen_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_dawarich_suggestions_trip" on "dawarich_visit_suggestions" ("trip_id");
|
|
create index "idx_dawarich_visit_suggestions_accepted_place_id" on "dawarich_visit_suggestions" ("accepted_place_id");
|
|
create index "idx_dawarich_visit_suggestions_accepted_bucket_list_item_id" on "dawarich_visit_suggestions" ("accepted_bucket_list_item_id");
|
|
create index "idx_dawarich_visit_suggestions_matched_bucket_list_item_id" on "dawarich_visit_suggestions" ("matched_bucket_list_item_id");
|
|
create index "idx_dawarich_suggestions_user_state" on "dawarich_visit_suggestions" ("user_id", "state");
|
|
alter table "dawarich_visit_suggestions" add constraint "dawarich_visit_suggestions_user_id_source_visit_id_unique" unique ("user_id", "source_visit_id");
|
|
create table "audit_log" ("id" bigserial primary key, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "user_id" bigint null, "action" text not null, "resource" text null, "details" text null, "ip" text null);
|
|
create index "idx_audit_log_created" on "audit_log" ("created_at");
|
|
create index "idx_audit_log_user_id" on "audit_log" ("user_id");
|
|
create table "assistant_usage" ("user_id" bigint not null, "day" text not null, "paid_by" text not null, "turns" bigint not null default 0, "input_tokens" bigint not null default 0, "output_tokens" bigint not null default 0, primary key ("user_id", "day", "paid_by"));
|
|
alter table "assistant_usage" add constraint "assistant_usage_user_id_day_paid_by_unique" unique ("user_id", "day", "paid_by");
|
|
create table "assistant_threads" ("id" bigserial primary key, "user_id" bigint not null, "trip_id" bigint null, "journey_id" bigint null, "title" text not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_message_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_assistant_threads_trip" on "assistant_threads" ("trip_id");
|
|
create index "idx_assistant_threads_journey" on "assistant_threads" ("journey_id");
|
|
create index "idx_assistant_threads_user_trip" on "assistant_threads" ("user_id", "trip_id", "last_message_at");
|
|
create index "idx_assistant_threads_user_journey" on "assistant_threads" ("user_id", "journey_id", "last_message_at");
|
|
create table "assistant_messages" ("id" bigserial primary key, "thread_id" bigint not null, "role" text not null, "parts" text not null, "provider_state" text null, "status" text not null default 'complete', "model" text null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_assistant_messages_thread" on "assistant_messages" ("thread_id", "id");
|
|
create table "assistant_tool_calls" ("id" text not null, "thread_id" bigint not null, "message_id" bigint not null, "provider_call_id" text not null, "tool_name" text not null, "args" text not null, "preview" text not null, "state" text not null default 'approval_requested', "result" text null, "undo_until" text null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "decided_at" text null, primary key ("id"));
|
|
create index "idx_assistant_tool_calls_message" on "assistant_tool_calls" ("message_id");
|
|
alter table "assistant_tool_calls" add constraint "assistant_tool_calls_thread_id_provider_call_id_unique" unique ("thread_id", "provider_call_id");
|
|
create table "assistant_attachments" ("id" text not null, "thread_id" bigint not null, "user_id" bigint not null, "trip_id" bigint not null, "name" text not null, "mime" text not null, "size" bigint not null, "sha256" text not null, "storage_key" text not null, "text" text null, "text_status" text not null, "shared_at" text null, "file_id" bigint null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), primary key ("id"));
|
|
create index "idx_assistant_attachments_user" on "assistant_attachments" ("user_id");
|
|
create index "idx_assistant_attachments_trip" on "assistant_attachments" ("trip_id");
|
|
create index "idx_assistant_attachments_file" on "assistant_attachments" ("file_id");
|
|
create index "idx_assistant_attachments_created" on "assistant_attachments" ("created_at");
|
|
create index "idx_assistant_attachments_thread" on "assistant_attachments" ("thread_id", "created_at");
|
|
create table "assignment_participants" ("id" bigserial primary key, "assignment_id" bigint not null, "user_id" bigint not null);
|
|
create index "idx_assignment_participants_assignment" on "assignment_participants" ("assignment_id");
|
|
create index "idx_assignment_participants_user_id" on "assignment_participants" ("user_id");
|
|
alter table "assignment_participants" add constraint "assignment_participants_assignment_id_user_id_unique" unique ("assignment_id", "user_id");
|
|
create table "ai_connections" ("id" bigserial primary key, "scope" text not null, "user_id" bigint null, "kind" text not null, "model" text not null, "base_url" text null, "secrets" text null, "secrets_version" bigint not null default 0, "hint" text null, "account" text null, "status" text not null default 'ok', "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create unique index "idx_ai_connections_instance" on "ai_connections" ("scope") where user_id IS NULL;
|
|
create unique index "idx_ai_connections_user" on "ai_connections" ("user_id") where user_id IS NOT NULL;
|
|
create table "user_sessions" ("id" text not null, "user_id" bigint not null, "created_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_seen_at" text not null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "expires_at" text not null, "revoked_at" text null, "user_agent" text null, primary key ("id"));
|
|
create index "idx_user_sessions_user" on "user_sessions" ("user_id");
|
|
create index "idx_user_sessions_expires" on "user_sessions" ("expires_at");
|
|
create table "vacay_plans" ("id" bigserial primary key, "owner_id" bigint not null, "block_weekends" bigint null default 1, "holidays_enabled" bigint null default 0, "holidays_region" text null default '', "school_holidays_enabled" bigint null default 0, "company_holidays_enabled" bigint null default 1, "carry_over_enabled" bigint null default 1, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "weekend_days" text null default '0,6', "week_start" bigint not null default 1);
|
|
alter table "vacay_plans" add constraint "vacay_plans_owner_id_unique" unique ("owner_id");
|
|
create table "vacay_plan_members" ("id" bigserial primary key, "plan_id" bigint not null, "user_id" bigint not null, "status" text null default 'pending', "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_vacay_plan_members_user_id" on "vacay_plan_members" ("user_id");
|
|
alter table "vacay_plan_members" add constraint "vacay_plan_members_plan_id_user_id_unique" unique ("plan_id", "user_id");
|
|
create table "vacay_holiday_calendars" ("id" bigserial primary key, "plan_id" bigint not null, "type" text not null default 'public_holiday', "region" text not null, "label" text null, "color" text not null default '#fecaca', "sort_order" bigint not null default 0);
|
|
create index "idx_vacay_holiday_calendars_plan_id" on "vacay_holiday_calendars" ("plan_id");
|
|
create table "vacay_entries" ("id" bigserial primary key, "plan_id" bigint not null, "user_id" bigint not null, "date" text not null, "note" text null default '', "fraction" double precision not null default 1, "kind" text not null default 'vacation');
|
|
create index "idx_vacay_entries_plan_id" on "vacay_entries" ("plan_id");
|
|
alter table "vacay_entries" add constraint "vacay_entries_user_id_plan_id_date_unique" unique ("user_id", "plan_id", "date");
|
|
create table "vacay_company_holidays" ("id" bigserial primary key, "plan_id" bigint not null, "date" text not null, "note" text null default '', "fraction" double precision not null default 1);
|
|
alter table "vacay_company_holidays" add constraint "vacay_company_holidays_plan_id_date_unique" unique ("plan_id", "date");
|
|
create table "vacay_shares" ("id" bigserial primary key, "owner_id" bigint not null, "user_id" bigint not null, "hidden" bigint not null default 0, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_vacay_shares_user" on "vacay_shares" ("user_id");
|
|
alter table "vacay_shares" add constraint "vacay_shares_owner_id_user_id_unique" unique ("owner_id", "user_id");
|
|
create table "vacay_user_colors" ("id" bigserial primary key, "user_id" bigint not null, "plan_id" bigint not null, "color" text null default '#6366f1');
|
|
create index "idx_vacay_user_colors_plan_id" on "vacay_user_colors" ("plan_id");
|
|
alter table "vacay_user_colors" add constraint "vacay_user_colors_user_id_plan_id_unique" unique ("user_id", "plan_id");
|
|
create table "vacay_user_settings" ("user_id" bigint null, "year_type" text not null default 'calendar', "year_start_month" bigint not null default 1, "year_start_day" bigint not null default 1, "hire_date" text null, primary key ("user_id"));
|
|
create table "vacay_user_years" ("id" bigserial primary key, "user_id" bigint not null, "plan_id" bigint not null, "year" bigint not null, "vacation_days" bigint null default 30, "carried_over" bigint null default 0);
|
|
create index "idx_vacay_user_years_plan_id" on "vacay_user_years" ("plan_id");
|
|
alter table "vacay_user_years" add constraint "vacay_user_years_user_id_plan_id_year_unique" unique ("user_id", "plan_id", "year");
|
|
create table "vacay_years" ("id" bigserial primary key, "plan_id" bigint not null, "year" bigint not null);
|
|
alter table "vacay_years" add constraint "vacay_years_plan_id_year_unique" unique ("plan_id", "year");
|
|
create table "visited_countries" ("id" bigserial primary key, "user_id" bigint not null, "country_code" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "source" text not null default 'manual');
|
|
alter table "visited_countries" add constraint "visited_countries_user_id_country_code_unique" unique ("user_id", "country_code");
|
|
create table "visited_regions" ("id" bigserial primary key, "user_id" bigint not null, "region_code" text not null, "region_name" text not null, "country_code" text not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_visited_regions_country" on "visited_regions" ("country_code");
|
|
alter table "visited_regions" add constraint "visited_regions_user_id_region_code_unique" unique ("user_id", "region_code");
|
|
create table "wanderer_connections" ("user_id" bigint null, "url" text not null, "token" text null, "allow_insecure_tls" bigint not null default 0, "last_checked_at" text null, "last_check_ok" bigint null, "last_check_error" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "updated_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "watch_enabled" bigint not null default 0, "watch_last_run_at" text null, "watch_failures" bigint not null default 0, "watch_paused_until" text null, primary key ("user_id"));
|
|
create table "webauthn_challenges" ("id" bigserial primary key, "challenge" text not null, "user_id" bigint null, "type" text not null, "expires_at" bigint not null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'));
|
|
create index "idx_webauthn_challenges_user_id" on "webauthn_challenges" ("user_id");
|
|
create index "idx_webauthn_challenges_expires" on "webauthn_challenges" ("expires_at");
|
|
alter table "webauthn_challenges" add constraint "webauthn_challenges_challenge_unique" unique ("challenge");
|
|
create table "webauthn_credentials" ("id" bigserial primary key, "user_id" bigint not null, "credential_id" text not null, "public_key" bytea not null, "counter" bigint not null default 0, "transports" text null, "device_type" text null, "backed_up" bigint not null default 0, "name" text null, "aaguid" text null, "created_at" text null default to_char((CURRENT_TIMESTAMP AT TIME ZONE 'UTC'), 'YYYY-MM-DD HH24:MI:SS'), "last_used_at" text null);
|
|
create index "idx_webauthn_credentials_user" on "webauthn_credentials" ("user_id");
|
|
alter table "webauthn_credentials" add constraint "webauthn_credentials_credential_id_unique" unique ("credential_id");
|
|
alter table "document_provider_fields" add constraint "document_provider_fields_provider_id_foreign" foreign key ("provider_id") references "document_providers" ("id") on delete cascade;
|
|
alter table "paddle_features" add constraint "paddle_features_region_id_foreign" foreign key ("region_id") references "paddle_regions" ("id") on delete cascade;
|
|
alter table "paddle_water_graphs" add constraint "paddle_water_graphs_region_id_foreign" foreign key ("region_id") references "paddle_regions" ("id") on update cascade on delete cascade;
|
|
alter table "photo_provider_fields" add constraint "photo_provider_fields_provider_id_foreign" foreign key ("provider_id") references "photo_providers" ("id") on delete cascade;
|
|
alter table "school_holiday_regions" add constraint "school_holiday_regions_country_foreign" foreign key ("country") references "school_holiday_countries" ("code");
|
|
alter table "school_holiday_periods" add constraint "school_holiday_periods_region_id_foreign" foreign key ("region_id") references "school_holiday_regions" ("id") on delete cascade;
|
|
alter table "user_notice_dismissals" add constraint "user_notice_dismissals_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "trips" add constraint "trips_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "roadtrip_preferences" add constraint "roadtrip_preferences_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "days" add constraint "days_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "roadtrip_vias" add constraint "roadtrip_vias_day_id_foreign" foreign key ("day_id") references "days" ("id") on delete cascade;
|
|
alter table "day_notes" add constraint "day_notes_day_id_foreign" foreign key ("day_id") references "days" ("id") on delete cascade;
|
|
alter table "day_notes" add constraint "day_notes_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "budget_category_order" add constraint "budget_category_order_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_members" add constraint "trip_members_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_members" add constraint "trip_members_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "trip_members" add constraint "trip_members_invited_by_foreign" foreign key ("invited_by") references "users" ("id") on delete no action;
|
|
alter table "trip_member_removals" add constraint "trip_member_removals_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_member_removals" add constraint "trip_member_removals_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "trip_invite_tokens" add constraint "trip_invite_tokens_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_invite_tokens" add constraint "trip_invite_tokens_created_by_foreign" foreign key ("created_by") references "users" ("id") on delete set null;
|
|
alter table "trip_album_links" add constraint "trip_album_links_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_album_links" add constraint "trip_album_links_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "trek_photos" add constraint "trek_photos_owner_id_foreign" foreign key ("owner_id") references "users" ("id") on delete set null;
|
|
alter table "trip_photos" add constraint "trip_photos_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_photos" add constraint "trip_photos_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "trip_photos" add constraint "trip_photos_photo_id_foreign" foreign key ("photo_id") references "trek_photos" ("id") on delete cascade;
|
|
alter table "trip_photos" add constraint "trip_photos_album_link_id_foreign" foreign key ("album_link_id") references "trip_album_links" ("id") on delete set null;
|
|
alter table "trek_photo_signals" add constraint "trek_photo_signals_photo_id_foreign" foreign key ("photo_id") references "trek_photos" ("id") on delete cascade;
|
|
alter table "tour_drafts" add constraint "tour_drafts_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "tour_drafts" add constraint "tour_drafts_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "todo_items" add constraint "todo_items_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "todo_items" add constraint "todo_items_assigned_user_id_foreign" foreign key ("assigned_user_id") references "users" ("id") on delete set null;
|
|
alter table "todo_category_assignees" add constraint "todo_category_assignees_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "todo_category_assignees" add constraint "todo_category_assignees_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "tags" add constraint "tags_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "share_tokens" add constraint "share_tokens_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "share_tokens" add constraint "share_tokens_created_by_foreign" foreign key ("created_by") references "users" ("id");
|
|
alter table "settings" add constraint "settings_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "push_subscriptions" add constraint "push_subscriptions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "password_reset_tokens" add constraint "password_reset_tokens_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "packing_templates" add constraint "packing_templates_created_by_foreign" foreign key ("created_by") references "users" ("id") on delete cascade;
|
|
alter table "packing_template_categories" add constraint "packing_template_categories_template_id_foreign" foreign key ("template_id") references "packing_templates" ("id") on delete cascade;
|
|
alter table "packing_template_items" add constraint "packing_template_items_category_id_foreign" foreign key ("category_id") references "packing_template_categories" ("id") on delete cascade;
|
|
alter table "packing_category_assignees" add constraint "packing_category_assignees_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "packing_category_assignees" add constraint "packing_category_assignees_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "packing_bags" add constraint "packing_bags_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "packing_bags" add constraint "packing_bags_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete set null;
|
|
alter table "packing_items" add constraint "packing_items_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "packing_items" add constraint "packing_items_bag_id_foreign" foreign key ("bag_id") references "packing_bags" ("id") on delete set null;
|
|
alter table "packing_items" add constraint "packing_items_owner_id_foreign" foreign key ("owner_id") references "users" ("id") on delete set null;
|
|
alter table "packing_item_contributors" add constraint "packing_item_contributors_item_id_foreign" foreign key ("item_id") references "packing_items" ("id") on update cascade on delete cascade;
|
|
alter table "packing_item_contributors" add constraint "packing_item_contributors_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "packing_item_recipients" add constraint "packing_item_recipients_item_id_foreign" foreign key ("item_id") references "packing_items" ("id") on update cascade on delete cascade;
|
|
alter table "packing_item_recipients" add constraint "packing_item_recipients_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "packing_bag_members" add constraint "packing_bag_members_bag_id_foreign" foreign key ("bag_id") references "packing_bags" ("id") on update cascade on delete cascade;
|
|
alter table "packing_bag_members" add constraint "packing_bag_members_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "oauth_clients" add constraint "oauth_clients_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "oauth_tokens" add constraint "oauth_tokens_client_id_foreign" foreign key ("client_id") references "oauth_clients" ("client_id") on delete cascade;
|
|
alter table "oauth_tokens" add constraint "oauth_tokens_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "oauth_tokens" add constraint "oauth_tokens_parent_token_id_foreign" foreign key ("parent_token_id") references "oauth_tokens" ("id") on delete no action;
|
|
alter table "oauth_consents" add constraint "oauth_consents_client_id_foreign" foreign key ("client_id") references "oauth_clients" ("client_id") on delete cascade;
|
|
alter table "oauth_consents" add constraint "oauth_consents_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "notifications" add constraint "notifications_sender_id_foreign" foreign key ("sender_id") references "users" ("id") on delete set null;
|
|
alter table "notifications" add constraint "notifications_recipient_id_foreign" foreign key ("recipient_id") references "users" ("id") on delete cascade;
|
|
alter table "notification_channel_preferences" add constraint "notification_channel_preferences_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "mcp_tokens" add constraint "mcp_tokens_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "journeys" add constraint "journeys_user_id_foreign" foreign key ("user_id") references "users" ("id");
|
|
alter table "trip_journal_links" add constraint "trip_journal_links_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_journal_links" add constraint "trip_journal_links_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "trip_journal_links" add constraint "trip_journal_links_linked_by_foreign" foreign key ("linked_by") references "users" ("id") on delete set null;
|
|
alter table "trip_journal_link_members" add constraint "trip_journal_link_members_link_id_foreign" foreign key ("link_id") references "trip_journal_links" ("id") on update cascade on delete cascade;
|
|
alter table "trip_journal_link_members" add constraint "trip_journal_link_members_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "journey_trips" add constraint "journey_trips_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on update cascade on delete cascade;
|
|
alter table "journey_trips" add constraint "journey_trips_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on update cascade on delete cascade;
|
|
alter table "journey_share_tokens" add constraint "journey_share_tokens_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_share_tokens" add constraint "journey_share_tokens_created_by_foreign" foreign key ("created_by") references "users" ("id");
|
|
alter table "journey_photos" add constraint "journey_photos_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_photos" add constraint "journey_photos_photo_id_foreign" foreign key ("photo_id") references "trek_photos" ("id") on delete cascade;
|
|
alter table "journey_book_revisions" add constraint "journey_book_revisions_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_recording_prep" add constraint "journey_recording_prep_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_recording_prep" add constraint "journey_recording_prep_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "journey_recorded_days" add constraint "journey_recorded_days_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_recorded_days" add constraint "journey_recorded_days_imported_by_foreign" foreign key ("imported_by") references "users" ("id") on delete set null;
|
|
alter table "journey_contributors" add constraint "journey_contributors_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on update cascade on delete cascade;
|
|
alter table "journey_contributors" add constraint "journey_contributors_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete no action;
|
|
alter table "journey_books" add constraint "journey_books_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_books" add constraint "journey_books_updated_by_foreign" foreign key ("updated_by") references "users" ("id") on delete set null;
|
|
alter table "journey_books" add constraint "journey_books_created_by_foreign" foreign key ("created_by") references "users" ("id") on delete set null;
|
|
alter table "invite_tokens" add constraint "invite_tokens_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete set null;
|
|
alter table "invite_tokens" add constraint "invite_tokens_created_by_foreign" foreign key ("created_by") references "users" ("id") on delete cascade;
|
|
alter table "idempotency_keys" add constraint "idempotency_keys_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "hidden_regions" add constraint "hidden_regions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "hidden_countries" add constraint "hidden_countries_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "document_connections" add constraint "document_connections_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "document_connections" add constraint "document_connections_provider_id_foreign" foreign key ("provider_id") references "document_providers" ("id") on delete cascade;
|
|
alter table "document_connections" add constraint "document_connections_owner_user_id_foreign" foreign key ("owner_user_id") references "users" ("id") on delete cascade;
|
|
alter table "trip_document_links" add constraint "trip_document_links_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_document_links" add constraint "trip_document_links_connection_id_foreign" foreign key ("connection_id") references "document_connections" ("id") on delete cascade;
|
|
alter table "trip_document_links" add constraint "trip_document_links_created_by_foreign" foreign key ("created_by") references "users" ("id") on delete set null;
|
|
alter table "dawarich_connections" add constraint "dawarich_connections_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "collections" add constraint "collections_owner_id_foreign" foreign key ("owner_id") references "users" ("id") on delete cascade;
|
|
alter table "collection_tours" add constraint "collection_tours_collection_id_foreign" foreign key ("collection_id") references "collections" ("id") on delete cascade;
|
|
alter table "collection_tours" add constraint "collection_tours_tour_type_foreign" foreign key ("tour_type") references "tour_types" ("key");
|
|
alter table "collection_tours" add constraint "collection_tours_saved_by_foreign" foreign key ("saved_by") references "users" ("id") on delete set null;
|
|
alter table "collection_labels" add constraint "collection_labels_collection_id_foreign" foreign key ("collection_id") references "collections" ("id") on delete cascade;
|
|
alter table "collection_members" add constraint "collection_members_collection_id_foreign" foreign key ("collection_id") references "collections" ("id") on delete cascade;
|
|
alter table "collection_members" add constraint "collection_members_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collab_polls" add constraint "collab_polls_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "collab_polls" add constraint "collab_polls_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collab_poll_votes" add constraint "collab_poll_votes_poll_id_foreign" foreign key ("poll_id") references "collab_polls" ("id") on delete cascade;
|
|
alter table "collab_poll_votes" add constraint "collab_poll_votes_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collab_notes" add constraint "collab_notes_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "collab_notes" add constraint "collab_notes_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collab_messages" add constraint "collab_messages_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "collab_messages" add constraint "collab_messages_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collab_messages" add constraint "collab_messages_reply_to_foreign" foreign key ("reply_to") references "collab_messages" ("id") on delete set null;
|
|
alter table "collab_message_reactions" add constraint "collab_message_reactions_message_id_foreign" foreign key ("message_id") references "collab_messages" ("id") on delete cascade;
|
|
alter table "collab_message_reactions" add constraint "collab_message_reactions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collab_links" add constraint "collab_links_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "collab_links" add constraint "collab_links_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "categories" add constraint "categories_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete set null;
|
|
alter table "places" add constraint "places_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "places" add constraint "places_category_id_foreign" foreign key ("category_id") references "categories" ("id") on delete set null;
|
|
alter table "tours" add constraint "tours_place_id_foreign" foreign key ("place_id") references "places" ("id") on update cascade on delete cascade;
|
|
alter table "tours" add constraint "tours_derived_from_place_id_foreign" foreign key ("derived_from_place_id") references "places" ("id") on delete set null;
|
|
alter table "tours" add constraint "tours_tour_type_foreign" foreign key ("tour_type") references "tour_types" ("key");
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on delete cascade;
|
|
alter table "tour_waypoints" add constraint "tour_waypoints_linked_place_id_foreign" foreign key ("linked_place_id") references "places" ("id") on delete set null;
|
|
alter table "tour_sources" add constraint "tour_sources_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on update cascade on delete cascade;
|
|
alter table "tour_sources" add constraint "tour_sources_imported_by_foreign" foreign key ("imported_by") references "users" ("id") on delete set null;
|
|
alter table "tour_source_hints" add constraint "tour_source_hints_place_id_foreign" foreign key ("place_id") references "tour_sources" ("place_id") on update cascade on delete cascade;
|
|
alter table "tour_source_hints" add constraint "tour_source_hints_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "tour_packing_links" add constraint "tour_packing_links_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on update cascade on delete cascade;
|
|
alter table "tour_packing_links" add constraint "tour_packing_links_linked_by_foreign" foreign key ("linked_by") references "users" ("id") on delete set null;
|
|
alter table "tour_obstacle_reviews" add constraint "tour_obstacle_reviews_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on delete cascade;
|
|
alter table "tour_change_steps" add constraint "tour_change_steps_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on delete cascade;
|
|
alter table "tour_activity_exclusions" add constraint "tour_activity_exclusions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "tour_activity_exclusions" add constraint "tour_activity_exclusions_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on delete cascade;
|
|
alter table "roadtrip_day_tracks" add constraint "roadtrip_day_tracks_day_id_foreign" foreign key ("day_id") references "days" ("id") on update cascade on delete cascade;
|
|
alter table "roadtrip_day_tracks" add constraint "roadtrip_day_tracks_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete cascade;
|
|
alter table "place_regions" add constraint "place_regions_place_id_foreign" foreign key ("place_id") references "places" ("id") on update cascade on delete cascade;
|
|
alter table "place_ratings" add constraint "place_ratings_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete cascade;
|
|
alter table "place_ratings" add constraint "place_ratings_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "place_field_origin" add constraint "place_field_origin_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete cascade;
|
|
alter table "place_contrib_outbox" add constraint "place_contrib_outbox_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete cascade;
|
|
alter table "place_tags" add constraint "place_tags_place_id_foreign" foreign key ("place_id") references "places" ("id") on update cascade on delete cascade;
|
|
alter table "place_tags" add constraint "place_tags_tag_id_foreign" foreign key ("tag_id") references "tags" ("id") on update cascade on delete cascade;
|
|
alter table "photos" add constraint "photos_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "photos" add constraint "photos_day_id_foreign" foreign key ("day_id") references "days" ("id") on delete set null;
|
|
alter table "photos" add constraint "photos_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete set null;
|
|
alter table "journey_entries" add constraint "journey_entries_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_entries" add constraint "journey_entries_source_trip_id_foreign" foreign key ("source_trip_id") references "trips" ("id") on delete set null;
|
|
alter table "journey_entries" add constraint "journey_entries_source_place_id_foreign" foreign key ("source_place_id") references "places" ("id") on delete set null;
|
|
alter table "journey_entries" add constraint "journey_entries_author_id_foreign" foreign key ("author_id") references "users" ("id");
|
|
alter table "journey_entry_stays" add constraint "journey_entry_stays_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "journey_entry_stays" add constraint "journey_entry_stays_entry_id_foreign" foreign key ("entry_id") references "journey_entries" ("id") on delete cascade;
|
|
alter table "journey_entry_stays" add constraint "journey_entry_stays_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete set null;
|
|
alter table "journey_entry_photos" add constraint "journey_entry_photos_entry_id_foreign" foreign key ("entry_id") references "journey_entries" ("id") on update cascade on delete cascade;
|
|
alter table "journey_entry_photos" add constraint "journey_entry_photos_journey_photo_id_foreign" foreign key ("journey_photo_id") references "journey_photos" ("id") on update cascade on delete cascade;
|
|
alter table "day_assignments" add constraint "day_assignments_day_id_foreign" foreign key ("day_id") references "days" ("id") on delete cascade;
|
|
alter table "day_assignments" add constraint "day_assignments_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete cascade;
|
|
alter table "tour_station_visits" add constraint "tour_station_visits_assignment_id_foreign" foreign key ("assignment_id") references "day_assignments" ("id") on delete cascade;
|
|
alter table "tour_activities" add constraint "tour_activities_place_id_foreign" foreign key ("place_id") references "tours" ("place_id") on delete cascade;
|
|
alter table "tour_activities" add constraint "tour_activities_track_place_id_foreign" foreign key ("track_place_id") references "tours" ("place_id") on delete cascade;
|
|
alter table "tour_activities" add constraint "tour_activities_assignment_id_foreign" foreign key ("assignment_id") references "day_assignments" ("id") on delete set null;
|
|
alter table "tour_activities" add constraint "tour_activities_assigned_by_foreign" foreign key ("assigned_by") references "users" ("id") on delete set null;
|
|
alter table "roadtrip_day_boundaries" add constraint "roadtrip_day_boundaries_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "roadtrip_day_boundaries" add constraint "roadtrip_day_boundaries_from_assignment_id_foreign" foreign key ("from_assignment_id") references "day_assignments" ("id") on delete cascade;
|
|
alter table "roadtrip_day_boundaries" add constraint "roadtrip_day_boundaries_to_assignment_id_foreign" foreign key ("to_assignment_id") references "day_assignments" ("id") on delete cascade;
|
|
alter table "reservations" add constraint "reservations_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "reservations" add constraint "reservations_day_id_foreign" foreign key ("day_id") references "days" ("id") on delete set null;
|
|
alter table "reservations" add constraint "reservations_end_day_id_foreign" foreign key ("end_day_id") references "days" ("id") on delete set null;
|
|
alter table "reservations" add constraint "reservations_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete set null;
|
|
alter table "reservations" add constraint "reservations_assignment_id_foreign" foreign key ("assignment_id") references "day_assignments" ("id") on delete set null;
|
|
alter table "trip_files" add constraint "trip_files_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "trip_files" add constraint "trip_files_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete set null;
|
|
alter table "trip_files" add constraint "trip_files_reservation_id_foreign" foreign key ("reservation_id") references "reservations" ("id") on delete set null;
|
|
alter table "trip_files" add constraint "trip_files_note_id_foreign" foreign key ("note_id") references "collab_notes" ("id") on delete set null;
|
|
alter table "trip_files" add constraint "trip_files_message_id_foreign" foreign key ("message_id") references "collab_messages" ("id") on delete cascade;
|
|
alter table "trip_files" add constraint "trip_files_uploaded_by_foreign" foreign key ("uploaded_by") references "users" ("id") on delete set null;
|
|
alter table "document_sync_items" add constraint "document_sync_items_link_id_foreign" foreign key ("link_id") references "trip_document_links" ("id") on delete cascade;
|
|
alter table "document_sync_items" add constraint "document_sync_items_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "document_sync_items" add constraint "document_sync_items_file_id_foreign" foreign key ("file_id") references "trip_files" ("id") on delete set null;
|
|
alter table "reservation_travelers" add constraint "reservation_travelers_reservation_id_foreign" foreign key ("reservation_id") references "reservations" ("id") on delete cascade;
|
|
alter table "reservation_travelers" add constraint "reservation_travelers_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "reservation_endpoints" add constraint "reservation_endpoints_reservation_id_foreign" foreign key ("reservation_id") references "reservations" ("id") on delete cascade;
|
|
alter table "reservation_day_positions" add constraint "reservation_day_positions_reservation_id_foreign" foreign key ("reservation_id") references "reservations" ("id") on update cascade on delete cascade;
|
|
alter table "reservation_day_positions" add constraint "reservation_day_positions_day_id_foreign" foreign key ("day_id") references "days" ("id") on update cascade on delete cascade;
|
|
alter table "day_accommodations" add constraint "day_accommodations_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "day_accommodations" add constraint "day_accommodations_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete set null;
|
|
alter table "day_accommodations" add constraint "day_accommodations_start_day_id_foreign" foreign key ("start_day_id") references "days" ("id") on delete cascade;
|
|
alter table "day_accommodations" add constraint "day_accommodations_end_day_id_foreign" foreign key ("end_day_id") references "days" ("id") on delete cascade;
|
|
alter table "collection_places" add constraint "collection_places_collection_id_foreign" foreign key ("collection_id") references "collections" ("id") on delete cascade;
|
|
alter table "collection_places" add constraint "collection_places_owner_id_foreign" foreign key ("owner_id") references "users" ("id") on delete cascade;
|
|
alter table "collection_places" add constraint "collection_places_category_id_foreign" foreign key ("category_id") references "categories" ("id") on delete set null;
|
|
alter table "collection_places" add constraint "collection_places_saved_by_foreign" foreign key ("saved_by") references "users" ("id") on delete set null;
|
|
alter table "collection_place_ratings" add constraint "collection_place_ratings_collection_place_id_foreign" foreign key ("collection_place_id") references "collection_places" ("id") on delete cascade;
|
|
alter table "collection_place_ratings" add constraint "collection_place_ratings_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "collection_place_tags" add constraint "collection_place_tags_collection_place_id_foreign" foreign key ("collection_place_id") references "collection_places" ("id") on update cascade on delete cascade;
|
|
alter table "collection_place_tags" add constraint "collection_place_tags_tag_id_foreign" foreign key ("tag_id") references "tags" ("id") on update cascade on delete cascade;
|
|
alter table "collection_place_labels" add constraint "collection_place_labels_collection_place_id_foreign" foreign key ("collection_place_id") references "collection_places" ("id") on update cascade on delete cascade;
|
|
alter table "collection_place_labels" add constraint "collection_place_labels_label_id_foreign" foreign key ("label_id") references "collection_labels" ("id") on update cascade on delete cascade;
|
|
alter table "budget_settlements" add constraint "budget_settlements_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "budget_settlements" add constraint "budget_settlements_from_user_id_foreign" foreign key ("from_user_id") references "users" ("id") on delete cascade;
|
|
alter table "budget_settlements" add constraint "budget_settlements_to_user_id_foreign" foreign key ("to_user_id") references "users" ("id") on delete cascade;
|
|
alter table "budget_settlements" add constraint "budget_settlements_created_by_user_id_foreign" foreign key ("created_by_user_id") references "users" ("id") on delete no action;
|
|
alter table "budget_items" add constraint "budget_items_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "budget_items" add constraint "budget_items_paid_by_user_id_foreign" foreign key ("paid_by_user_id") references "users" ("id") on delete no action;
|
|
alter table "budget_items" add constraint "budget_items_reservation_id_foreign" foreign key ("reservation_id") references "reservations" ("id") on delete set null;
|
|
alter table "budget_items" add constraint "budget_items_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete set null;
|
|
alter table "file_links" add constraint "file_links_file_id_foreign" foreign key ("file_id") references "trip_files" ("id") on delete cascade;
|
|
alter table "file_links" add constraint "file_links_reservation_id_foreign" foreign key ("reservation_id") references "reservations" ("id") on delete cascade;
|
|
alter table "file_links" add constraint "file_links_assignment_id_foreign" foreign key ("assignment_id") references "day_assignments" ("id") on delete cascade;
|
|
alter table "file_links" add constraint "file_links_place_id_foreign" foreign key ("place_id") references "places" ("id") on delete cascade;
|
|
alter table "file_links" add constraint "file_links_budget_item_id_foreign" foreign key ("budget_item_id") references "budget_items" ("id") on delete set null;
|
|
alter table "budget_item_payers" add constraint "budget_item_payers_budget_item_id_foreign" foreign key ("budget_item_id") references "budget_items" ("id") on delete cascade;
|
|
alter table "budget_item_payers" add constraint "budget_item_payers_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "budget_item_members" add constraint "budget_item_members_budget_item_id_foreign" foreign key ("budget_item_id") references "budget_items" ("id") on delete cascade;
|
|
alter table "budget_item_members" add constraint "budget_item_members_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "bucket_list" add constraint "bucket_list_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "dawarich_visit_suggestions" add constraint "dawarich_visit_suggestions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "dawarich_visit_suggestions" add constraint "dawarich_visit_suggestions_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete set null;
|
|
alter table "dawarich_visit_suggestions" add constraint "dawarich_visit_suggestions_accepted_place_id_foreign" foreign key ("accepted_place_id") references "places" ("id") on delete set null;
|
|
alter table "dawarich_visit_suggestions" add constraint "dawarich_visit_suggestions_accepted_bucket_list_item_id_foreign" foreign key ("accepted_bucket_list_item_id") references "bucket_list" ("id") on delete set null;
|
|
alter table "dawarich_visit_suggestions" add constraint "dawarich_visit_suggestions_matched_bucket_list_item_id_foreign" foreign key ("matched_bucket_list_item_id") references "bucket_list" ("id") on delete set null;
|
|
alter table "audit_log" add constraint "audit_log_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete set null;
|
|
alter table "assistant_usage" add constraint "assistant_usage_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "assistant_threads" add constraint "assistant_threads_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "assistant_threads" add constraint "assistant_threads_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "assistant_threads" add constraint "assistant_threads_journey_id_foreign" foreign key ("journey_id") references "journeys" ("id") on delete cascade;
|
|
alter table "assistant_messages" add constraint "assistant_messages_thread_id_foreign" foreign key ("thread_id") references "assistant_threads" ("id") on delete cascade;
|
|
alter table "assistant_tool_calls" add constraint "assistant_tool_calls_thread_id_foreign" foreign key ("thread_id") references "assistant_threads" ("id") on delete cascade;
|
|
alter table "assistant_tool_calls" add constraint "assistant_tool_calls_message_id_foreign" foreign key ("message_id") references "assistant_messages" ("id") on delete cascade;
|
|
alter table "assistant_attachments" add constraint "assistant_attachments_thread_id_foreign" foreign key ("thread_id") references "assistant_threads" ("id") on delete cascade;
|
|
alter table "assistant_attachments" add constraint "assistant_attachments_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "assistant_attachments" add constraint "assistant_attachments_trip_id_foreign" foreign key ("trip_id") references "trips" ("id") on delete cascade;
|
|
alter table "assistant_attachments" add constraint "assistant_attachments_file_id_foreign" foreign key ("file_id") references "trip_files" ("id") on delete set null;
|
|
alter table "assignment_participants" add constraint "assignment_participants_assignment_id_foreign" foreign key ("assignment_id") references "day_assignments" ("id") on delete cascade;
|
|
alter table "assignment_participants" add constraint "assignment_participants_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "ai_connections" add constraint "ai_connections_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "user_sessions" add constraint "user_sessions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_plans" add constraint "vacay_plans_owner_id_foreign" foreign key ("owner_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_plan_members" add constraint "vacay_plan_members_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "vacay_plan_members" add constraint "vacay_plan_members_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_holiday_calendars" add constraint "vacay_holiday_calendars_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "vacay_entries" add constraint "vacay_entries_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "vacay_entries" add constraint "vacay_entries_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_company_holidays" add constraint "vacay_company_holidays_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "vacay_shares" add constraint "vacay_shares_owner_id_foreign" foreign key ("owner_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_shares" add constraint "vacay_shares_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_user_colors" add constraint "vacay_user_colors_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_user_colors" add constraint "vacay_user_colors_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "vacay_user_settings" add constraint "vacay_user_settings_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "vacay_user_years" add constraint "vacay_user_years_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "vacay_user_years" add constraint "vacay_user_years_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "vacay_years" add constraint "vacay_years_plan_id_foreign" foreign key ("plan_id") references "vacay_plans" ("id") on delete cascade;
|
|
alter table "visited_countries" add constraint "visited_countries_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "visited_regions" add constraint "visited_regions_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "wanderer_connections" add constraint "wanderer_connections_user_id_foreign" foreign key ("user_id") references "users" ("id") on update cascade on delete cascade;
|
|
alter table "webauthn_challenges" add constraint "webauthn_challenges_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
alter table "webauthn_credentials" add constraint "webauthn_credentials_user_id_foreign" foreign key ("user_id") references "users" ("id") on delete cascade;
|
|
insert into "app_settings" ("key", "value") values ('app_version', '3.0.15'), ('places_photos_enabled', 'true'), ('places_autocomplete_enabled', 'true'), ('places_details_enabled', 'true');
|
|
insert into "addons" ("id", "name", "description", "type", "icon", "enabled", "config", "sort_order") values ('collab', 'Collab', 'Notes, polls, and live chat for trip collaboration', 'trip', 'Users', '1', '{}', '6'), ('memories', 'Photos', NULL, 'trip', 'Image', '0', '{}', '7'), ('mcp', 'MCP', 'Model Context Protocol for AI assistant integration', 'integration', 'Terminal', '0', '{}', '12'), ('naver_list_import', 'Naver List Import', 'Import places from shared Naver Maps lists', 'integration', 'Link2', '1', '{}', '13'), ('journey', 'Journey', 'Trip tracking & travel journal — check-ins, photos, daily stories', 'global', 'Compass', '0', '{}', '35'), ('airtrail', 'AirTrail', 'Sync flights from your self-hosted AirTrail instance', 'integration', 'Plane', '0', '{}', '14'), ('collections', 'Collections', 'Personal place library — save places across trips into named lists, copy into any trip, share with others', 'global', 'Bookmark', '0', '{}', '16');
|
|
insert into "photo_providers" ("id", "name", "description", "icon", "enabled", "sort_order") values ('synologyphotos', 'Synology Photos', 'Synology Photos integration with separate account settings', 'Image', '0', '1');
|
|
insert into "photo_provider_fields" ("id", "provider_id", "field_key", "label", "input_type", "placeholder", "hint", "required", "secret", "settings_key", "payload_key", "sort_order") values ('1', 'synologyphotos', 'synology_url', 'providerUrl', 'url', 'https://synology.example.com', 'providerUrlHintSynology', '1', '0', 'synology_url', 'synology_url', '0'), ('2', 'synologyphotos', 'synology_username', 'providerUsername', 'text', 'Username', NULL, '1', '0', 'synology_username', 'synology_username', '1'), ('3', 'synologyphotos', 'synology_password', 'providerPassword', 'password', 'Password', NULL, '1', '1', NULL, 'synology_password', '2'), ('4', 'synologyphotos', 'synology_otp', 'providerOTP', 'text', '123456', NULL, '0', '0', NULL, 'synology_otp', '3'), ('5', 'synologyphotos', 'synology_skip_ssl', 'skipSSLVerification', 'checkbox', NULL, NULL, '0', '0', 'synology_skip_ssl', 'synology_skip_ssl', '4');
|
|
select setval(seq, greatest(max_id, 1)) from (select pg_get_serial_sequence('"photo_provider_fields"', 'id') as seq, max("id") as max_id from "photo_provider_fields") ids where seq is not null;
|
|
insert into "document_providers" ("id", "name", "description", "icon", "enabled", "sort_order") values ('paperless', 'Paperless-ngx', 'Two-way document sync with a Paperless-ngx instance, scoped by tag', 'FileText', '0', '0'), ('papra', 'Papra', 'Two-way document sync with a Papra organisation, scoped by tag', 'FileText', '0', '1'), ('nextcloud', 'Nextcloud', 'Two-way document sync with a Nextcloud folder over WebDAV', 'Cloud', '0', '2'), ('opencloud', 'OpenCloud', 'Two-way document sync with an OpenCloud space over WebDAV', 'Cloud', '0', '3'), ('synologydrive', 'Synology Drive', 'Two-way document sync with a folder on a Synology NAS', 'HardDrive', '0', '4');
|
|
insert into "document_provider_fields" ("id", "provider_id", "field_key", "label", "input_type", "placeholder", "hint", "required", "secret", "sort_order") values ('1', 'paperless', 'base_url', 'providerUrl', 'url', 'https://paperless.example.com', NULL, '1', '0', '0'), ('2', 'paperless', 'api_token', 'providerApiToken', 'password', 'API token', 'hintPaperlessToken', '1', '1', '1'), ('3', 'paperless', 'allow_insecure_tls', 'allowInsecureTls', 'checkbox', NULL, NULL, '0', '0', '2'), ('4', 'papra', 'base_url', 'providerUrl', 'url', 'https://papra.example.com', NULL, '1', '0', '0'), ('5', 'papra', 'api_key', 'providerApiKey', 'password', 'ppapi_…', 'hintPapraKey', '1', '1', '1'), ('6', 'papra', 'organization_id', 'providerOrganization', 'text', 'org_…', 'hintPapraOrg', '1', '0', '2'), ('7', 'papra', 'allow_insecure_tls', 'allowInsecureTls', 'checkbox', NULL, NULL, '0', '0', '3'), ('8', 'nextcloud', 'base_url', 'providerUrl', 'url', 'https://cloud.example.com', NULL, '1', '0', '0'), ('9', 'nextcloud', 'login_name', 'providerUsername', 'text', 'username', 'hintNextcloudLogin', '1', '0', '1'), ('10', 'nextcloud', 'app_password', 'providerAppPassword', 'password', 'app password', 'hintNextcloudAppPassword', '1', '1', '2'), ('11', 'nextcloud', 'base_path', 'providerBasePath', 'text', '/TREK', 'hintBasePath', '0', '0', '3'), ('12', 'nextcloud', 'allow_insecure_tls', 'allowInsecureTls', 'checkbox', NULL, NULL, '0', '0', '4'), ('13', 'opencloud', 'base_url', 'providerUrl', 'url', 'https://opencloud.example.com', NULL, '1', '0', '0'), ('14', 'opencloud', 'username', 'providerUsername', 'text', 'username', NULL, '1', '0', '1'), ('15', 'opencloud', 'app_token', 'providerAppToken', 'password', 'app token', 'hintOpenCloudToken', '1', '1', '2'), ('16', 'opencloud', 'allow_insecure_tls', 'allowInsecureTls', 'checkbox', NULL, NULL, '0', '0', '3'), ('17', 'synologydrive', 'base_url', 'providerUrl', 'url', 'https://nas.example.com:5001', 'hintSynologyUrl', '1', '0', '0'), ('18', 'synologydrive', 'username', 'providerUsername', 'text', 'username', 'hintSynologyUser', '1', '0', '1'), ('19', 'synologydrive', 'password', 'providerPassword', 'password', 'password', NULL, '1', '1', '2'), ('20', 'synologydrive', 'otp_code', 'providerOTP', 'text', '123456', 'hintSynologyOtp', '0', '1', '3'), ('21', 'synologydrive', 'base_path', 'providerBasePath', 'text', '/trek', 'hintBasePath', '0', '0', '4'), ('22', 'synologydrive', 'allow_insecure_tls', 'allowInsecureTls', 'checkbox', NULL, NULL, '0', '0', '5');
|
|
select setval(seq, greatest(max_id, 1)) from (select pg_get_serial_sequence('"document_provider_fields"', 'id') as seq, max("id") as max_id from "document_provider_fields") ids where seq is not null;
|
|
insert into "tour_types" ("key", "label_key", "icon", "color", "routing_profile", "is_sport", "enabled", "sort_order") values ('hike', 'tourTypes.hike', 'Mountain', '#16a34a', 'pedestrian', '1', '1', '0'), ('bike', 'tourTypes.bike', 'Bike', '#2563eb', 'bicycle', '1', '1', '1'), ('run', 'tourTypes.run', 'Footprints', '#dc2626', 'pedestrian', '1', '1', '2'), ('ski', 'tourTypes.ski', 'MountainSnow', '#0891b2', NULL, '1', '1', '3'), ('kayak', 'tourTypes.kayak', 'Sailboat', '#0d9488', NULL, '1', '1', '4'), ('walk', 'tourTypes.walk', 'Landmark', '#9333ea', 'pedestrian', '0', '1', '5'), ('food', 'tourTypes.food', 'UtensilsCrossed', '#ea580c', 'pedestrian', '0', '0', '6'), ('horse', 'tourTypes.horse', 'Horseshoe', '#a16207', NULL, '1', '1', '7');
|
|
CREATE FUNCTION trg_release_stop_on_stay_delete() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
BEGIN
|
|
UPDATE day_assignments SET accommodation_id = NULL WHERE accommodation_id = OLD.id;
|
|
RETURN OLD;
|
|
END
|
|
$$;
|
|
CREATE TRIGGER trg_release_stop_on_stay_delete AFTER DELETE ON day_accommodations FOR EACH ROW EXECUTE FUNCTION trg_release_stop_on_stay_delete();
|
|
CREATE FUNCTION trg_place_regions_follow_place() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
BEGIN
|
|
DELETE FROM place_regions WHERE place_id = NEW.id;
|
|
RETURN NEW;
|
|
END
|
|
$$;
|
|
CREATE TRIGGER trg_place_regions_follow_place AFTER UPDATE OF lat, lng, address ON places FOR EACH ROW WHEN (OLD.lat IS DISTINCT FROM NEW.lat OR OLD.lng IS DISTINCT FROM NEW.lng OR OLD.address IS DISTINCT FROM NEW.address) EXECUTE FUNCTION trg_place_regions_follow_place();
|