diff --git a/apps/expo/src/app/home/index.tsx b/apps/expo/src/app/home/index.tsx index 160f606f..9f6a888f 100644 --- a/apps/expo/src/app/home/index.tsx +++ b/apps/expo/src/app/home/index.tsx @@ -84,6 +84,8 @@ export function EventToast() { } export function Home() { + // const hello = api.menu.hello.useQuery(); + const { anteateryMenu, brandywineMenu, setAnteateryMenu, setBrandywineMenu } = useMenuStore(); diff --git a/apps/expo/src/utils/api.tsx b/apps/expo/src/utils/api.tsx index 9a1ebf50..2ada14b4 100644 --- a/apps/expo/src/utils/api.tsx +++ b/apps/expo/src/utils/api.tsx @@ -19,7 +19,7 @@ export { type RouterInputs, type RouterOutputs } from "@zotmeal/api"; */ const getBaseUrl = () => { /** - * Gets the IP address of your host-machine. If it cannot automatically find it, + * Gets the IP address of your host-machine. If it cannot automatically find i t, * you'll have to manually set it. NOTE: Port 3000 should work for most but confirm * you don't have anything else running on it, or you'd have to change it. * diff --git a/packages/db/testMigrations/0000_nostalgic_earthquake.sql b/packages/db/testMigrations/0000_nostalgic_earthquake.sql new file mode 100644 index 00000000..9a2816f5 --- /dev/null +++ b/packages/db/testMigrations/0000_nostalgic_earthquake.sql @@ -0,0 +1,151 @@ +DO $$ BEGIN + CREATE TYPE "period" AS ENUM('latenight', 'dinner', 'lunch', 'brunch', 'breakfast'); +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "diet_restrictions" ( + "dish_id" text PRIMARY KEY NOT NULL, + "created_at" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3), + "contains_eggs" boolean, + "contains_fish" boolean, + "contains_milk" boolean, + "contains_peanuts" boolean, + "contains_sesame" boolean, + "contains_shellfish" boolean, + "contains_soy" boolean, + "contains_tree_nuts" boolean, + "contains_wheat" boolean, + "is_gluten_free" boolean, + "is_halal" boolean, + "is_kosher" boolean, + "is_locally_grown" boolean, + "is_organic" boolean, + "is_vegan" boolean, + "is_vegetarian" boolean +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "dish_menu_station_joint" ( + "dish_id" text NOT NULL, + "menu_id" text NOT NULL, + "station_id" text NOT NULL, + CONSTRAINT "dish_menu_station_joint_dish_id_menu_id_station_id_pk" PRIMARY KEY("dish_id","menu_id","station_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "dishes" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "description" text NOT NULL, + "category" text NOT NULL, + "created_at" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3) +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "events" ( + "title" text NOT NULL, + "image" text NOT NULL, + "restaurant_id" text NOT NULL, + "description" text NOT NULL, + "date" date NOT NULL, + "createdAt" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3), + CONSTRAINT "events_title_restaurant_id_date_pk" PRIMARY KEY("title","restaurant_id","date") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "menus" ( + "id" text PRIMARY KEY NOT NULL, + "date" date NOT NULL, + "restaurantId" text NOT NULL, + "created_at" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3), + "start" timestamp(3) NOT NULL, + "end" timestamp(3) NOT NULL, + "price" text NOT NULL, + "period" "period" NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "nutrition_info" ( + "dish_id" text PRIMARY KEY NOT NULL, + "created_at" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3), + "serving_size" text, + "serving_unit" text, + "calories" text, + "calories_from_fat" text, + "total_fat_g" text, + "trans_fat_g" text, + "saturated_fat_g" text, + "cholesterol_mg" text, + "sodium_mg" text, + "total_carbs_g" text, + "dietary_fiber_g" text, + "sugars_mg" text, + "protein_g" text, + "vitamin_a_iu" text, + "vitamin_c_iu" text, + "calcium_mg" text, + "iron_mg" text +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "push_token" ( + "token" text PRIMARY KEY NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "restaurants" ( + "id" text PRIMARY KEY NOT NULL, + "name" text NOT NULL, + "created_at" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3), + CONSTRAINT "restaurants_name_unique" UNIQUE("name") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "stations" ( + "id" text PRIMARY KEY NOT NULL, + "createdAt" timestamp(3) DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT CURRENT_TIMESTAMP(3), + "name" text NOT NULL, + "restaurantId" text NOT NULL +); +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "diet_restrictions" ADD CONSTRAINT "diet_restrictions_dish_id_dishes_id_fk" FOREIGN KEY ("dish_id") REFERENCES "dishes"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "dish_menu_station_joint" ADD CONSTRAINT "dish_menu_station_joint_dish_id_dishes_id_fk" FOREIGN KEY ("dish_id") REFERENCES "dishes"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "dish_menu_station_joint" ADD CONSTRAINT "dish_menu_station_joint_menu_id_menus_id_fk" FOREIGN KEY ("menu_id") REFERENCES "menus"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "dish_menu_station_joint" ADD CONSTRAINT "dish_menu_station_joint_station_id_stations_id_fk" FOREIGN KEY ("station_id") REFERENCES "stations"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "menus" ADD CONSTRAINT "menus_restaurantId_restaurants_id_fk" FOREIGN KEY ("restaurantId") REFERENCES "restaurants"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "nutrition_info" ADD CONSTRAINT "nutrition_info_dish_id_dishes_id_fk" FOREIGN KEY ("dish_id") REFERENCES "dishes"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "stations" ADD CONSTRAINT "stations_restaurantId_restaurants_id_fk" FOREIGN KEY ("restaurantId") REFERENCES "restaurants"("id") ON DELETE restrict ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/packages/db/testMigrations/meta/0000_snapshot.json b/packages/db/testMigrations/meta/0000_snapshot.json new file mode 100644 index 00000000..5e15c6d6 --- /dev/null +++ b/packages/db/testMigrations/meta/0000_snapshot.json @@ -0,0 +1,696 @@ +{ + "id": "715ed03c-70e3-4d2b-9dd0-00ee70b386ac", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "5", + "dialect": "pg", + "tables": { + "diet_restrictions": { + "name": "diet_restrictions", + "schema": "", + "columns": { + "dish_id": { + "name": "dish_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + }, + "contains_eggs": { + "name": "contains_eggs", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_fish": { + "name": "contains_fish", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_milk": { + "name": "contains_milk", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_peanuts": { + "name": "contains_peanuts", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_sesame": { + "name": "contains_sesame", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_shellfish": { + "name": "contains_shellfish", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_soy": { + "name": "contains_soy", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_tree_nuts": { + "name": "contains_tree_nuts", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "contains_wheat": { + "name": "contains_wheat", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_gluten_free": { + "name": "is_gluten_free", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_halal": { + "name": "is_halal", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_kosher": { + "name": "is_kosher", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_locally_grown": { + "name": "is_locally_grown", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_organic": { + "name": "is_organic", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_vegan": { + "name": "is_vegan", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "is_vegetarian": { + "name": "is_vegetarian", + "type": "boolean", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "diet_restrictions_dish_id_dishes_id_fk": { + "name": "diet_restrictions_dish_id_dishes_id_fk", + "tableFrom": "diet_restrictions", + "tableTo": "dishes", + "columnsFrom": [ + "dish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "dish_menu_station_joint": { + "name": "dish_menu_station_joint", + "schema": "", + "columns": { + "dish_id": { + "name": "dish_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "menu_id": { + "name": "menu_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "station_id": { + "name": "station_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "dish_menu_station_joint_dish_id_dishes_id_fk": { + "name": "dish_menu_station_joint_dish_id_dishes_id_fk", + "tableFrom": "dish_menu_station_joint", + "tableTo": "dishes", + "columnsFrom": [ + "dish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + }, + "dish_menu_station_joint_menu_id_menus_id_fk": { + "name": "dish_menu_station_joint_menu_id_menus_id_fk", + "tableFrom": "dish_menu_station_joint", + "tableTo": "menus", + "columnsFrom": [ + "menu_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + }, + "dish_menu_station_joint_station_id_stations_id_fk": { + "name": "dish_menu_station_joint_station_id_stations_id_fk", + "tableFrom": "dish_menu_station_joint", + "tableTo": "stations", + "columnsFrom": [ + "station_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": { + "dish_menu_station_joint_dish_id_menu_id_station_id_pk": { + "name": "dish_menu_station_joint_dish_id_menu_id_station_id_pk", + "columns": [ + "dish_id", + "menu_id", + "station_id" + ] + } + }, + "uniqueConstraints": {} + }, + "dishes": { + "name": "dishes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "events": { + "name": "events", + "schema": "", + "columns": { + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "restaurant_id": { + "name": "restaurant_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "events_title_restaurant_id_date_pk": { + "name": "events_title_restaurant_id_date_pk", + "columns": [ + "title", + "restaurant_id", + "date" + ] + } + }, + "uniqueConstraints": {} + }, + "menus": { + "name": "menus", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "date": { + "name": "date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "restaurantId": { + "name": "restaurantId", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + }, + "start": { + "name": "start", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true + }, + "end": { + "name": "end", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "period": { + "name": "period", + "type": "period", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "menus_restaurantId_restaurants_id_fk": { + "name": "menus_restaurantId_restaurants_id_fk", + "tableFrom": "menus", + "tableTo": "restaurants", + "columnsFrom": [ + "restaurantId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "nutrition_info": { + "name": "nutrition_info", + "schema": "", + "columns": { + "dish_id": { + "name": "dish_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + }, + "serving_size": { + "name": "serving_size", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "serving_unit": { + "name": "serving_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calories": { + "name": "calories", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calories_from_fat": { + "name": "calories_from_fat", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_fat_g": { + "name": "total_fat_g", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trans_fat_g": { + "name": "trans_fat_g", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "saturated_fat_g": { + "name": "saturated_fat_g", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cholesterol_mg": { + "name": "cholesterol_mg", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sodium_mg": { + "name": "sodium_mg", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_carbs_g": { + "name": "total_carbs_g", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dietary_fiber_g": { + "name": "dietary_fiber_g", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sugars_mg": { + "name": "sugars_mg", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "protein_g": { + "name": "protein_g", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vitamin_a_iu": { + "name": "vitamin_a_iu", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vitamin_c_iu": { + "name": "vitamin_c_iu", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "calcium_mg": { + "name": "calcium_mg", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "iron_mg": { + "name": "iron_mg", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "nutrition_info_dish_id_dishes_id_fk": { + "name": "nutrition_info_dish_id_dishes_id_fk", + "tableFrom": "nutrition_info", + "tableTo": "dishes", + "columnsFrom": [ + "dish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "push_token": { + "name": "push_token", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "restaurants": { + "name": "restaurants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "restaurants_name_unique": { + "name": "restaurants_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + } + }, + "stations": { + "name": "stations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "createdAt": { + "name": "createdAt", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP(3)" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "restaurantId": { + "name": "restaurantId", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "stations_restaurantId_restaurants_id_fk": { + "name": "stations_restaurantId_restaurants_id_fk", + "tableFrom": "stations", + "tableTo": "restaurants", + "columnsFrom": [ + "restaurantId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "period": { + "name": "period", + "values": { + "latenight": "latenight", + "dinner": "dinner", + "lunch": "lunch", + "brunch": "brunch", + "breakfast": "breakfast" + } + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/testMigrations/meta/_journal.json b/packages/db/testMigrations/meta/_journal.json new file mode 100644 index 00000000..a77cb7d5 --- /dev/null +++ b/packages/db/testMigrations/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "5", + "dialect": "pg", + "entries": [ + { + "idx": 0, + "version": "5", + "when": 1714291292863, + "tag": "0000_nostalgic_earthquake", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/packages/utils/package.json b/packages/utils/package.json index b09eec72..459db4b2 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -10,6 +10,7 @@ } }, "license": "MIT", + "main": "./src/index.ts", "scripts": { "clean": "rm -rf .turbo node_modules", "format": "prettier --check . --ignore-path ../../.gitignore",