commit 524acbd1a6b3a2b717d7defabe42053cf89a7b0a Author: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Sat Jan 24 00:13:15 2026 +0530 enh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7e612e --- /dev/null +++ b/.gitignore @@ -0,0 +1,133 @@ +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +# .env +# .env.development.local +# .env.test.local +# .env.production.local +# .env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + + diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..db916fa --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,52 @@ +# Agent Instructions for Meat Farmer Monorepo + +## Important instructions +- Don't try to build the code or run or compile it. Just make changes and leave the rest for the user. +- Don't run any drizzle migrations. User will handle it. + +## Code Style Guidelines + +### TypeScript & React Native +- **Strict TypeScript**: `strict: true` enabled in tsconfig +- **Path aliases**: Use `@/*` for local imports, `common-ui` for shared UI package +- **Component naming**: PascalCase (e.g., `MyButton`, `ImageCarousel`) +- **Function naming**: camelCase (e.g., `handleSubmit`, `getCurrentUserId`) +- **Interface naming**: PascalCase with `Props` suffix (e.g., `ButtonProps`) + +don't import Text,TextInput,TouchableOpacity and other such primitive components directly from +react-native. They are available in the common-ui as MyText, MyTextInput, MyTouchableOpacity etc. + +### Imports +- React imports first +- Third-party libraries second +- Local imports last +- Use absolute imports with path aliases when possible +- imports from /packages/ui are aliased as `common-ui` in apps/user-ui and apps/admin-ui + +### Error Handling +- API errors handled via axios interceptors +- Use `DeviceEventEmitter` for cross-component communication +- Throw custom errors with descriptive messages +- Avoid try-catch blocks unless necessary + +### Formatting & Linting +- ESLint with Expo config +- No Prettier configured - follow consistent indentation (2 spaces) +- No semicolons at end of statements +- Single quotes for strings + +### Testing +- No test framework currently configured +- When adding tests, use Jest + React Native Testing Library +- Test files: `*.test.tsx` or `*.spec.tsx` + +### Architecture +- Monorepo with Turbo +- Shared UI components in `packages/ui` +- Apps: `user-ui`, `admin-ui`, `inspiration-ui`, `inspiration-backend` +- Database: Drizzle ORM with PostgreSQL + +## Important Notes +- **Do not run build, compile, or migration commands** - These should be handled manually by developers +- Avoid running `npm run build`, `tsc`, `drizzle-kit generate`, or similar compilation/migration commands +- Don't do anything with git. Don't do git add or git commit. That will be managed entirely by the user \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6fe5cf1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# Optimized Dockerfile for backend and fallback-ui services (project root) + +# 1. ---- Base Node image +FROM node:20-slim AS base +WORKDIR /app + +# 2. ---- Pruner ---- +FROM base AS pruner +WORKDIR /app +# Copy config files first for better caching +COPY package.json package-lock.json turbo.json ./ +COPY apps/backend/package.json ./apps/backend/ +COPY apps/fallback-ui/package.json ./apps/fallback-ui/ +COPY packages/ui/package.json ./packages/ui/ +RUN npm install -g turbo +COPY . . +RUN turbo prune --scope=backend --scope=fallback-ui --scope=common-ui --docker + +# 3. ---- Builder ---- +FROM base AS builder +WORKDIR /app +# Copy package files first to cache npm install +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/package-lock.json ./package-lock.json +COPY --from=pruner /app/turbo.json . +RUN npm ci +# Copy source code after dependencies are installed +COPY --from=pruner /app/out/full/ . +RUN npx turbo run build --filter=fallback-ui... --filter=backend... + +# 4. ---- Runner ---- +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production +# Copy package files and install production deps +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/package-lock.json ./package-lock.json +RUN npm ci --production --omit=dev +# Copy built applications +COPY --from=builder /app/apps/backend/dist ./apps/backend/dist +COPY --from=builder /app/apps/fallback-ui/dist ./apps/fallback-ui/dist +EXPOSE 4000 +RUN npm i -g bun +CMD ["bun", "apps/backend/dist/index.js"] +# CMD ["node", "apps/backend/dist/index.js"] \ No newline at end of file diff --git a/Dockerfile.txt b/Dockerfile.txt new file mode 100644 index 0000000..4c1c879 --- /dev/null +++ b/Dockerfile.txt @@ -0,0 +1,34 @@ +# Dockerfile for backend service (project root) + +# 1. ---- Base Node image +FROM node:20-slim AS base +WORKDIR /app + +# 2. ---- Pruner ---- +FROM base AS pruner +WORKDIR /app +RUN npm install -g turbo +COPY . . +RUN turbo prune --scope=backend --scope=fallback-ui --scope=common-ui --docker + +# 3. ---- Builder ---- +FROM base AS builder +WORKDIR /app +COPY --from=pruner /app/out/full/ . +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/package-lock.json ./package-lock.json +COPY --from=pruner /app/turbo.json . +RUN npm install +RUN npx turbo run build --filter=fallback-ui... --filter=backend... + +# 4. ---- Runner ---- +FROM base AS runner +WORKDIR /app +ENV NODE_ENV=production +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/package-lock.json ./package-lock.json +RUN npm ci --production +COPY --from=builder /app/apps/backend/dist ./apps/backend/dist +COPY --from=builder /app/apps/fallback-ui/dist ./apps/fallback-ui/dist +EXPOSE 4000 +CMD ["node", "apps/backend/dist/index.js"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b9c3bba --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 shafi + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100755 index 0000000..6909884 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +.env file structure +DATABASE_URL=**** +PHONE_PE_BASE_URL=https://api-preprod.phonepe.com/ +PHONE_PE_CLIENT_ID=**** +PHONE_PE_CLIENT_VERSION=1 +PHONE_PE_CLIENT_SECRET=**** +PHONE_PE_MERCHANT_ID=**** +S3_REGION=**** +S3_ACCESS_KEY_ID=**** +S3_SECRET_ACCESS_KEY=**** +S3_URL=**** +S3_BUCKET_NAME=**** +EXPO_ACCESS_TOKEN=**** + + +also add google-services.json and firebase sdk files to ui folder to run notif functionality diff --git a/app.json b/app.json new file mode 100644 index 0000000..c9e8c8a --- /dev/null +++ b/app.json @@ -0,0 +1,3 @@ +{ + "expo": {} +} \ No newline at end of file diff --git a/apps/admin-ui/.expo/README.md b/apps/admin-ui/.expo/README.md new file mode 100644 index 0000000..f7eb5fe --- /dev/null +++ b/apps/admin-ui/.expo/README.md @@ -0,0 +1,8 @@ +> Why do I have a folder named ".expo" in my project? +The ".expo" folder is created when an Expo project is started using "expo start" command. +> What do the files contain? +- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds. +- "settings.json": contains the server configuration that is used to serve the application manifest. +> Should I commit the ".expo" folder? +No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine. +Upon project creation, the ".expo" folder is already added to your ".gitignore" file. diff --git a/apps/admin-ui/.expo/cache/eslint/.cache_1wqyakh b/apps/admin-ui/.expo/cache/eslint/.cache_1wqyakh new file mode 100644 index 0000000..1379236 --- /dev/null +++ b/apps/admin-ui/.expo/cache/eslint/.cache_1wqyakh @@ -0,0 +1 @@ +[{"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/api-hooks/product.api.ts":"1","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/api-hooks/tag.api.ts":"2","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/CouponForm.tsx":"3","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/ProductForm.tsx":"4","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/TagForm.tsx":"5","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/TagMenu.tsx":"6","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/trpc-client.ts":"7","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/_layout.tsx":"8","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-product/_layout.tsx":"9","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-product/index.tsx":"10","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-slot/_layout.tsx":"11","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-slot/index.tsx":"12","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-store/_layout.tsx":"13","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-store/index.tsx":"14","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-tag/_layout.tsx":"15","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-tag/index.tsx":"16","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/address-management/index.tsx":"17","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/complaints/_layout.tsx":"18","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/complaints/index.tsx":"19","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/coupons/_layout.tsx":"20","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/coupons/index.tsx":"21","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/create-coupon/_layout.tsx":"22","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/create-coupon/index.tsx":"23","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard/_layout.tsx":"24","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard/index.tsx":"25","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/delivery-sequences/_layout.tsx":"26","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/delivery-sequences/index.tsx":"27","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-coupon/[id]/index.tsx":"28","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-product/_layout.tsx":"29","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-product/index.tsx":"30","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-slot/[id]/index.tsx":"31","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-slot/_layout.tsx":"32","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-store/_layout.tsx":"33","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-store/index.tsx":"34","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-tag/_layout.tsx":"35","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-tag/index.tsx":"36","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/manage-orders/_layout.tsx":"37","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/manage-orders/index.tsx":"38","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/order-details/[id].tsx":"39","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/order-details/_layout.tsx":"40","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/orders/_layout.tsx":"41","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/orders/index.tsx":"42","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-detail/[id].tsx":"43","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-detail/_layout.tsx":"44","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-tags/_layout.tsx":"45","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-tags/index.tsx":"46","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/products/_layout.tsx":"47","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/products/index.tsx":"48","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/slots/_layout.tsx":"49","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/slots/index.tsx":"50","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/stores/_layout.tsx":"51","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/stores/index.tsx":"52","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/user-details/[id]/index.tsx":"53","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/users/index.tsx":"54","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/vendor-snippets/_layout.tsx":"55","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/vendor-snippets/index.tsx":"56","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/_layout.tsx":"57","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/index.tsx":"58","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/login.tsx":"59","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/AddressPlaceForm.tsx":"60","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/AddressZoneForm.tsx":"61","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/FullOrderView.tsx":"62","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/HorizontalImageScroller.tsx":"63","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/OrderNotesForm.tsx":"64","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/SlotForm.tsx":"65","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/SnippetMenu.tsx":"66","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/SnippetOrdersView.tsx":"67","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/StoreForm.tsx":"68","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/TabNavigation.tsx":"69","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/VendorSnippetForm.tsx":"70","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/app-container.tsx":"71","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/context/auth-context.tsx":"72","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/context/roles-context.tsx":"73","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/context/staff-auth-context.tsx":"74","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/dashboard-header.tsx":"75","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/date-time-picker.tsx":"76","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/day-account-view.tsx":"77","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/IconSymbol.ios.tsx":"78","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/IconSymbol.tsx":"79","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/TabBarBackground.ios.tsx":"80","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/TabBarBackground.tsx":"81","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/create-product-group.tsx":"82","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-product-group/[id].tsx":"83","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-groupings/_layout.tsx":"84","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-groupings/index.tsx":"85","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/slots/slot-details.tsx":"86","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ProductGroupForm.tsx":"87","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/api-hooks/banner.api.ts":"88","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/_layout.tsx":"89","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/_layout.tsx":"90","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/index.tsx":"91","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/index.tsx":"92","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/[id].tsx":"93","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/_layout.tsx":"94","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/BannerForm.tsx":"95","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/prices-overview/_layout.tsx":"96","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/prices-overview/index.tsx":"97","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/rebalance-orders/_layout.tsx":"98","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/rebalance-orders/index.tsx":"99","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/coupons/reserved-coupons/index.tsx":"100","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/customize-app/_layout.tsx":"101","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/customize-app/index.tsx":"102","/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/customize-app/popular-items.tsx":"103"},{"size":2498,"mtime":1768400165146,"results":"104","hashOfConfig":"105"},{"size":2703,"mtime":1763796305041,"results":"106","hashOfConfig":"105"},{"size":15378,"mtime":1768478021727,"results":"107","hashOfConfig":"105"},{"size":14468,"mtime":1768477648553,"results":"108","hashOfConfig":"105"},{"size":4623,"mtime":1766317749748,"results":"109","hashOfConfig":"105"},{"size":3110,"mtime":1763795789564,"results":"110","hashOfConfig":"105"},{"size":1337,"mtime":1762599434312,"results":"111","hashOfConfig":"105"},{"size":8796,"mtime":1767634707805,"results":"112","hashOfConfig":"105"},{"size":257,"mtime":1762599434197,"results":"113","hashOfConfig":"105"},{"size":2615,"mtime":1768477691699,"results":"114","hashOfConfig":"105"},{"size":222,"mtime":1764190176636,"results":"115","hashOfConfig":"105"},{"size":554,"mtime":1764189907122,"results":"116","hashOfConfig":"105"},{"size":223,"mtime":1763059388593,"results":"117","hashOfConfig":"105"},{"size":1209,"mtime":1766289701319,"results":"118","hashOfConfig":"105"},{"size":253,"mtime":1763797137184,"results":"119","hashOfConfig":"105"},{"size":2021,"mtime":1763797248106,"results":"120","hashOfConfig":"105"},{"size":3945,"mtime":1767174865620,"results":"121","hashOfConfig":"105"},{"size":224,"mtime":1762599434200,"results":"122","hashOfConfig":"105"},{"size":5507,"mtime":1764438946177,"results":"123","hashOfConfig":"105"},{"size":253,"mtime":1767802221050,"results":"124","hashOfConfig":"105"},{"size":18870,"mtime":1767807975320,"results":"125","hashOfConfig":"105"},{"size":208,"mtime":1763924530767,"results":"126","hashOfConfig":"105"},{"size":1692,"mtime":1767791079484,"results":"127","hashOfConfig":"105"},{"size":255,"mtime":1762599434205,"results":"128","hashOfConfig":"105"},{"size":7781,"mtime":1768452505130,"results":"129","hashOfConfig":"105"},{"size":232,"mtime":1762599434206,"results":"130","hashOfConfig":"105"},{"size":32518,"mtime":1767426716492,"results":"131","hashOfConfig":"105"},{"size":2862,"mtime":1767791455131,"results":"132","hashOfConfig":"105"},{"size":258,"mtime":1762599434210,"results":"133","hashOfConfig":"105"},{"size":5195,"mtime":1768477730302,"results":"134","hashOfConfig":"105"},{"size":1507,"mtime":1764189564896,"results":"135","hashOfConfig":"105"},{"size":222,"mtime":1764190176942,"results":"136","hashOfConfig":"105"},{"size":224,"mtime":1763060554500,"results":"137","hashOfConfig":"105"},{"size":2143,"mtime":1766289690360,"results":"138","hashOfConfig":"105"},{"size":254,"mtime":1763797142709,"results":"139","hashOfConfig":"105"},{"size":3016,"mtime":1763798631329,"results":"140","hashOfConfig":"105"},{"size":227,"mtime":1762599434212,"results":"141","hashOfConfig":"105"},{"size":2908,"mtime":1768287610431,"results":"142","hashOfConfig":"105"},{"size":34634,"mtime":1768287610431,"results":"143","hashOfConfig":"105"},{"size":258,"mtime":1764241729339,"results":"144","hashOfConfig":"105"},{"size":220,"mtime":1764307866014,"results":"145","hashOfConfig":"105"},{"size":30720,"mtime":1768287610432,"results":"146","hashOfConfig":"105"},{"size":24820,"mtime":1767151476546,"results":"147","hashOfConfig":"105"},{"size":227,"mtime":1762599434217,"results":"148","hashOfConfig":"105"},{"size":258,"mtime":1763798895678,"results":"149","hashOfConfig":"105"},{"size":4519,"mtime":1768502509021,"results":"150","hashOfConfig":"105"},{"size":222,"mtime":1762599434225,"results":"151","hashOfConfig":"105"},{"size":10823,"mtime":1768415636310,"results":"152","hashOfConfig":"105"},{"size":298,"mtime":1766897186521,"results":"153","hashOfConfig":"105"},{"size":7495,"mtime":1768452623441,"results":"154","hashOfConfig":"105"},{"size":220,"mtime":1763059003587,"results":"155","hashOfConfig":"105"},{"size":8720,"mtime":1768502477149,"results":"156","hashOfConfig":"105"},{"size":5957,"mtime":1764361113959,"results":"157","hashOfConfig":"105"},{"size":2740,"mtime":1768502547435,"results":"158","hashOfConfig":"105"},{"size":229,"mtime":1762599434236,"results":"159","hashOfConfig":"105"},{"size":10743,"mtime":1766897689489,"results":"160","hashOfConfig":"105"},{"size":972,"mtime":1764172066361,"results":"161","hashOfConfig":"105"},{"size":703,"mtime":1766301995213,"results":"162","hashOfConfig":"105"},{"size":2439,"mtime":1766003080925,"results":"163","hashOfConfig":"105"},{"size":2286,"mtime":1765396821826,"results":"164","hashOfConfig":"105"},{"size":1666,"mtime":1765394256580,"results":"165","hashOfConfig":"105"},{"size":8575,"mtime":1766317751973,"results":"166","hashOfConfig":"105"},{"size":1037,"mtime":1762599434261,"results":"167","hashOfConfig":"105"},{"size":2103,"mtime":1762599434263,"results":"168","hashOfConfig":"105"},{"size":11049,"mtime":1766895371468,"results":"169","hashOfConfig":"105"},{"size":3592,"mtime":1762599434264,"results":"170","hashOfConfig":"105"},{"size":5420,"mtime":1766318553117,"results":"171","hashOfConfig":"105"},{"size":8193,"mtime":1766290045998,"results":"172","hashOfConfig":"105"},{"size":1020,"mtime":1762599434265,"results":"173","hashOfConfig":"105"},{"size":7463,"mtime":1762680829626,"results":"174","hashOfConfig":"105"},{"size":71,"mtime":1762599434267,"results":"175","hashOfConfig":"105"},{"size":7568,"mtime":1762599434268,"results":"176","hashOfConfig":"105"},{"size":1281,"mtime":1762599434269,"results":"177","hashOfConfig":"105"},{"size":3087,"mtime":1762681291123,"results":"178","hashOfConfig":"105"},{"size":3637,"mtime":1762599434272,"results":"179","hashOfConfig":"105"},{"size":7496,"mtime":1762599434272,"results":"180","hashOfConfig":"105"},{"size":2633,"mtime":1762599434273,"results":"181","hashOfConfig":"105"},{"size":598,"mtime":1762599434274,"results":"182","hashOfConfig":"105"},{"size":1422,"mtime":1762599434274,"results":"183","hashOfConfig":"105"},{"size":547,"mtime":1762599434275,"results":"184","hashOfConfig":"105"},{"size":159,"mtime":1762599434276,"results":"185","hashOfConfig":"105"},{"size":459,"mtime":1766889746933,"results":"186","hashOfConfig":"105"},{"size":1280,"mtime":1766889754475,"results":"187","hashOfConfig":"105"},{"size":231,"mtime":1766889670975,"results":"188","hashOfConfig":"105"},{"size":7403,"mtime":1767239712753,"results":"189","hashOfConfig":"105"},{"size":10642,"mtime":1767240859155,"results":"190","hashOfConfig":"105"},{"size":4840,"mtime":1766890421736,"results":"191","hashOfConfig":"105"},{"size":512,"mtime":1767163680847,"results":"192","hashOfConfig":"105"},{"size":389,"mtime":1767163849126,"results":"193","hashOfConfig":"105"},{"size":227,"mtime":1767163711679,"results":"194","hashOfConfig":"105"},{"size":2463,"mtime":1767178533223,"results":"195","hashOfConfig":"105"},{"size":17644,"mtime":1767178172673,"results":"196","hashOfConfig":"105"},{"size":4703,"mtime":1767179689237,"results":"197","hashOfConfig":"105"},{"size":224,"mtime":1767163855093,"results":"198","hashOfConfig":"105"},{"size":9157,"mtime":1767179690187,"results":"199","hashOfConfig":"105"},{"size":275,"mtime":1767633238728,"results":"200","hashOfConfig":"105"},{"size":14940,"mtime":1768477917852,"results":"201","hashOfConfig":"105"},{"size":277,"mtime":1767634693670,"results":"202","hashOfConfig":"105"},{"size":8964,"mtime":1768452581215,"results":"203","hashOfConfig":"105"},{"size":9844,"mtime":1767791293123,"results":"204","hashOfConfig":"105"},{"size":411,"mtime":1768412786804,"results":"205","hashOfConfig":"105"},{"size":6531,"mtime":1768452417476,"results":"206","hashOfConfig":"105"},{"size":14537,"mtime":1768413392903,"results":"207","hashOfConfig":"105"},{"filePath":"208","messages":"209","suppressedMessages":"210","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1vn1flh",{"filePath":"211","messages":"212","suppressedMessages":"213","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"214","messages":"215","suppressedMessages":"216","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"217","messages":"218","suppressedMessages":"219","errorCount":3,"fatalErrorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"220","messages":"221","suppressedMessages":"222","errorCount":2,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"223","messages":"224","suppressedMessages":"225","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"226","messages":"227","suppressedMessages":"228","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"229","messages":"230","suppressedMessages":"231","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"232","messages":"233","suppressedMessages":"234","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"235","messages":"236","suppressedMessages":"237","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"238","messages":"239","suppressedMessages":"240","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"241","messages":"242","suppressedMessages":"243","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"244","messages":"245","suppressedMessages":"246","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"247","messages":"248","suppressedMessages":"249","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"250","messages":"251","suppressedMessages":"252","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"253","messages":"254","suppressedMessages":"255","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"256","messages":"257","suppressedMessages":"258","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"259","messages":"260","suppressedMessages":"261","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"262","messages":"263","suppressedMessages":"264","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"265","messages":"266","suppressedMessages":"267","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"268","messages":"269","suppressedMessages":"270","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"271","messages":"272","suppressedMessages":"273","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"274","messages":"275","suppressedMessages":"276","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"277","messages":"278","suppressedMessages":"279","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"280","messages":"281","suppressedMessages":"282","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"283","messages":"284","suppressedMessages":"285","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"286","messages":"287","suppressedMessages":"288","errorCount":0,"fatalErrorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"289","messages":"290","suppressedMessages":"291","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"292","messages":"293","suppressedMessages":"294","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"295","messages":"296","suppressedMessages":"297","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"298","messages":"299","suppressedMessages":"300","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"301","messages":"302","suppressedMessages":"303","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"304","messages":"305","suppressedMessages":"306","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"307","messages":"308","suppressedMessages":"309","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"310","messages":"311","suppressedMessages":"312","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"313","messages":"314","suppressedMessages":"315","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"316","messages":"317","suppressedMessages":"318","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"319","messages":"320","suppressedMessages":"321","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"322","messages":"323","suppressedMessages":"324","errorCount":0,"fatalErrorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"325","messages":"326","suppressedMessages":"327","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"328","messages":"329","suppressedMessages":"330","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"331","messages":"332","suppressedMessages":"333","errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"334","messages":"335","suppressedMessages":"336","errorCount":0,"fatalErrorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"337","messages":"338","suppressedMessages":"339","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"340","messages":"341","suppressedMessages":"342","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"343","messages":"344","suppressedMessages":"345","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"346","messages":"347","suppressedMessages":"348","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"349","messages":"350","suppressedMessages":"351","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"352","messages":"353","suppressedMessages":"354","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"355","messages":"356","suppressedMessages":"357","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"358","messages":"359","suppressedMessages":"360","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"361","messages":"362","suppressedMessages":"363","errorCount":1,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"364","messages":"365","suppressedMessages":"366","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"367","messages":"368","suppressedMessages":"369","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"370","messages":"371","suppressedMessages":"372","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"373","messages":"374","suppressedMessages":"375","errorCount":0,"fatalErrorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"376","messages":"377","suppressedMessages":"378","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"379","messages":"380","suppressedMessages":"381","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"382","messages":"383","suppressedMessages":"384","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"385","messages":"386","suppressedMessages":"387","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"388","messages":"389","suppressedMessages":"390","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"391","messages":"392","suppressedMessages":"393","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"394","messages":"395","suppressedMessages":"396","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"397","messages":"398","suppressedMessages":"399","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"400","messages":"401","suppressedMessages":"402","errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"403","messages":"404","suppressedMessages":"405","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"406","messages":"407","suppressedMessages":"408","errorCount":5,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"409","messages":"410","suppressedMessages":"411","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"412","messages":"413","suppressedMessages":"414","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"415","messages":"416","suppressedMessages":"417","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"418","messages":"419","suppressedMessages":"420","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"421","messages":"422","suppressedMessages":"423","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"424","messages":"425","suppressedMessages":"426","errorCount":0,"fatalErrorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"427","messages":"428","suppressedMessages":"429","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"430","messages":"431","suppressedMessages":"432","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"433","messages":"434","suppressedMessages":"435","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"436","messages":"437","suppressedMessages":"438","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"439","messages":"440","suppressedMessages":"441","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"442","messages":"443","suppressedMessages":"444","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"445","messages":"446","suppressedMessages":"447","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"448","messages":"449","suppressedMessages":"450","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"451","messages":"452","suppressedMessages":"453","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"454","messages":"455","suppressedMessages":"456","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"457","messages":"458","suppressedMessages":"459","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"460","messages":"461","suppressedMessages":"462","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"463","messages":"464","suppressedMessages":"465","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"466","messages":"467","suppressedMessages":"468","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"469","messages":"470","suppressedMessages":"471","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"472","messages":"473","suppressedMessages":"474","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"475","messages":"476","suppressedMessages":"477","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"478","messages":"479","suppressedMessages":"480","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"481","messages":"482","suppressedMessages":"483","errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"484","messages":"485","suppressedMessages":"486","errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"487","messages":"488","suppressedMessages":"489","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"490","messages":"491","suppressedMessages":"492","errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"493","messages":"494","suppressedMessages":"495","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"496","messages":"497","suppressedMessages":"498","errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"499","messages":"500","suppressedMessages":"501","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"502","messages":"503","suppressedMessages":"504","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"505","messages":"506","suppressedMessages":"507","errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"508","messages":"509","suppressedMessages":"510","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"511","messages":"512","suppressedMessages":"513","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"514","messages":"515","suppressedMessages":"516","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/api-hooks/product.api.ts",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/api-hooks/tag.api.ts",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/CouponForm.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/ProductForm.tsx",["517","518","519","520","521","522","523","524","525"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/TagForm.tsx",["526","527","528","529","530"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/components/TagMenu.tsx",["531"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/trpc-client.ts",["532"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/_layout.tsx",["533","534"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-product/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-product/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-slot/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-slot/index.tsx",["535"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-store/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-store/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-tag/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/add-tag/index.tsx",["536"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/address-management/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/complaints/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/complaints/index.tsx",["537"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/coupons/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/coupons/index.tsx",["538","539"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/create-coupon/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/create-coupon/index.tsx",["540","541"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard/index.tsx",["542"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/delivery-sequences/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/delivery-sequences/index.tsx",["543","544","545","546","547","548","549"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-coupon/[id]/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-product/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-product/index.tsx",["550"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-slot/[id]/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-slot/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-store/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-store/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-tag/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-tag/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/manage-orders/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/manage-orders/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/order-details/[id].tsx",["551","552","553","554","555"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/order-details/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/orders/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/orders/index.tsx",["556","557","558"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-detail/[id].tsx",["559","560","561","562","563","564","565","566"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-detail/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-tags/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-tags/index.tsx",["567"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/products/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/products/index.tsx",["568","569"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/slots/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/slots/index.tsx",["570"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/stores/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/stores/index.tsx",["571","572","573"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/user-details/[id]/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/users/index.tsx",["574"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/vendor-snippets/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/vendor-snippets/index.tsx",["575","576","577","578","579","580"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/login.tsx",["581","582"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/AddressPlaceForm.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/AddressZoneForm.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/FullOrderView.tsx",["583","584"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/HorizontalImageScroller.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/OrderNotesForm.tsx",["585","586"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/SlotForm.tsx",["587","588","589"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/SnippetMenu.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/SnippetOrdersView.tsx",["590","591","592","593","594"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/StoreForm.tsx",["595"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/TabNavigation.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/VendorSnippetForm.tsx",["596","597"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/app-container.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/context/auth-context.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/context/roles-context.tsx",["598","599","600","601","602"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/context/staff-auth-context.tsx",["603","604"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/dashboard-header.tsx",["605"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/date-time-picker.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/day-account-view.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/IconSymbol.ios.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/IconSymbol.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/TabBarBackground.ios.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ui/TabBarBackground.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/create-product-group.tsx",["606"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/edit-product-group/[id].tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-groupings/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/product-groupings/index.tsx",["607","608"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/slots/slot-details.tsx",["609"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/ProductGroupForm.tsx",["610"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/src/api-hooks/banner.api.ts",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/index.tsx",["611","612"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/index.tsx",["613","614","615","616"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/[id].tsx",["617","618","619","620"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/components/BannerForm.tsx",["621","622","623"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/prices-overview/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/prices-overview/index.tsx",["624","625","626","627"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/rebalance-orders/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/rebalance-orders/index.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/coupons/reserved-coupons/index.tsx",["628","629","630"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/customize-app/_layout.tsx",[],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/customize-app/index.tsx",["631"],[],"/Users/mohammedshafiuddin/WebDev/freshyo/apps/admin-ui/app/(drawer)/customize-app/popular-items.tsx",["632","633"],[],{"ruleId":"634","severity":1,"message":"635","line":3,"column":10,"nodeType":null,"messageId":"636","endLine":3,"endColumn":15},{"ruleId":"634","severity":1,"message":"637","line":4,"column":18,"nodeType":null,"messageId":"636","endLine":4,"endColumn":28},{"ruleId":"634","severity":1,"message":"638","line":5,"column":13,"nodeType":null,"messageId":"636","endLine":5,"endColumn":16},{"ruleId":"634","severity":1,"message":"639","line":6,"column":96,"nodeType":null,"messageId":"636","endLine":6,"endColumn":106},{"ruleId":"634","severity":1,"message":"640","line":8,"column":8,"nodeType":null,"messageId":"636","endLine":8,"endColumn":21},{"ruleId":"634","severity":1,"message":"641","line":62,"column":11,"nodeType":null,"messageId":"636","endLine":62,"endColumn":16},{"ruleId":"642","severity":2,"message":"643","line":101,"column":27,"nodeType":"644","endLine":101,"endColumn":38},{"ruleId":"642","severity":2,"message":"645","line":107,"column":9,"nodeType":"644","endLine":107,"endColumn":25},{"ruleId":"642","severity":2,"message":"646","line":110,"column":9,"nodeType":"644","endLine":110,"endColumn":28},{"ruleId":"634","severity":1,"message":"635","line":3,"column":10,"nodeType":null,"messageId":"636","endLine":3,"endColumn":15},{"ruleId":"634","severity":1,"message":"640","line":8,"column":8,"nodeType":null,"messageId":"636","endLine":8,"endColumn":21},{"ruleId":"647","severity":1,"message":"648","line":38,"column":6,"nodeType":"649","endLine":38,"endColumn":36,"suggestions":"650"},{"ruleId":"642","severity":2,"message":"643","line":67,"column":27,"nodeType":"644","endLine":67,"endColumn":38},{"ruleId":"642","severity":2,"message":"645","line":74,"column":9,"nodeType":"644","endLine":74,"endColumn":25},{"ruleId":"634","severity":1,"message":"651","line":25,"column":41,"nodeType":null,"messageId":"636","endLine":25,"endColumn":51},{"ruleId":"634","severity":1,"message":"652","line":1,"column":48,"nodeType":null,"messageId":"636","endLine":1,"endColumn":63},{"ruleId":"634","severity":1,"message":"653","line":4,"column":10,"nodeType":null,"messageId":"636","endLine":4,"endColumn":23},{"ruleId":"634","severity":1,"message":"654","line":4,"column":25,"nodeType":null,"messageId":"636","endLine":4,"endColumn":38},{"ruleId":"634","severity":1,"message":"655","line":2,"column":10,"nodeType":null,"messageId":"636","endLine":2,"endColumn":14},{"ruleId":"634","severity":1,"message":"656","line":4,"column":24,"nodeType":null,"messageId":"636","endLine":4,"endColumn":30},{"ruleId":"634","severity":1,"message":"657","line":2,"column":16,"nodeType":null,"messageId":"636","endLine":2,"endColumn":20},{"ruleId":"634","severity":1,"message":"658","line":199,"column":9,"nodeType":null,"messageId":"636","endLine":199,"endColumn":15},{"ruleId":"634","severity":1,"message":"658","line":346,"column":9,"nodeType":null,"messageId":"636","endLine":346,"endColumn":15},{"ruleId":"634","severity":1,"message":"655","line":2,"column":10,"nodeType":null,"messageId":"636","endLine":2,"endColumn":14},{"ruleId":"634","severity":1,"message":"659","line":3,"column":10,"nodeType":null,"messageId":"636","endLine":3,"endColumn":12},{"ruleId":"634","severity":1,"message":"660","line":6,"column":10,"nodeType":null,"messageId":"636","endLine":6,"endColumn":24},{"ruleId":"634","severity":1,"message":"661","line":10,"column":3,"nodeType":null,"messageId":"636","endLine":10,"endColumn":19},{"ruleId":"634","severity":1,"message":"662","line":14,"column":3,"nodeType":null,"messageId":"636","endLine":14,"endColumn":15},{"ruleId":"634","severity":1,"message":"663","line":23,"column":10,"nodeType":null,"messageId":"636","endLine":23,"endColumn":24},{"ruleId":"647","severity":1,"message":"664","line":371,"column":6,"nodeType":"649","endLine":371,"endColumn":48,"suggestions":"665"},{"ruleId":"634","severity":1,"message":"666","line":720,"column":24,"nodeType":null,"messageId":"636","endLine":720,"endColumn":29},{"ruleId":"634","severity":1,"message":"666","line":765,"column":24,"nodeType":null,"messageId":"636","endLine":765,"endColumn":29},{"ruleId":"634","severity":1,"message":"666","line":825,"column":24,"nodeType":null,"messageId":"636","endLine":825,"endColumn":29},{"ruleId":"634","severity":1,"message":"657","line":2,"column":16,"nodeType":null,"messageId":"636","endLine":2,"endColumn":20},{"ruleId":"634","severity":1,"message":"667","line":4,"column":3,"nodeType":null,"messageId":"636","endLine":4,"endColumn":13},{"ruleId":"634","severity":1,"message":"668","line":186,"column":9,"nodeType":null,"messageId":"636","endLine":186,"endColumn":26},{"ruleId":"634","severity":1,"message":"669","line":188,"column":9,"nodeType":null,"messageId":"636","endLine":188,"endColumn":26},{"ruleId":"634","severity":1,"message":"670","line":195,"column":9,"nodeType":null,"messageId":"636","endLine":195,"endColumn":27},{"ruleId":"634","severity":1,"message":"671","line":202,"column":9,"nodeType":null,"messageId":"636","endLine":202,"endColumn":28},{"ruleId":"634","severity":1,"message":"672","line":92,"column":9,"nodeType":null,"messageId":"636","endLine":92,"endColumn":11},{"ruleId":"634","severity":1,"message":"673","line":145,"column":9,"nodeType":null,"messageId":"636","endLine":145,"endColumn":23},{"ruleId":"634","severity":1,"message":"658","line":438,"column":9,"nodeType":null,"messageId":"636","endLine":438,"endColumn":15},{"ruleId":"634","severity":1,"message":"674","line":1,"column":27,"nodeType":null,"messageId":"636","endLine":1,"endColumn":36},{"ruleId":"634","severity":1,"message":"662","line":5,"column":14,"nodeType":null,"messageId":"636","endLine":5,"endColumn":26},{"ruleId":"634","severity":1,"message":"675","line":6,"column":25,"nodeType":null,"messageId":"636","endLine":6,"endColumn":37},{"ruleId":"634","severity":1,"message":"676","line":12,"column":42,"nodeType":null,"messageId":"636","endLine":12,"endColumn":58},{"ruleId":"634","severity":1,"message":"677","line":12,"column":60,"nodeType":null,"messageId":"636","endLine":12,"endColumn":74},{"ruleId":"634","severity":1,"message":"678","line":12,"column":76,"nodeType":null,"messageId":"636","endLine":12,"endColumn":86},{"ruleId":"634","severity":1,"message":"679","line":23,"column":10,"nodeType":null,"messageId":"636","endLine":23,"endColumn":23},{"ruleId":"634","severity":1,"message":"680","line":26,"column":10,"nodeType":null,"messageId":"636","endLine":26,"endColumn":20},{"ruleId":"634","severity":1,"message":"681","line":2,"column":34,"nodeType":null,"messageId":"636","endLine":2,"endColumn":39},{"ruleId":"634","severity":1,"message":"682","line":6,"column":64,"nodeType":null,"messageId":"636","endLine":6,"endColumn":75},{"ruleId":"647","severity":1,"message":"683","line":29,"column":9,"nodeType":"684","endLine":29,"endColumn":48},{"ruleId":"634","severity":1,"message":"662","line":4,"column":10,"nodeType":null,"messageId":"636","endLine":4,"endColumn":22},{"ruleId":"634","severity":1,"message":"685","line":100,"column":19,"nodeType":null,"messageId":"636","endLine":100,"endColumn":30},{"ruleId":"634","severity":1,"message":"686","line":136,"column":9,"nodeType":null,"messageId":"636","endLine":136,"endColumn":18},{"ruleId":"687","severity":2,"message":"688","line":156,"column":69,"nodeType":"689","messageId":"690","suggestions":"691"},{"ruleId":"634","severity":1,"message":"692","line":43,"column":5,"nodeType":null,"messageId":"636","endLine":43,"endColumn":14},{"ruleId":"634","severity":1,"message":"693","line":2,"column":28,"nodeType":null,"messageId":"636","endLine":2,"endColumn":44},{"ruleId":"634","severity":1,"message":"694","line":2,"column":53,"nodeType":null,"messageId":"636","endLine":2,"endColumn":63},{"ruleId":"634","severity":1,"message":"666","line":52,"column":14,"nodeType":null,"messageId":"636","endLine":52,"endColumn":19},{"ruleId":"634","severity":1,"message":"695","line":147,"column":9,"nodeType":null,"messageId":"636","endLine":147,"endColumn":22},{"ruleId":"634","severity":1,"message":"696","line":148,"column":9,"nodeType":null,"messageId":"636","endLine":148,"endColumn":22},{"ruleId":"634","severity":1,"message":"658","line":154,"column":9,"nodeType":null,"messageId":"636","endLine":154,"endColumn":15},{"ruleId":"634","severity":1,"message":"658","line":14,"column":9,"nodeType":null,"messageId":"636","endLine":14,"endColumn":15},{"ruleId":"634","severity":1,"message":"666","line":24,"column":14,"nodeType":null,"messageId":"636","endLine":24,"endColumn":19},{"ruleId":"634","severity":1,"message":"635","line":3,"column":10,"nodeType":null,"messageId":"636","endLine":3,"endColumn":15},{"ruleId":"634","severity":1,"message":"697","line":30,"column":9,"nodeType":null,"messageId":"636","endLine":30,"endColumn":20},{"ruleId":"634","severity":1,"message":"693","line":2,"column":27,"nodeType":null,"messageId":"636","endLine":2,"endColumn":43},{"ruleId":"634","severity":1,"message":"666","line":35,"column":14,"nodeType":null,"messageId":"636","endLine":35,"endColumn":19},{"ruleId":"634","severity":1,"message":"698","line":1,"column":17,"nodeType":null,"messageId":"636","endLine":1,"endColumn":25},{"ruleId":"634","severity":1,"message":"674","line":1,"column":27,"nodeType":null,"messageId":"636","endLine":1,"endColumn":36},{"ruleId":"634","severity":1,"message":"699","line":1,"column":38,"nodeType":null,"messageId":"636","endLine":1,"endColumn":45},{"ruleId":"687","severity":2,"message":"700","line":94,"column":74,"nodeType":"689","messageId":"690","suggestions":"701"},{"ruleId":"687","severity":2,"message":"700","line":94,"column":94,"nodeType":"689","messageId":"690","suggestions":"702"},{"ruleId":"687","severity":2,"message":"700","line":116,"column":78,"nodeType":"689","messageId":"690","suggestions":"703"},{"ruleId":"687","severity":2,"message":"700","line":116,"column":92,"nodeType":"689","messageId":"690","suggestions":"704"},{"ruleId":"687","severity":2,"message":"688","line":137,"column":56,"nodeType":"689","messageId":"690","suggestions":"705"},{"ruleId":"706","severity":1,"message":"707","line":17,"column":18,"nodeType":"644","messageId":"708","endLine":17,"endColumn":30,"suggestions":"709"},{"ruleId":"634","severity":1,"message":"698","line":1,"column":17,"nodeType":null,"messageId":"636","endLine":1,"endColumn":25},{"ruleId":"647","severity":1,"message":"710","line":98,"column":6,"nodeType":"649","endLine":98,"endColumn":17,"suggestions":"711"},{"ruleId":"634","severity":1,"message":"712","line":1,"column":8,"nodeType":null,"messageId":"636","endLine":1,"endColumn":13},{"ruleId":"634","severity":1,"message":"713","line":1,"column":17,"nodeType":null,"messageId":"636","endLine":1,"endColumn":30},{"ruleId":"634","severity":1,"message":"674","line":1,"column":44,"nodeType":null,"messageId":"636","endLine":1,"endColumn":53},{"ruleId":"634","severity":1,"message":"698","line":1,"column":55,"nodeType":null,"messageId":"636","endLine":1,"endColumn":63},{"ruleId":"634","severity":1,"message":"714","line":1,"column":65,"nodeType":null,"messageId":"636","endLine":1,"endColumn":74},{"ruleId":"647","severity":1,"message":"715","line":53,"column":6,"nodeType":"649","endLine":53,"endColumn":8,"suggestions":"716"},{"ruleId":"647","severity":1,"message":"717","line":91,"column":6,"nodeType":"649","endLine":91,"endColumn":8,"suggestions":"718"},{"ruleId":"647","severity":1,"message":"719","line":53,"column":6,"nodeType":"649","endLine":53,"endColumn":18,"suggestions":"720"},{"ruleId":"634","severity":1,"message":"655","line":2,"column":10,"nodeType":null,"messageId":"636","endLine":2,"endColumn":14},{"ruleId":"634","severity":1,"message":"721","line":11,"column":3,"nodeType":null,"messageId":"636","endLine":11,"endColumn":15},{"ruleId":"634","severity":1,"message":"722","line":138,"column":10,"nodeType":null,"messageId":"636","endLine":138,"endColumn":22},{"ruleId":"634","severity":1,"message":"666","line":134,"column":40,"nodeType":null,"messageId":"636","endLine":134,"endColumn":45},{"ruleId":"634","severity":1,"message":"723","line":4,"column":55,"nodeType":null,"messageId":"636","endLine":4,"endColumn":60},{"ruleId":"634","severity":1,"message":"724","line":6,"column":10,"nodeType":null,"messageId":"636","endLine":6,"endColumn":23},{"ruleId":"634","severity":1,"message":"666","line":48,"column":14,"nodeType":null,"messageId":"636","endLine":48,"endColumn":19},{"ruleId":"647","severity":1,"message":"725","line":51,"column":6,"nodeType":"649","endLine":51,"endColumn":19,"suggestions":"726"},{"ruleId":"634","severity":1,"message":"666","line":129,"column":14,"nodeType":null,"messageId":"636","endLine":129,"endColumn":19},{"ruleId":"634","severity":1,"message":"666","line":170,"column":14,"nodeType":null,"messageId":"636","endLine":170,"endColumn":19},{"ruleId":"634","severity":1,"message":"666","line":200,"column":22,"nodeType":null,"messageId":"636","endLine":200,"endColumn":27},{"ruleId":"634","severity":1,"message":"724","line":6,"column":10,"nodeType":null,"messageId":"636","endLine":6,"endColumn":23},{"ruleId":"634","severity":1,"message":"727","line":10,"column":11,"nodeType":null,"messageId":"636","endLine":10,"endColumn":17},{"ruleId":"647","severity":1,"message":"728","line":68,"column":6,"nodeType":"649","endLine":68,"endColumn":28,"suggestions":"729"},{"ruleId":"634","severity":1,"message":"666","line":109,"column":14,"nodeType":null,"messageId":"636","endLine":109,"endColumn":19},{"ruleId":"634","severity":1,"message":"693","line":2,"column":28,"nodeType":null,"messageId":"636","endLine":2,"endColumn":44},{"ruleId":"634","severity":1,"message":"724","line":3,"column":18,"nodeType":null,"messageId":"636","endLine":3,"endColumn":31},{"ruleId":"634","severity":1,"message":"640","line":9,"column":8,"nodeType":null,"messageId":"636","endLine":9,"endColumn":21},{"ruleId":"634","severity":1,"message":"662","line":13,"column":3,"nodeType":null,"messageId":"636","endLine":13,"endColumn":15},{"ruleId":"647","severity":1,"message":"730","line":169,"column":9,"nodeType":"684","endLine":169,"endColumn":42},{"ruleId":"647","severity":1,"message":"731","line":169,"column":9,"nodeType":"684","endLine":169,"endColumn":42},{"ruleId":"647","severity":1,"message":"732","line":170,"column":9,"nodeType":"684","endLine":170,"endColumn":51},{"ruleId":"634","severity":1,"message":"681","line":2,"column":34,"nodeType":null,"messageId":"636","endLine":2,"endColumn":39},{"ruleId":"634","severity":1,"message":"733","line":9,"column":10,"nodeType":null,"messageId":"636","endLine":9,"endColumn":26},{"ruleId":"647","severity":1,"message":"734","line":118,"column":9,"nodeType":"684","endLine":118,"endColumn":66},{"ruleId":"634","severity":1,"message":"667","line":2,"column":16,"nodeType":null,"messageId":"636","endLine":2,"endColumn":26},{"ruleId":"634","severity":1,"message":"699","line":1,"column":38,"nodeType":null,"messageId":"636","endLine":1,"endColumn":45},{"ruleId":"634","severity":1,"message":"661","line":10,"column":3,"nodeType":null,"messageId":"636","endLine":10,"endColumn":19},"@typescript-eslint/no-unused-vars","'Image' is defined but never used.","unusedVar","'FieldArray' is defined but never used.","'Yup' is defined but never used.","'DatePicker' is defined but never used.","'MaterialIcons' is defined but never used.","'theme' is assigned a value but never used.","react-hooks/rules-of-hooks","React Hook \"useCallback\" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.","Identifier","React Hook \"useFocusCallback\" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.","React Hook \"useImperativeHandle\" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'existingImageUrl'. Either include it or remove the dependency array. If 'setImage' needs the current value of 'existingImageUrl', you can also switch to useReducer instead of useState and read 'existingImageUrl' in the reducer.","ArrayExpression",["735"],"'isDeleting' is assigned a value but never used.","'TRPCClientError' is defined but never used.","'useNavigation' is defined but never used.","'DrawerActions' is defined but never used.","'View' is defined but never used.","'MyText' is defined but never used.","'Text' is defined but never used.","'router' is assigned a value but never used.","'tw' is defined but never used.","'LinearGradient' is defined but never used.","'RenderItemParams' is defined but never used.","'AppContainer' is defined but never used.","'useQueryClient' is defined but never used.","React Hook useMemo has missing dependencies: 'deliverySequence' and 'orders'. Either include them or remove the dependency array.",["736"],"'error' is defined but never used.","'ScrollView' is defined but never used.","'showRefundOptions' is assigned a value but never used.","'getRefundDotColor' is assigned a value but never used.","'getRefundTextColor' is assigned a value but never used.","'getRefundStatusText' is assigned a value but never used.","'id' is assigned a value but never used.","'getStatusColor' is assigned a value but never used.","'useEffect' is defined but never used.","'FontAwesome5' is defined but never used.","'useAnimatedStyle' is defined but never used.","'useSharedValue' is defined but never used.","'withSpring' is defined but never used.","'adminResponse' is assigned a value but never used.","'uploadUrls' is assigned a value but never used.","'Alert' is defined but never used.","'MyTextInput' is defined but never used.","The 'products' logical expression could make the dependencies of useMemo Hook (at line 48) change on every render. To fix this, wrap the initialization of 'products' in its own useMemo() Hook.","VariableDeclarator","'deleteStore' is assigned a value but never used.","'cardWidth' is assigned a value but never used.","react/no-unescaped-entities","`'` can be escaped with `'`, `‘`, `'`, `’`.","JSXText","unescapedEntityAlts",["737","738","739","740"],"'isLoading' is assigned a value but never used.","'TouchableOpacity' is defined but never used.","'Dimensions' is defined but never used.","'createSnippet' is assigned a value but never used.","'updateSnippet' is assigned a value but never used.","'totalAmount' is assigned a value but never used.","'useState' is defined but never used.","'useMemo' is defined but never used.","`\"` can be escaped with `"`, `“`, `"`, `”`.",["741","742","743","744"],["745","746","747","748"],["749","750","751","752"],["753","754","755","756"],["757","758","759","760"],"@typescript-eslint/no-empty-object-type","An empty interface declaration allows any non-nullish value, including literals like `0` and `\"\"`.\n- If that's what you want, disable this lint rule with an inline comment or configure the 'allowInterfaces' rule option.\n- If you want a type meaning \"any object\", you probably want `object` instead.\n- If you want a type meaning \"any value\", you probably want `unknown` instead.","noEmptyInterface",["761","762"],"React Hook useEffect has a missing dependency: 'formik'. Either include it or remove the dependency array.",["763"],"'React' is defined but never used.","'createContext' is defined but never used.","'ReactNode' is defined but never used.","React Hook useEffect has missing dependencies: 'pathname' and 'router'. Either include them or remove the dependency array.",["764"],"React Hook useEffect has a missing dependency: 'logout'. Either include it or remove the dependency array.",["765"],"React Hook React.useEffect has a missing dependency: 'spinAnim'. Either include it or remove the dependency array.",["766"],"'BottomDialog' is defined but never used.","'viewProducts' is assigned a value but never used.","'theme' is defined but never used.","'FormikHelpers' is defined but never used.","React Hook React.useEffect has a missing dependency: 'banners'. Either include it or remove the dependency array.",["767"],"'Banner' is defined but never used.","React Hook useEffect has a missing dependency: 'router'. Either include it or remove the dependency array.",["768"],"The 'stores' logical expression could make the dependencies of useMemo Hook (at line 175) change on every render. To fix this, wrap the initialization of 'stores' in its own useMemo() Hook.","The 'stores' logical expression could make the dependencies of useEffect Hook (at line 192) change on every render. To fix this, wrap the initialization of 'stores' in its own useMemo() Hook.","The 'allProducts' logical expression could make the dependencies of useMemo Hook (at line 200) change on every render. Move it inside the useMemo callback. Alternatively, wrap the initialization of 'allProducts' in its own useMemo() Hook.","'useInfiniteQuery' is defined but never used.","The 'coupons' logical expression could make the dependencies of useMemo Hook (at line 135) change on every render. Move it inside the useMemo callback. Alternatively, wrap the initialization of 'coupons' in its own useMemo() Hook.",{"desc":"769","fix":"770"},{"desc":"771","fix":"772"},{"messageId":"773","data":"774","fix":"775","desc":"776"},{"messageId":"773","data":"777","fix":"778","desc":"779"},{"messageId":"773","data":"780","fix":"781","desc":"782"},{"messageId":"773","data":"783","fix":"784","desc":"785"},{"messageId":"773","data":"786","fix":"787","desc":"788"},{"messageId":"773","data":"789","fix":"790","desc":"791"},{"messageId":"773","data":"792","fix":"793","desc":"794"},{"messageId":"773","data":"795","fix":"796","desc":"797"},{"messageId":"773","data":"798","fix":"799","desc":"788"},{"messageId":"773","data":"800","fix":"801","desc":"791"},{"messageId":"773","data":"802","fix":"803","desc":"794"},{"messageId":"773","data":"804","fix":"805","desc":"797"},{"messageId":"773","data":"806","fix":"807","desc":"788"},{"messageId":"773","data":"808","fix":"809","desc":"791"},{"messageId":"773","data":"810","fix":"811","desc":"794"},{"messageId":"773","data":"812","fix":"813","desc":"797"},{"messageId":"773","data":"814","fix":"815","desc":"788"},{"messageId":"773","data":"816","fix":"817","desc":"791"},{"messageId":"773","data":"818","fix":"819","desc":"794"},{"messageId":"773","data":"820","fix":"821","desc":"797"},{"messageId":"773","data":"822","fix":"823","desc":"776"},{"messageId":"773","data":"824","fix":"825","desc":"779"},{"messageId":"773","data":"826","fix":"827","desc":"782"},{"messageId":"773","data":"828","fix":"829","desc":"785"},{"messageId":"830","data":"831","fix":"832","desc":"833"},{"messageId":"830","data":"834","fix":"835","desc":"836"},{"desc":"837","fix":"838"},{"desc":"839","fix":"840"},{"desc":"841","fix":"842"},{"desc":"843","fix":"844"},{"desc":"845","fix":"846"},{"desc":"847","fix":"848"},"Update the dependencies array to be: [existingImageUrl, initialValues.isDashboardTag]",{"range":"849","text":"850"},"Update the dependencies array to be: [orders, selectedUserId, deliverySequence]",{"range":"851","text":"852"},"replaceWithAlt",{"alt":"853"},{"range":"854","text":"855"},"Replace with `'`.",{"alt":"856"},{"range":"857","text":"858"},"Replace with `‘`.",{"alt":"859"},{"range":"860","text":"861"},"Replace with `'`.",{"alt":"862"},{"range":"863","text":"864"},"Replace with `’`.",{"alt":"865"},{"range":"866","text":"867"},"Replace with `"`.",{"alt":"868"},{"range":"869","text":"870"},"Replace with `“`.",{"alt":"871"},{"range":"872","text":"873"},"Replace with `"`.",{"alt":"874"},{"range":"875","text":"876"},"Replace with `”`.",{"alt":"865"},{"range":"877","text":"878"},{"alt":"868"},{"range":"879","text":"880"},{"alt":"871"},{"range":"881","text":"882"},{"alt":"874"},{"range":"883","text":"884"},{"alt":"865"},{"range":"885","text":"886"},{"alt":"868"},{"range":"887","text":"888"},{"alt":"871"},{"range":"889","text":"890"},{"alt":"874"},{"range":"891","text":"892"},{"alt":"865"},{"range":"893","text":"865"},{"alt":"868"},{"range":"894","text":"868"},{"alt":"871"},{"range":"895","text":"871"},{"alt":"874"},{"range":"896","text":"874"},{"alt":"853"},{"range":"897","text":"898"},{"alt":"856"},{"range":"899","text":"900"},{"alt":"859"},{"range":"901","text":"902"},{"alt":"862"},{"range":"903","text":"904"},"replaceEmptyInterface",{"replacement":"905"},{"range":"906","text":"907"},"Replace empty interface with `object`.",{"replacement":"908"},{"range":"909","text":"910"},"Replace empty interface with `unknown`.","Update the dependencies array to be: [formik, isEditing]",{"range":"911","text":"912"},"Update the dependencies array to be: [pathname, router]",{"range":"913","text":"914"},"Update the dependencies array to be: [logout]",{"range":"915","text":"916"},"Update the dependencies array to be: [refreshing, spinAnim]",{"range":"917","text":"918"},"Update the dependencies array to be: [banners, bannersData]",{"range":"919","text":"920"},"Update the dependencies array to be: [bannerId, bannerData, router]",{"range":"921","text":"922"},[1284,1314],"[existingImageUrl, initialValues.isDashboardTag]",[11758,11800],"[orders, selectedUserId, deliverySequence]","'",[5672,5718],"We couldn't load the stores. Please try again.","‘",[5672,5718],"We couldn‘t load the stores. Please try again.","'",[5672,5718],"We couldn't load the stores. Please try again.","’",[5672,5718],"We couldn’t load the stores. Please try again.",""",[3153,3179]," product(s) from snippet "","“",[3153,3179]," product(s) from snippet “",""",[3153,3179]," product(s) from snippet "","”",[3153,3179]," product(s) from snippet ”",[3198,3208],""\n ",[3198,3208],"“\n ",[3198,3208],""\n ",[3198,3208],"”\n ",[3830,3842],"Orders for "",[3830,3842],"Orders for “",[3830,3842],"Orders for "",[3830,3842],"Orders for ”",[3855,3856],[3855,3856],[3855,3856],[3855,3856],[4770,4852],"\n No orders found that match this snippet's criteria\n ",[4770,4852],"\n No orders found that match this snippet‘s criteria\n ",[4770,4852],"\n No orders found that match this snippet's criteria\n ",[4770,4852],"\n No orders found that match this snippet’s criteria\n ","object",[534,587],"type StoreFormRef = object","unknown",[534,587],"type StoreFormRef = unknown",[2998,3009],"[formik, isEditing]",[1709,1711],"[pathname, router]",[2596,2598],"[logout]",[1465,1477],"[refreshing, spinAnim]",[1979,1992],"[banners, bannersData]",[2002,2024],"[bannerId, bannerData, router]"] \ No newline at end of file diff --git a/apps/admin-ui/.expo/devices.json b/apps/admin-ui/.expo/devices.json new file mode 100644 index 0000000..5efff6c --- /dev/null +++ b/apps/admin-ui/.expo/devices.json @@ -0,0 +1,3 @@ +{ + "devices": [] +} diff --git a/apps/admin-ui/.expo/prebuild/cached-packages.json b/apps/admin-ui/.expo/prebuild/cached-packages.json new file mode 100644 index 0000000..7e9df5c --- /dev/null +++ b/apps/admin-ui/.expo/prebuild/cached-packages.json @@ -0,0 +1,4 @@ +{ + "dependencies": "091948e86692e0cce7744b6b0543448538c3125a", + "devDependencies": "b3b38265f32b99a8299270a292f38ca26288d53d" +} diff --git a/apps/admin-ui/.expo/types/router.d.ts b/apps/admin-ui/.expo/types/router.d.ts new file mode 100644 index 0000000..6b43803 --- /dev/null +++ b/apps/admin-ui/.expo/types/router.d.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ +import * as Router from 'expo-router'; + +export * from 'expo-router'; + +declare module 'expo-router' { + export namespace ExpoRouter { + export interface __routes { + hrefInputParams: { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/`; params?: Router.UnknownInputParams; } | { pathname: `/login`; params?: Router.UnknownInputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/create-product-group` | `/create-product-group`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-product` | `/add-product`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-slot` | `/add-slot`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-store` | `/add-store`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-tag` | `/add-tag`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/address-management` | `/address-management`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/complaints` | `/complaints`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/coupons` | `/coupons`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/coupons/reserved-coupons` | `/coupons/reserved-coupons`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/create-coupon` | `/create-coupon`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/customize-app` | `/customize-app`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/customize-app/popular-items` | `/customize-app/popular-items`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard` | `/dashboard`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners` | `/dashboard-banners`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners/create-banner` | `/dashboard-banners/create-banner`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/delivery-sequences` | `/delivery-sequences`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/edit-product` | `/edit-product`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/edit-store` | `/edit-store`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/edit-tag` | `/edit-tag`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/manage-orders` | `/manage-orders`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/orders` | `/orders`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/prices-overview` | `/prices-overview`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/product-groupings` | `/product-groupings`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/product-tags` | `/product-tags`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/products` | `/products`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/rebalance-orders` | `/rebalance-orders`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/slots` | `/slots`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/slots/slot-details` | `/slots/slot-details`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/stores` | `/stores`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/users` | `/users`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/vendor-snippets` | `/vendor-snippets`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners/edit-banner/[id]` | `/dashboard-banners/edit-banner/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/edit-coupon/[id]` | `/edit-coupon/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/edit-product-group/[id]` | `/edit-product-group/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/edit-slot/[id]` | `/edit-slot/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/order-details/[id]` | `/order-details/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/product-detail/[id]` | `/product-detail/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/user-details/[id]` | `/user-details/[id]`, params: Router.UnknownInputParams & { id: string | number; } }; + hrefOutputParams: { pathname: Router.RelativePathString, params?: Router.UnknownOutputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams } | { pathname: `/`; params?: Router.UnknownOutputParams; } | { pathname: `/login`; params?: Router.UnknownOutputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/create-product-group` | `/create-product-group`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/add-product` | `/add-product`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/add-slot` | `/add-slot`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/add-store` | `/add-store`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/add-tag` | `/add-tag`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/address-management` | `/address-management`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/complaints` | `/complaints`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/coupons` | `/coupons`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/coupons/reserved-coupons` | `/coupons/reserved-coupons`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/create-coupon` | `/create-coupon`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/customize-app` | `/customize-app`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/customize-app/popular-items` | `/customize-app/popular-items`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/dashboard` | `/dashboard`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners` | `/dashboard-banners`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners/create-banner` | `/dashboard-banners/create-banner`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/delivery-sequences` | `/delivery-sequences`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/edit-product` | `/edit-product`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/edit-store` | `/edit-store`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/edit-tag` | `/edit-tag`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/manage-orders` | `/manage-orders`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/orders` | `/orders`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/prices-overview` | `/prices-overview`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/product-groupings` | `/product-groupings`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/product-tags` | `/product-tags`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/products` | `/products`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/rebalance-orders` | `/rebalance-orders`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/slots` | `/slots`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/slots/slot-details` | `/slots/slot-details`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/stores` | `/stores`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/users` | `/users`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/vendor-snippets` | `/vendor-snippets`; params?: Router.UnknownOutputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners/edit-banner/[id]` | `/dashboard-banners/edit-banner/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(drawer)'}/edit-coupon/[id]` | `/edit-coupon/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(drawer)'}/edit-product-group/[id]` | `/edit-product-group/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(drawer)'}/edit-slot/[id]` | `/edit-slot/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(drawer)'}/order-details/[id]` | `/order-details/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(drawer)'}/product-detail/[id]` | `/product-detail/[id]`, params: Router.UnknownOutputParams & { id: string; } } | { pathname: `${'/(drawer)'}/user-details/[id]` | `/user-details/[id]`, params: Router.UnknownOutputParams & { id: string; } }; + href: Router.RelativePathString | Router.ExternalPathString | `/${`?${string}` | `#${string}` | ''}` | `/login${`?${string}` | `#${string}` | ''}` | `/_sitemap${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/create-product-group${`?${string}` | `#${string}` | ''}` | `/create-product-group${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/add-product${`?${string}` | `#${string}` | ''}` | `/add-product${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/add-slot${`?${string}` | `#${string}` | ''}` | `/add-slot${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/add-store${`?${string}` | `#${string}` | ''}` | `/add-store${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/add-tag${`?${string}` | `#${string}` | ''}` | `/add-tag${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/address-management${`?${string}` | `#${string}` | ''}` | `/address-management${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/complaints${`?${string}` | `#${string}` | ''}` | `/complaints${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/coupons${`?${string}` | `#${string}` | ''}` | `/coupons${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/coupons/reserved-coupons${`?${string}` | `#${string}` | ''}` | `/coupons/reserved-coupons${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/create-coupon${`?${string}` | `#${string}` | ''}` | `/create-coupon${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/customize-app${`?${string}` | `#${string}` | ''}` | `/customize-app${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/customize-app/popular-items${`?${string}` | `#${string}` | ''}` | `/customize-app/popular-items${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/dashboard${`?${string}` | `#${string}` | ''}` | `/dashboard${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/dashboard-banners${`?${string}` | `#${string}` | ''}` | `/dashboard-banners${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/dashboard-banners/create-banner${`?${string}` | `#${string}` | ''}` | `/dashboard-banners/create-banner${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/delivery-sequences${`?${string}` | `#${string}` | ''}` | `/delivery-sequences${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/edit-product${`?${string}` | `#${string}` | ''}` | `/edit-product${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/edit-store${`?${string}` | `#${string}` | ''}` | `/edit-store${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/edit-tag${`?${string}` | `#${string}` | ''}` | `/edit-tag${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/manage-orders${`?${string}` | `#${string}` | ''}` | `/manage-orders${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/orders${`?${string}` | `#${string}` | ''}` | `/orders${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/prices-overview${`?${string}` | `#${string}` | ''}` | `/prices-overview${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/product-groupings${`?${string}` | `#${string}` | ''}` | `/product-groupings${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/product-tags${`?${string}` | `#${string}` | ''}` | `/product-tags${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/products${`?${string}` | `#${string}` | ''}` | `/products${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/rebalance-orders${`?${string}` | `#${string}` | ''}` | `/rebalance-orders${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/slots${`?${string}` | `#${string}` | ''}` | `/slots${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/slots/slot-details${`?${string}` | `#${string}` | ''}` | `/slots/slot-details${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/stores${`?${string}` | `#${string}` | ''}` | `/stores${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/users${`?${string}` | `#${string}` | ''}` | `/users${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/vendor-snippets${`?${string}` | `#${string}` | ''}` | `/vendor-snippets${`?${string}` | `#${string}` | ''}` | { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/`; params?: Router.UnknownInputParams; } | { pathname: `/login`; params?: Router.UnknownInputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/create-product-group` | `/create-product-group`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-product` | `/add-product`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-slot` | `/add-slot`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-store` | `/add-store`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/add-tag` | `/add-tag`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/address-management` | `/address-management`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/complaints` | `/complaints`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/coupons` | `/coupons`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/coupons/reserved-coupons` | `/coupons/reserved-coupons`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/create-coupon` | `/create-coupon`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/customize-app` | `/customize-app`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/customize-app/popular-items` | `/customize-app/popular-items`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard` | `/dashboard`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners` | `/dashboard-banners`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/dashboard-banners/create-banner` | `/dashboard-banners/create-banner`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/delivery-sequences` | `/delivery-sequences`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/edit-product` | `/edit-product`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/edit-store` | `/edit-store`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/edit-tag` | `/edit-tag`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/manage-orders` | `/manage-orders`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/orders` | `/orders`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/prices-overview` | `/prices-overview`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/product-groupings` | `/product-groupings`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/product-tags` | `/product-tags`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/products` | `/products`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/rebalance-orders` | `/rebalance-orders`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/slots` | `/slots`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/slots/slot-details` | `/slots/slot-details`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/stores` | `/stores`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/users` | `/users`; params?: Router.UnknownInputParams; } | { pathname: `${'/(drawer)'}/vendor-snippets` | `/vendor-snippets`; params?: Router.UnknownInputParams; } | `${'/(drawer)'}/dashboard-banners/edit-banner/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/dashboard-banners/edit-banner/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/edit-coupon/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/edit-coupon/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/edit-product-group/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/edit-product-group/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/edit-slot/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/edit-slot/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/order-details/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/order-details/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/product-detail/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/product-detail/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `${'/(drawer)'}/user-details/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | `/user-details/${Router.SingleRoutePart}${`?${string}` | `#${string}` | ''}` | { pathname: `${'/(drawer)'}/dashboard-banners/edit-banner/[id]` | `/dashboard-banners/edit-banner/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/edit-coupon/[id]` | `/edit-coupon/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/edit-product-group/[id]` | `/edit-product-group/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/edit-slot/[id]` | `/edit-slot/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/order-details/[id]` | `/order-details/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/product-detail/[id]` | `/product-detail/[id]`, params: Router.UnknownInputParams & { id: string | number; } } | { pathname: `${'/(drawer)'}/user-details/[id]` | `/user-details/[id]`, params: Router.UnknownInputParams & { id: string | number; } }; + } + } +} diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_108.png b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_108.png new file mode 100644 index 0000000..0f6e273 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_108.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_162.png b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_162.png new file mode 100644 index 0000000..3be8da9 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_162.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_216.png b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_216.png new file mode 100644 index 0000000..54fc6e9 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_216.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_324.png b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_324.png new file mode 100644 index 0000000..e248f83 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_324.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_432.png b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_432.png new file mode 100644 index 0000000..fbb272c Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-adaptive-foreground/android-adaptive-foreground-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-transparent/icon_432.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_144.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_144.png new file mode 100644 index 0000000..fa56768 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_144.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_192.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_192.png new file mode 100644 index 0000000..e704616 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_192.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_48.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_48.png new file mode 100644 index 0000000..4cc3153 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_48.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_72.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_72.png new file mode 100644 index 0000000..61233cc Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_72.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_96.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_96.png new file mode 100644 index 0000000..dfb81e4 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-circle/android-standard-circle-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_96.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_144.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_144.png new file mode 100644 index 0000000..0413650 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_144.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_192.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_192.png new file mode 100644 index 0000000..8cfea23 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_192.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_48.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_48.png new file mode 100644 index 0000000..f75244d Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_48.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_72.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_72.png new file mode 100644 index 0000000..b5b67c8 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_72.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_96.png b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_96.png new file mode 100644 index 0000000..98d390a Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/android-standard-square/android-standard-square-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#fff0f6/icon_96.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/iconsuniversal-icon/iconsuniversal-icon-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#ffffff/App-Icon-1024x1024@1x.png b/apps/admin-ui/.expo/web/cache/production/images/iconsuniversal-icon/iconsuniversal-icon-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#ffffff/App-Icon-1024x1024@1x.png new file mode 100644 index 0000000..3ee4406 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/iconsuniversal-icon/iconsuniversal-icon-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-cover-#ffffff/App-Icon-1024x1024@1x.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_200.png b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_200.png new file mode 100644 index 0000000..ce070bf Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_200.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_300.png b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_300.png new file mode 100644 index 0000000..6ac7e85 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_300.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_400.png b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_400.png new file mode 100644 index 0000000..d0c150c Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_400.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_600.png b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_600.png new file mode 100644 index 0000000..d48100c Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_600.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_800.png b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_800.png new file mode 100644 index 0000000..750fe21 Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-android/splash-android-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_800.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_200.png b/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_200.png new file mode 100644 index 0000000..ce070bf Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_200.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_400.png b/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_400.png new file mode 100644 index 0000000..d0c150c Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_400.png differ diff --git a/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_600.png b/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_600.png new file mode 100644 index 0000000..d48100c Binary files /dev/null and b/apps/admin-ui/.expo/web/cache/production/images/splash-ios/splash-ios-3a02c603f3580be3c731fe6fe225bd822968f9a49abc196da934f1abf264d906-contain/icon_600.png differ diff --git a/apps/admin-ui/.gitignore b/apps/admin-ui/.gitignore new file mode 100755 index 0000000..5873d9a --- /dev/null +++ b/apps/admin-ui/.gitignore @@ -0,0 +1,6 @@ + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +# @end expo-cli \ No newline at end of file diff --git a/apps/admin-ui/README.md b/apps/admin-ui/README.md new file mode 100755 index 0000000..48dd63f --- /dev/null +++ b/apps/admin-ui/README.md @@ -0,0 +1,50 @@ +# Welcome to your Expo app 👋 + +This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). + +## Get started + +1. Install dependencies + + ```bash + npm install + ``` + +2. Start the app + + ```bash + npx expo start + ``` + +In the output, you'll find options to open the app in a + +- [development build](https://docs.expo.dev/develop/development-builds/introduction/) +- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) +- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) +- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo + +You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). + +## Get a fresh project + +When you're ready, run: + +```bash +npm run reset-project +``` + +This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing. + +## Learn more + +To learn more about developing your project with Expo, look at the following resources: + +- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). +- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web. + +## Join the community + +Join our community of developers creating universal apps. + +- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. +- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. diff --git a/apps/admin-ui/app.json b/apps/admin-ui/app.json new file mode 100644 index 0000000..74cfd1b --- /dev/null +++ b/apps/admin-ui/app.json @@ -0,0 +1,81 @@ +{ + "expo": { + "name": "Symbuyote Admin", + "slug": "freshyoadmin", + "version": "1.0.0", + "orientation": "portrait", + "icon": "./assets/images/symbuyoteadmin.png", + "scheme": "freshyoadmin", + "userInterfaceStyle": "automatic", + "newArchEnabled": true, + "ios": { + "supportsTablet": true, + "bundleIdentifier": "in.freshyo.adminui", + "infoPlist": { + "LSApplicationQueriesSchemes": [ + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay" + ] + } + }, + "android": { + "adaptiveIcon": { + "foregroundImage": "./assets/images/symbuyoteadmin.png", + "backgroundColor": "#fff0f6" + }, + "edgeToEdgeEnabled": true, + "package": "in.freshyo.adminui" + }, + "web": { + "bundler": "metro", + "output": "static", + "favicon": "./assets/images/favicon.png" + }, + "plugins": [ + "expo-router", + [ + "expo-splash-screen", + { + "image": "./assets/images/symbuyoteadmin.png", + "imageWidth": 200, + "resizeMode": "contain", + "backgroundColor": "#ffffff" + } + ], + "expo-secure-store" + ], + "experiments": { + "typedRoutes": true + }, + "extra": { + "router": {}, + "eas": { + "projectId": "55e2f200-eb9d-4880-a193-70f59320e054" + } + }, + "runtimeVersion": { + "policy": "appVersion" + }, + "updates": { + "url": "https://u.expo.dev/55e2f200-eb9d-4880-a193-70f59320e054" + } + } +} diff --git a/apps/admin-ui/app/(drawer)/_layout.tsx b/apps/admin-ui/app/(drawer)/_layout.tsx new file mode 100644 index 0000000..fe09f61 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/_layout.tsx @@ -0,0 +1,232 @@ +import { Drawer } from "expo-router/drawer"; +import { DrawerContentScrollView, DrawerItem } from "@react-navigation/drawer"; +import { useRouter, Redirect } from "expo-router"; +import { useNavigation, DrawerActions } from "@react-navigation/native"; +import { + TouchableOpacity, + DeviceEventEmitter, + View, + ActivityIndicator, +} from "react-native"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { REFRESH_EVENT } from "common-ui/src/lib/const-strs"; +import { useStaffAuth } from "@/components/context/staff-auth-context"; +import { tw, MyText, theme } from "common-ui"; + +function CustomDrawerContent() { + const router = useRouter(); + const { logout, staff } = useStaffAuth(); + + return ( + + {staff && ( + + + + + {staff.name} + + Staff Member + + + )} + router.push("/(drawer)/dashboard" as any)} + icon={({ color, size }) => ( + + )} + /> + {/* router.push("/(drawer)/add-product" as any)} + icon={({ color, size }) => ( + + )} + /> */} + router.push("/(drawer)/products" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("/(drawer)/prices-overview" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("/(drawer)/product-groupings" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("/(drawer)/dashboard-banners" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("/(drawer)/slots" as any)} + icon={({ color, size }) => ( + + )} + /> + {/* router.push("/(drawer)/edit-product" as any)} + icon={({ color, size }) => ( + + )} + /> */} + router.push("/(drawer)/complaints" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("/(drawer)/manage-orders" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("coupons" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("vendor-snippets" as any)} + icon={({ color, size }) => ( + + )} + /> + router.push("/(drawer)/stores" as any)} + icon={({ color, size }) => ( + + )} + /> + logout()} + icon={({ color, size }) => ( + + )} + /> + + ); +} + +export default function Layout() { + const { isLoggedIn, isLoading } = useStaffAuth(); + + if (isLoading) { + return ( + + + + ); + } + + if (!isLoggedIn) { + return ; + } + + return ( + ({ + headerShown: true, + headerStyle: { + backgroundColor: theme.colors.gray1, + shadowOpacity: 0, + shadowRadius: 0, + shadowOffset: { height: 0, width: 0 }, + elevation: 0, + }, + headerTitleAlign: "center", + headerLeft: () => ( + (navigation as any).openDrawer()} + style={{ + marginLeft: 15, + width: 40, + height: 40, + borderRadius: 20, + backgroundColor: "#f2f2f2", + justifyContent: "center", + alignItems: "center", + }} + > + + + ), + headerRight: () => ( + { + DeviceEventEmitter.emit(REFRESH_EVENT); + }} + > + + + ), + })} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/admin-ui/app/(drawer)/add-product/_layout.tsx b/apps/admin-ui/app/(drawer)/add-product/_layout.tsx new file mode 100644 index 0000000..0bb91f7 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-product/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-product/index.tsx b/apps/admin-ui/app/(drawer)/add-product/index.tsx new file mode 100644 index 0000000..67aa694 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-product/index.tsx @@ -0,0 +1,89 @@ +import React from 'react'; +import { Alert } from 'react-native'; +import { AppContainer } from 'common-ui'; +import ProductForm from '../../../src/components/ProductForm'; +import { useCreateProduct, CreateProductPayload } from '../../../src/api-hooks/product.api'; + +export default function AddProduct() { + const { mutate: createProduct, isPending: isCreating } = useCreateProduct(); + + const handleSubmit = (values: any, images?: { uri?: string, mimeType?: string }[]) => { + const payload: CreateProductPayload = { + name: values.name, + shortDescription: values.shortDescription, + longDescription: values.longDescription, + unitId: parseInt(values.unitId), + storeId: parseInt(values.storeId), + price: parseFloat(values.price), + marketPrice: values.marketPrice ? parseFloat(values.marketPrice) : undefined, + incrementStep: 1, + productQuantity: values.productQuantity || 1, + }; + + const formData = new FormData(); + Object.entries(payload).forEach(([key, value]) => { + if (value !== undefined && value !== null) { + formData.append(key, value as string); + } + }); + + // Append tag IDs + if (values.tagIds && values.tagIds.length > 0) { + values.tagIds.forEach((tagId: number) => { + formData.append('tagIds', tagId.toString()); + }); + } + + // Append images + if (images) { + images.forEach((image, index) => { + if (image.uri) { + formData.append('images', { + uri: image.uri, + name: `image-${index}.jpg`, + // type: 'image/jpeg', + type: image.mimeType as any, + } as any); + } + }); + } + + createProduct(formData, { + onSuccess: (data) => { + Alert.alert('Success', 'Product created successfully!'); + // Reset form or navigate + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to create product'); + }, + }); + }; + + const initialValues = { + name: '', + shortDescription: '', + longDescription: '', + unitId: 0, + price: '', + storeId: 1, + marketPrice: '', + deals: [{ quantity: '', price: '', validTill: new Date() }], + tagIds: [], + isSuspended: false, + isFlashAvailable: false, + flashPrice: '', + productQuantity: 1, + }; + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-slot/_layout.tsx b/apps/admin-ui/app/(drawer)/add-slot/_layout.tsx new file mode 100644 index 0000000..6ce19b7 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-slot/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-slot/index.tsx b/apps/admin-ui/app/(drawer)/add-slot/index.tsx new file mode 100644 index 0000000..5ee2002 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-slot/index.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { View } from 'react-native'; +import { AppContainer } from 'common-ui'; +import SlotForm from '../../../components/SlotForm'; +import { useRouter } from 'expo-router'; +import { trpc } from '../../../src/trpc-client'; + +export default function AddSlot() { + const router = useRouter(); + const { refetch } = trpc.admin.slots.getAll.useQuery(); + + const handleSlotAdded = () => { + refetch(); + router.back(); + }; + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-store/_layout.tsx b/apps/admin-ui/app/(drawer)/add-store/_layout.tsx new file mode 100644 index 0000000..1b2194e --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-store/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-store/index.tsx b/apps/admin-ui/app/(drawer)/add-store/index.tsx new file mode 100644 index 0000000..0313cb6 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-store/index.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { View, Alert } from 'react-native'; +import { useRouter } from 'expo-router'; +import { AppContainer, MyText, tw } from 'common-ui'; +import StoreForm, { StoreFormData } from '@/components/StoreForm'; +import { trpc } from '@/src/trpc-client'; + +export default function AddStore() { + const router = useRouter(); + + const createStoreMutation = trpc.admin.store.createStore.useMutation(); + + const handleSubmit = (values: StoreFormData) => { + createStoreMutation.mutate(values, { + onSuccess: (data) => { + Alert.alert('Success', data.message); + router.push('/(drawer)/stores' as any); // Navigate back to stores list + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to create store'); + }, + }); + }; + + return ( + + + Add New Store + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-tag/_layout.tsx b/apps/admin-ui/app/(drawer)/add-tag/_layout.tsx new file mode 100644 index 0000000..c1c246f --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-tag/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/add-tag/index.tsx b/apps/admin-ui/app/(drawer)/add-tag/index.tsx new file mode 100644 index 0000000..1d83c32 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/add-tag/index.tsx @@ -0,0 +1,77 @@ +import React from 'react'; +import { View, Alert } from 'react-native'; +import { useRouter } from 'expo-router'; +import { AppContainer, MyText, tw } from 'common-ui'; +import TagForm from '@/src/components/TagForm'; +import { useCreateTag } from '@/src/api-hooks/tag.api'; + +interface TagFormData { + tagName: string; + tagDescription: string; + isDashboardTag: boolean; +} + +export default function AddTag() { + const router = useRouter(); + const { mutate: createTag, isPending: isCreating } = useCreateTag(); + + const handleSubmit = (values: TagFormData, image?: { uri?: string }) => { + const formData = new FormData(); + + // Add text fields + formData.append('tagName', values.tagName); + if (values.tagDescription) { + formData.append('tagDescription', values.tagDescription); + } + formData.append('isDashboardTag', values.isDashboardTag.toString()); + + // Add image if uploaded + if (image?.uri) { + const filename = image.uri.split('/').pop() || 'image.jpg'; + const match = /\.(\w+)$/.exec(filename); + const type = match ? `image/${match[1]}` : 'image/jpeg'; + + formData.append('image', { + uri: image.uri, + name: filename, + type, + } as any); + } + + createTag(formData, { + onSuccess: (data) => { + Alert.alert('Success', 'Tag created successfully', [ + { + text: 'OK', + onPress: () => router.back(), + }, + ]); + }, + onError: (error: any) => { + const errorMessage = error.message || 'Failed to create tag'; + Alert.alert('Error', errorMessage); + }, + }); + }; + + const initialValues: TagFormData = { + tagName: '', + tagDescription: '', + isDashboardTag: false, + }; + + return ( + + + + {/* Form */} + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/address-management/index.tsx b/apps/admin-ui/app/(drawer)/address-management/index.tsx new file mode 100644 index 0000000..69745b8 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/address-management/index.tsx @@ -0,0 +1,108 @@ +import React, { useState } from 'react' +import { View, Text, TouchableOpacity, ScrollView } from 'react-native' +import { BottomDialog , tw } from 'common-ui' +import { trpc } from '@/src/trpc-client' +import AddressZoneForm from '@/components/AddressZoneForm' +import AddressPlaceForm from '@/components/AddressPlaceForm' +import MaterialIcons from '@expo/vector-icons/MaterialIcons' + +const AddressManagement: React.FC = () => { + const [dialogOpen, setDialogOpen] = useState(false) + const [dialogType, setDialogType] = useState<'zone' | 'place' | null>(null) + const [expandedZones, setExpandedZones] = useState>(new Set()) + + const { data: zones, refetch: refetchZones } = trpc.admin.address.getZones.useQuery() + const { data: areas, refetch: refetchAreas } = trpc.admin.address.getAreas.useQuery() + + const createZone = trpc.admin.address.createZone.useMutation({ + onSuccess: () => { + refetchZones() + setDialogOpen(false) + }, + }) + + const createArea = trpc.admin.address.createArea.useMutation({ + onSuccess: () => { + refetchAreas() + setDialogOpen(false) + }, + }) + + const handleAddZone = () => { + setDialogType('zone') + setDialogOpen(true) + } + + const handleAddPlace = () => { + setDialogType('place') + setDialogOpen(true) + } + + const toggleZone = (zoneId: number) => { + setExpandedZones(prev => { + const newSet = new Set(prev) + if (newSet.has(zoneId)) { + newSet.delete(zoneId) + } else { + newSet.add(zoneId) + } + return newSet + }) + } + + const groupedAreas = areas?.reduce((acc, area) => { + if (area.zoneId) { + if (!acc[area.zoneId]) acc[area.zoneId] = [] + acc[area.zoneId].push(area) + } + return acc + }, {} as Record) || {} + + const unzonedAreas = areas?.filter(a => !a.zoneId) || [] + + return ( + + + + Add Zone + + + Add Place + + + + + {zones?.map(zone => ( + + toggleZone(zone.id)}> + {zone.zoneName} + + + {expandedZones.has(zone.id) && ( + + {groupedAreas[zone.id]?.map(area => ( + - {area.placeName} + )) || No places in this zone} + + )} + + ))} + + + Unzoned Places + {unzonedAreas.map(area => ( + - {area.placeName} + ))} + {unzonedAreas.length === 0 && No unzoned places} + + + + setDialogOpen(false)}> + {dialogType === 'zone' && setDialogOpen(false)} />} + {dialogType === 'place' && setDialogOpen(false)} />} + + + ) +} + +export default AddressManagement \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/complaints/_layout.tsx b/apps/admin-ui/app/(drawer)/complaints/_layout.tsx new file mode 100644 index 0000000..32d78fa --- /dev/null +++ b/apps/admin-ui/app/(drawer)/complaints/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/complaints/index.tsx b/apps/admin-ui/app/(drawer)/complaints/index.tsx new file mode 100644 index 0000000..cc1e38f --- /dev/null +++ b/apps/admin-ui/app/(drawer)/complaints/index.tsx @@ -0,0 +1,158 @@ +import React, { useState } from "react"; +import { View, Text, TouchableOpacity, Alert } from "react-native"; +import { tw, ConfirmationDialog, MyText, MyFlatList, useMarkDataFetchers, usePagination, ImageViewerURI } from "common-ui"; +import { trpc } from "@/src/trpc-client"; + +export default function Complaints() { + const { currentPage, pageSize, PaginationComponent } = usePagination(5); // 5 complaints per page for testing + const { data, isLoading, error, refetch } = trpc.admin.complaint.getAll.useQuery({ + page: currentPage, + limit: pageSize, + }); + const resolveComplaint = trpc.admin.complaint.resolve.useMutation(); + + useMarkDataFetchers(() => { + refetch(); + }); + + const [dialogOpen, setDialogOpen] = useState(false); + const [selectedComplaintId, setSelectedComplaintId] = useState(null); + + const complaints = data?.complaints || []; + const totalCount = data?.totalCount || 0; + + const handleMarkResolved = (id: number) => { + setSelectedComplaintId(id); + setDialogOpen(true); + }; + + const handleConfirmResolve = (response?: string) => { + if (!selectedComplaintId) return; + + resolveComplaint.mutate( + { id: String(selectedComplaintId), response }, + { + onSuccess: () => { + Alert.alert("Success", "Complaint marked as resolved"); + refetch(); + setDialogOpen(false); + setSelectedComplaintId(null); + }, + onError: (error: any) => { + Alert.alert( + "Error", + error.message || "Failed to resolve complaint" + ); + setDialogOpen(false); + setSelectedComplaintId(null); + }, + } + ); + }; + + if (isLoading) { + return ( + + Loading complaints... + + ); + } + + if (error) { + return ( + + Error loading complaints + + ); + } + + return ( + + item.id.toString()} + renderItem={({ item }) => ( + + Complaint #{item.id} + {item.text} + + {item.images && item.images.length > 0 && ( + + Attached Images: + + {item.images.map((imageUri: string, index: number) => ( + + ))} + + + )} + + + + Alert.alert("User Page", "User page coming soon") + } + > + + {item.userName} + + + | + {item.orderId && ( + + Alert.alert("Order Page", "Order page coming soon") + } + > + + Order #{item.orderId} + + + )} + + + Status: {item.status} + + {item.status === "pending" && ( + handleMarkResolved(item.id)} + style={tw`mt-2 bg-blue-500 p-3 rounded-lg shadow-md`} + > + Mark as Resolved + + )} + + )} + ListEmptyComponent={ + + No complaints found + + } + /> + + { + setDialogOpen(false); + setSelectedComplaintId(null); + }} + title="Mark as Resolved" + message="Add admin notes for this resolution:" + confirmText="Resolve" + cancelText="Cancel" + /> + + ); +} diff --git a/apps/admin-ui/app/(drawer)/coupons/_layout.tsx b/apps/admin-ui/app/(drawer)/coupons/_layout.tsx new file mode 100644 index 0000000..777af67 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/coupons/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/coupons/index.tsx b/apps/admin-ui/app/(drawer)/coupons/index.tsx new file mode 100644 index 0000000..e17c248 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/coupons/index.tsx @@ -0,0 +1,515 @@ +import React, { useState, useCallback, useMemo } from 'react'; +import { View, TouchableOpacity, Alert, RefreshControl, Dimensions } from 'react-native'; +import { MaterialCommunityIcons } from '@expo/vector-icons'; +import { LinearGradient } from 'expo-linear-gradient'; +import { tw, MyButton, MyText, SearchBar, MyFlatList, useMarkDataFetchers, MyTouchableOpacity, BottomDropdown } from 'common-ui'; +import useManualRefresh from 'common-ui/hooks/useManualRefresh'; +import { trpc } from '@/src/trpc-client'; +import { useRouter } from 'expo-router'; +import { TabView, SceneMap, TabBar } from 'react-native-tab-view'; + +const CouponItem = ({ item, onDelete }: { item: any; onDelete: (id: number) => void }) => { + const router = useRouter(); + + const getCouponStatus = (coupon: any) => { + if (coupon.isInvalidated) return 'inactive'; + if (coupon.validTill && new Date(coupon.validTill) <= new Date()) return 'expired'; + return 'active'; + }; + + const status = getCouponStatus(item); + + const getBorderColor = () => { + if (status === 'active') return 'border-green-500'; + if (status === 'expired') return 'border-yellow-500'; + return 'border-red-500'; + }; + + const getBgColor = () => { + if (status === 'active') return 'bg-green-100'; + if (status === 'expired') return 'bg-yellow-100'; + return 'bg-red-100'; + }; + + const getTextColor = () => { + if (status === 'active') return 'text-green-600'; + if (status === 'expired') return 'text-yellow-600'; + return 'text-red-600'; + }; + + const getIconColor = () => { + if (status === 'active') return '#10b981'; + if (status === 'expired') return '#f59e0b'; + return '#ef4444'; + }; + + return ( + + + + + + + {item.couponCode} + ID: {item.id} + + + + {status === 'active' ? 'Active' : status === 'expired' ? 'Expired' : 'Inactive'} + + + + + + + Discount: {item.discountPercent ? `${item.discountPercent}% off` : item.flatDiscount ? `₹${item.flatDiscount} off` : 'N/A'} + + + Min Order: {item.minOrder ? `₹${item.minOrder}` : 'None'} + Max: {item.maxValue ? `₹${item.maxValue}` : 'None'} + + + Valid Till: {item.validTill ? new Date(item.validTill).toLocaleDateString() : 'No expiry'} + + + + + + Target: {item.isApplyForAll ? 'All Users' : item.applicableUsers?.length > 0 ? `${item.applicableUsers.length} Users` : 'All Users'} + + {item.applicableProducts && item.applicableProducts.length > 0 && ( + + Products: {item.applicableProducts.length} selected + + )} + + + + router.push(`/(drawer)/edit-coupon/${item.id}`)} + style={tw`bg-blue-500 p-3 rounded-lg shadow-md flex-1 flex-row items-center justify-center`} + > + + Edit + + onDelete(item.id)} + style={tw`bg-red-500 p-3 rounded-lg shadow-md flex-1 flex-row items-center justify-center`} + > + + Delete + + + + ); +}; + +const ReservedCouponItem = ({ item }: { item: any }) => { + const getStatus = () => { + if (item.isRedeemed) return 'redeemed'; + if (item.validTill && new Date(item.validTill) <= new Date()) return 'expired'; + return 'active'; + }; + + const status = getStatus(); + + const getBorderColor = () => { + if (status === 'active') return 'border-green-500'; + if (status === 'expired') return 'border-yellow-500'; + return 'border-blue-500'; + }; + + const getBgColor = () => { + if (status === 'active') return 'bg-green-100'; + if (status === 'expired') return 'bg-yellow-100'; + return 'bg-blue-100'; + }; + + const getTextColor = () => { + if (status === 'active') return 'text-green-600'; + if (status === 'expired') return 'text-yellow-600'; + return 'text-blue-600'; + }; + + const getIconColor = () => { + if (status === 'active') return '#10b981'; + if (status === 'expired') return '#f59e0b'; + return '#3b82f6'; + }; + + return ( + + + + + + + {item.secretCode} + Coupon: {item.couponCode} + + + + {status === 'active' ? 'Active' : status === 'expired' ? 'Expired' : 'Redeemed'} + + + + + + + Discount: {item.discountPercent ? `${item.discountPercent}% off` : item.flatDiscount ? `₹${item.flatDiscount} off` : 'N/A'} + + + Min Order: {item.minOrder ? `₹${item.minOrder}` : 'None'} + Max: {item.maxValue ? `₹${item.maxValue}` : 'None'} + + + Valid Till: {item.validTill ? new Date(item.validTill).toLocaleDateString() : 'No expiry'} + + + + {item.isRedeemed && item.redeemedUser && ( + + + Redeemed by: {item.redeemedUser.name || 'Unknown'} ({item.redeemedUser.mobile}) + + + Redeemed on: {item.redeemedAt ? new Date(item.redeemedAt).toLocaleDateString() : 'N/A'} + + + )} + + + + Created by: {item.creator?.name || 'Unknown'} + + + + ); +}; + +const GeneralTab = () => { + const router = useRouter(); + const [refreshing, setRefreshing] = useState(false); + const [searchQuery, setSearchQuery] = useState(''); + const [statusFilters, setStatusFilters] = useState([]); + const { + data, + fetchNextPage, + hasNextPage, + isLoading, + isFetchingNextPage, + error, + refetch, + } = trpc.admin.coupon.getAll.useInfiniteQuery( + { limit: 20, search: searchQuery }, + { getNextPageParam: (lastPage) => lastPage.nextCursor } + ); + + const coupons = useMemo(() => data?.pages.flatMap(page => page.coupons) || [], [data]); + + const getCouponStatus = (coupon: any) => { + if (coupon.isInvalidated) return 'inactive'; + if (coupon.validTill && new Date(coupon.validTill) <= new Date()) return 'expired'; + return 'active'; + }; + + const filteredCoupons = useMemo(() => { + let filtered = coupons; + if (statusFilters.length > 0) { + filtered = filtered.filter(coupon => statusFilters.includes(getCouponStatus(coupon))); + } + return filtered; + }, [coupons, statusFilters]); + + const handleRefresh = useCallback(async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }, [refetch]); + + useManualRefresh(() => refetch()); + + useMarkDataFetchers(() => { + refetch(); + }); + + const deleteCoupon = trpc.admin.coupon.delete.useMutation(); + + const handleDeleteCoupon = (id: number) => { + Alert.alert('Delete Coupon', 'Are you sure you want to delete this coupon?', [ + { text: 'Cancel', style: 'cancel' }, + { + text: 'Delete', + style: 'destructive', + onPress: () => { + deleteCoupon.mutate({ id }, { + onSuccess: () => { + Alert.alert('Success', 'Coupon deleted successfully'); + refetch(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to delete coupon'); + }, + }); + }, + }, + ]); + }; + + if (isLoading) { + return ( + + + Loading Coupons... + + ); + } + + if (error) { + return ( + + + Failed to load coupons + refetch()} style={tw`bg-red-500`}> + Retry + + + ); + } + + return ( + + + + + + setStatusFilters(value as string[])} + multiple={true} + triggerComponent={({ onPress }) => ( + + + + )} + /> + + item.id.toString()} + renderItem={({ item }) => } + refreshControl={ + + } + contentContainerStyle={tw`px-4 pb-4`} + onEndReached={() => { + if (hasNextPage && !isFetchingNextPage) { + fetchNextPage(); + } + }} + onEndReachedThreshold={0.5} + ListEmptyComponent={ + + + No Coupons Found + {searchQuery ? ( + setSearchQuery('')} style={tw`bg-gray-500 mt-4`}> + Clear Search + + ) : null} + + } + /> + + ); +}; + +const ReservedTab = () => { + const router = useRouter(); + const [refreshing, setRefreshing] = useState(false); + const [searchQuery, setSearchQuery] = useState(''); + const [statusFilters, setStatusFilters] = useState([]); + + const { + data, + isLoading, + isFetchingNextPage, + hasNextPage, + fetchNextPage, + error, + refetch + } = trpc.admin.coupon.getReservedCoupons.useInfiniteQuery( + { limit: 20, search: searchQuery }, + { getNextPageParam: (lastPage) => lastPage.nextCursor } + ); + + const coupons = useMemo(() => data?.pages.flatMap((page) => page.coupons) || [], [data]); + + const getStatus = (coupon: any) => { + if (coupon.isRedeemed) return 'redeemed'; + if (coupon.validTill && new Date(coupon.validTill) <= new Date()) return 'expired'; + return 'active'; + }; + + const filteredCoupons = useMemo(() => { + let filtered = coupons; + if (statusFilters.length > 0) { + filtered = filtered.filter(coupon => statusFilters.includes(getStatus(coupon))); + } + return filtered; + }, [coupons, statusFilters]); + + const handleRefresh = useCallback(async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }, [refetch]); + + useManualRefresh(() => refetch()); + + useMarkDataFetchers(() => { + refetch(); + }); + + if (isLoading) { + return ( + + + Loading Reserved Coupons... + + ); + } + + if (error) { + return ( + + + Failed to load reserved coupons + refetch()} style={tw`bg-red-500`}> + Retry + + + ); + } + + return ( + + + + + + setStatusFilters(value as string[])} + multiple={true} + triggerComponent={({ onPress }) => ( + + + + )} + /> + + item.id.toString()} + renderItem={({ item }) => } + refreshControl={ + + } + contentContainerStyle={tw`px-4 pb-4`} + onEndReached={() => { + if (hasNextPage && !isFetchingNextPage) { + fetchNextPage(); + } + }} + onEndReachedThreshold={0.5} + ListEmptyComponent={ + + + No Reserved Coupons Found + {searchQuery ? ( + setSearchQuery('')} style={tw`bg-gray-500 mt-4`}> + Clear Search + + ) : null} + + } + /> + + ); +}; + +export default function Coupons() { + const router = useRouter(); + const [index, setIndex] = useState(0); + const routes = [ + { key: 'general', title: 'General' }, + { key: 'reserved', title: 'Reserved' }, + ]; + + return ( + + ( + + )} + /> + router.push('/(drawer)/create-coupon')} + activeOpacity={0.95} + style={{ position: 'absolute', bottom: 32, right: 24, zIndex: 100 }} + > + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/coupons/reserved-coupons/index.tsx b/apps/admin-ui/app/(drawer)/coupons/reserved-coupons/index.tsx new file mode 100644 index 0000000..7f1eb81 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/coupons/reserved-coupons/index.tsx @@ -0,0 +1,248 @@ +import React, { useState, useCallback, useMemo } from 'react'; +import { View, TouchableOpacity, Alert, RefreshControl } from 'react-native'; +import { MaterialCommunityIcons } from '@expo/vector-icons'; +import { LinearGradient } from 'expo-linear-gradient'; +import { tw, MyButton, MyText, SearchBar, MyFlatList, useMarkDataFetchers, MyTouchableOpacity, BottomDropdown } from 'common-ui'; +import useManualRefresh from 'common-ui/hooks/useManualRefresh'; +import { trpc } from '@/src/trpc-client'; +import { useRouter } from 'expo-router'; +import { useInfiniteQuery } from '@tanstack/react-query'; + +const ReservedCouponItem = ({ item }: { item: any }) => { + const getStatus = () => { + if (item.isRedeemed) return 'redeemed'; + if (item.validTill && new Date(item.validTill) <= new Date()) return 'expired'; + return 'active'; + }; + + const status = getStatus(); + + const getBorderColor = () => { + if (status === 'active') return 'border-green-500'; + if (status === 'expired') return 'border-yellow-500'; + return 'border-blue-500'; + }; + + const getBgColor = () => { + if (status === 'active') return 'bg-green-100'; + if (status === 'expired') return 'bg-yellow-100'; + return 'bg-blue-100'; + }; + + const getTextColor = () => { + if (status === 'active') return 'text-green-600'; + if (status === 'expired') return 'text-yellow-600'; + return 'text-blue-600'; + }; + + const getIconColor = () => { + if (status === 'active') return '#10b981'; + if (status === 'expired') return '#f59e0b'; + return '#3b82f6'; + }; + + return ( + + + + + + + {item.secretCode} + Coupon: {item.couponCode} + + + + {status === 'active' ? 'Active' : status === 'expired' ? 'Expired' : 'Redeemed'} + + + + + + + Discount: {item.discountPercent ? `${item.discountPercent}% off` : item.flatDiscount ? `₹${item.flatDiscount} off` : 'N/A'} + + + Min Order: {item.minOrder ? `₹${item.minOrder}` : 'None'} + Max: {item.maxValue ? `₹${item.maxValue}` : 'None'} + + + Valid Till: {item.validTill ? new Date(item.validTill).toLocaleDateString() : 'No expiry'} + + + + {item.isRedeemed && item.redeemedUser && ( + + + Redeemed by: {item.redeemedUser.name || 'Unknown'} ({item.redeemedUser.mobile}) + + + Redeemed on: {item.redeemedAt ? new Date(item.redeemedAt).toLocaleDateString() : 'N/A'} + + + )} + + + + Created by: {item.creator?.name || 'Unknown'} + + + + ); +}; + +export default function ReservedCoupons() { + const router = useRouter(); + const [refreshing, setRefreshing] = useState(false); + const [searchQuery, setSearchQuery] = useState(''); + const [statusFilters, setStatusFilters] = useState([]); + + const { + data, + fetchNextPage, + hasNextPage, + isLoading, + isFetchingNextPage, + refetch, + } = trpc.admin.coupon.getReservedCoupons.useInfiniteQuery( + { limit: 50 }, + { + getNextPageParam: (lastPage) => lastPage.nextCursor, + } + ); + + const coupons = data?.pages.flatMap(page => page.coupons) || []; + + const getStatus = (coupon: any) => { + if (coupon.isRedeemed) return 'redeemed'; + if (coupon.validTill && new Date(coupon.validTill) <= new Date()) return 'expired'; + return 'active'; + }; + + const filteredCoupons = useMemo(() => { + let filtered = coupons.filter(coupon => + coupon.secretCode.toLowerCase().includes(searchQuery.toLowerCase()) || + coupon.couponCode.toLowerCase().includes(searchQuery.toLowerCase()) + ); + if (statusFilters.length > 0) { + filtered = filtered.filter(coupon => statusFilters.includes(getStatus(coupon))); + } + return filtered; + }, [coupons, searchQuery, statusFilters]); + + const handleRefresh = useCallback(async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }, [refetch]); + + useManualRefresh(() => refetch()); + + useMarkDataFetchers(() => { + refetch(); + }); + + if (isLoading) { + return ( + + + + + Loading Reserved Coupons... + + ); + } + + return ( + + + + + + setStatusFilters(value as string[])} + multiple={true} + triggerComponent={({ onPress }) => ( + + + + )} + /> + + item.id.toString()} + renderItem={({ item }) => } + refreshControl={ + + } + contentContainerStyle={tw`px-4 pb-4`} + onEndReached={() => { + if (hasNextPage && !isFetchingNextPage) { + fetchNextPage(); + } + }} + onEndReachedThreshold={0.5} + ListEmptyComponent={ + searchQuery ? ( + + + + + No Results + No reserved coupons match “{searchQuery}” + setSearchQuery('')} style={tw`bg-gray-500`}> + Clear Search + + + ) : ( + + + + + No Reserved Coupons Yet + Create your first reserved coupon to start offering secret discounts + router.push('/(drawer)/create-coupon')} style={tw`bg-blue-500`}> + + + Create Reserved Coupon + + + + ) + } + /> + + {/* FAB for Add New Reserved Coupon */} + router.push('/(drawer)/create-coupon')} + activeOpacity={0.95} + style={{ position: 'absolute', bottom: 32, right: 24, zIndex: 100 }} + > + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/create-coupon/_layout.tsx b/apps/admin-ui/app/(drawer)/create-coupon/_layout.tsx new file mode 100644 index 0000000..b95204e --- /dev/null +++ b/apps/admin-ui/app/(drawer)/create-coupon/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/create-coupon/index.tsx b/apps/admin-ui/app/(drawer)/create-coupon/index.tsx new file mode 100644 index 0000000..07523a0 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/create-coupon/index.tsx @@ -0,0 +1,49 @@ +import React from 'react'; +import { View, Alert } from 'react-native'; +import { tw, AppContainer } from 'common-ui'; +import CouponForm from '../../../src/components/CouponForm'; +import { trpc } from '@/src/trpc-client'; +import { useRouter } from 'expo-router'; + +export default function CreateCoupon() { + const router = useRouter(); + const createCoupon = trpc.admin.coupon.create.useMutation(); + const createReservedCoupon = trpc.admin.coupon.createReservedCoupon.useMutation(); + + const handleCreateCoupon = (values: any) => { + console.log('Form values:', values); // Debug log + const { isReservedCoupon, ...rest } = values; + // Transform targetUsers array to targetUser for backend compatibility + const payload = { + ...rest, + targetUser: rest.targetUsers?.[0] || undefined, + }; + delete payload.targetUsers; + console.log('Payload:', payload); // Debug log + + const mutation = isReservedCoupon ? createReservedCoupon : createCoupon; + const isLoading = isReservedCoupon ? createReservedCoupon.isPending : createCoupon.isPending; + + if (isLoading) return; // Prevent double submission + + mutation.mutate(payload, { + onSuccess: () => { + Alert.alert('Success', `${isReservedCoupon ? 'Reserved coupon' : 'Coupon'} created successfully`, [ + { text: 'OK', onPress: () => router.back() } + ]); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to create coupon'); + }, + }); + }; + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/create-product-group.tsx b/apps/admin-ui/app/(drawer)/create-product-group.tsx new file mode 100644 index 0000000..8f2bbd5 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/create-product-group.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { View } from 'react-native'; +import { AppContainer } from 'common-ui'; +import ProductGroupForm from '../../components/ProductGroupForm'; +import { useRouter } from 'expo-router'; + +export default function CreateProductGroup() { + const router = useRouter(); + + return ( + + router.back()} + onSuccess={() => router.back()} + /> + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/customize-app/_layout.tsx b/apps/admin-ui/app/(drawer)/customize-app/_layout.tsx new file mode 100644 index 0000000..913362f --- /dev/null +++ b/apps/admin-ui/app/(drawer)/customize-app/_layout.tsx @@ -0,0 +1,22 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/customize-app/index.tsx b/apps/admin-ui/app/(drawer)/customize-app/index.tsx new file mode 100644 index 0000000..8148277 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/customize-app/index.tsx @@ -0,0 +1,218 @@ +import React from 'react'; +import { View, ScrollView, Alert } from 'react-native'; +import { Formik } from 'formik'; +import { MyText, MyTextInput, MyTouchableOpacity, tw, AppContainer, Checkbox } from 'common-ui'; +import { trpc } from '../../../src/trpc-client'; +import { useRouter } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +interface ConstantFormData { + constants: ConstantItem[]; +} + +interface ConstantItem { + key: string; + value: any; +} + +const CONST_LABELS: Record = { + minRegularOrderValue: 'Minimum Regular Order Value', + freeDeliveryThreshold: 'Free Delivery Threshold', + deliveryCharge: 'Delivery Charge', + flashFreeDeliveryThreshold: 'Flash Free Delivery Threshold', + flashDeliveryCharge: 'Flash Delivery Charge', + platformFeePercent: 'Platform Fee Percent', + taxRate: 'Tax Rate', + minOrderAmountForCoupon: 'Minimum Order Amount for Coupon', + maxCouponDiscount: 'Maximum Coupon Discount', + flashDeliverySlotId: 'Flash Delivery Slot ID', + readableOrderId: 'Readable Order ID', + versionNum: 'Version Number', + playStoreUrl: 'Play Store URL', + appStoreUrl: 'App Store URL', + popularItems: 'Popular Items', + isFlashDeliveryEnabled: 'Enable Flash Delivery', + supportMobile: 'Support Mobile', + supportEmail: 'Support Email', +}; + +interface ConstantInputProps { + constant: ConstantItem; + setFieldValue: (field: string, value: any) => void; + index: number; + router: any; +} + +const ConstantInput: React.FC = ({ constant, setFieldValue, index, router }) => { + const fieldName = `constants.${index}.value`; + + // Special handling for popularItems - show navigation button instead of input + if (constant.key === 'popularItems') { + return ( + + + {CONST_LABELS[constant.key] || constant.key} + + router.push('/(drawer)/customize-app/popular-items')} + style={tw`bg-blue-50 border-2 border-dashed border-blue-200 p-4 rounded-lg flex-row items-center justify-center`} + > + + + Manage Popular Items ({Array.isArray(constant.value) ? constant.value.length : 0} items) + + + + + ); + } + + // Handle boolean values - show checkbox + if (typeof constant.value === 'boolean') { + return ( + + + {CONST_LABELS[constant.key] || constant.key} + + + setFieldValue(fieldName, !constant.value)} + size={28} + /> + + {constant.value ? 'Enabled' : 'Disabled'} + + + + ); + } + + // Handle different value types + if (typeof constant.value === 'number') { + return ( + { + const numValue = parseFloat(value); + setFieldValue(fieldName, isNaN(numValue) ? 0 : numValue); + }} + keyboardType="numeric" + placeholder="Enter number" + /> + ); + } + + if (Array.isArray(constant.value)) { + return ( + { + const arrayValue = value.split(',').map(s => s.trim()).filter(s => s.length > 0); + setFieldValue(fieldName, arrayValue); + }} + placeholder="Enter comma separated values" + /> + ); + } + + // Default to string + return ( + setFieldValue(fieldName, value)} + placeholder="Enter value" + /> + ); +}; + +export default function CustomizeApp() { + const router = useRouter(); + const { data: constants, isLoading: isLoadingConstants, refetch } = trpc.admin.const.getConstants.useQuery(); + const { mutate: updateConstants, isPending: isUpdating } = trpc.admin.const.updateConstants.useMutation(); + + const handleSubmit = (values: ConstantFormData) => { + // Filter out constants that haven't changed + const changedConstants = values.constants.filter((constant, index) => { + const original = constants?.[index]; + return original && JSON.stringify(constant.value) !== JSON.stringify(original.value); + }); + + if (changedConstants.length === 0) { + Alert.alert('No Changes', 'No constants were modified.'); + return; + } + + updateConstants( + { constants: changedConstants }, + { + onSuccess: (response) => { + Alert.alert('Success', `Updated ${response.updatedCount} constants successfully.`); + refetch(); + }, + onError: (error) => { + Alert.alert('Error', 'Failed to update constants. Please try again.'); + console.error('Update constants error:', error); + }, + } + ); + }; + + if (isLoadingConstants) { + return ( + + Loading constants... + + ); + } + + if (!constants) { + return ( + + Failed to load constants + + ); + } + + const initialValues: ConstantFormData = { + constants: constants.map(c => ({ key: c.key, value: c.value ?? '' } as ConstantItem)), + }; + + + + return ( + + + Customize App Constants + + Modify application constants. Changes will take effect immediately. + + + + {({ handleSubmit, values, setFieldValue }) => ( + + {values.constants.map((constant, index) => ( + + + + ))} + + handleSubmit()} + disabled={isUpdating} + style={tw`bg-blue-500 p-4 rounded-lg mt-6 ${isUpdating ? 'opacity-50' : ''}`} + > + + {isUpdating ? 'Updating...' : 'Save Changes'} + + + + )} + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/customize-app/popular-items.tsx b/apps/admin-ui/app/(drawer)/customize-app/popular-items.tsx new file mode 100644 index 0000000..6082bc3 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/customize-app/popular-items.tsx @@ -0,0 +1,439 @@ +import React, { useState, useEffect, useMemo } from "react"; +import { + View, + TouchableOpacity, + Alert, + ActivityIndicator, +} from "react-native"; +import { Image } from "expo-image"; +import DraggableFlatList, { + RenderItemParams, + ScaleDecorator, +} from "react-native-draggable-flatlist"; +import { + AppContainer, + MyText, + tw, + BottomDialog, + BottomDropdown, +} from "common-ui"; +import { useRouter } from "expo-router"; +import { trpc } from "../../../src/trpc-client"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { useQueryClient } from "@tanstack/react-query"; + +interface PopularProduct { + id: number; + name: string; + shortDescription: string | null; + price: string; + marketPrice: string | null; + unit: string; + incrementStep: number; + productQuantity: number; + storeId: number | null; + isOutOfStock: boolean; + nextDeliveryDate: string | null; + images: string[]; +} + +interface ProductItemProps { + item: PopularProduct; + drag: () => void; + isActive: boolean; + onDelete: (id: number) => void; +} + +const ProductItem: React.FC = ({ + item, + drag, + isActive, + onDelete, +}) => { + return ( + + + + + {/* Drag Handle */} + + + + + {/* Product Image */} + {item.images?.[0] ? ( + + ) : ( + + + + )} + + {/* Product Info */} + + + {item.name} + + + ₹{item.price} + + + + {/* Delete Button */} + onDelete(item.id)} + style={tw`p-2 ml-2`} + > + + + + + + + ); +}; + +export default function CustomizePopularItems() { + const router = useRouter(); + const queryClient = useQueryClient(); + const [popularProducts, setPopularProducts] = useState([]); + const [hasChanges, setHasChanges] = useState(false); + const [showAddDialog, setShowAddDialog] = useState(false); + const [selectedProductId, setSelectedProductId] = useState(null); + + // Get current popular items from constants + const { data: constants, isLoading: isLoadingConstants, error: constantsError } = trpc.admin.const.getConstants.useQuery(); + const { data: allProducts, isLoading: isLoadingProducts, error: productsError } = trpc.common.product.getAllProductsSummary.useQuery({}); + const updateConstants = trpc.admin.const.updateConstants.useMutation(); + + // Initialize popular products from constants + useEffect(() => { + if (constants && allProducts?.products) { + const popularItemsConstant = constants.find(c => c.key === 'popularItems'); + + let popularIds: number[] = []; + + if (popularItemsConstant) { + const value = popularItemsConstant.value; + + if (Array.isArray(value)) { + // Already an array of IDs + popularIds = value.map((id: any) => parseInt(id)); + } else if (typeof value === 'string') { + // Comma-separated string + popularIds = value.split(',').map((id: string) => parseInt(id.trim())).filter(id => !isNaN(id)); + } + + const popularProds: PopularProduct[] = []; + + for (const id of popularIds) { + const product = allProducts.products.find(p => p.id === id); + if (product) { + popularProds.push(product); + } + } + + setPopularProducts(popularProds); + } + } + }, [constants, allProducts]); + + const handleDragEnd = ({ data }: { data: PopularProduct[] }) => { + setPopularProducts(data); + setHasChanges(true); + }; + + const handleDelete = (productId: number) => { + Alert.alert( + "Remove Product", + "Are you sure you want to remove this product from popular items?", + [ + { text: "Cancel", style: "cancel" }, + { + text: "Remove", + style: "destructive", + onPress: () => { + setPopularProducts(prev => prev.filter(p => p.id !== productId)); + setHasChanges(true); + } + } + ] + ); + }; + + const handleAddProduct = () => { + if (selectedProductId) { + const product = allProducts?.products.find(p => p.id === selectedProductId); + if (product && !popularProducts.find(p => p.id === product.id)) { + setPopularProducts(prev => [...prev, product as PopularProduct]); + setHasChanges(true); + setSelectedProductId(null); + setShowAddDialog(false); + } + } + }; + + const handleSave = () => { + const popularIds = popularProducts.map(p => p.id); + + updateConstants.mutate( + { + constants: [{ + key: 'popularItems', + value: popularIds + }] + }, + { + onSuccess: () => { + setHasChanges(false); + Alert.alert('Success', 'Popular items updated successfully!'); + queryClient.invalidateQueries({ queryKey: ['const.getConstants'] }); + }, + onError: (error) => { + Alert.alert('Error', 'Failed to update popular items. Please try again.'); + console.error('Update popular items error:', error); + } + } + ); + }; + + const availableProducts = (allProducts?.products || []).filter( + product => !popularProducts.find(p => p.id === product.id) + ); + + const productOptions = availableProducts.map(product => ({ + label: `${product.name} - ₹${product.price}`, + value: product.id, + })); + + // Show loading state while data is being fetched + if (isLoadingConstants || isLoadingProducts) { + return ( + + + {/* Header */} + + router.back()} + style={tw`p-2 -ml-4`} + > + + + + Popular Items + + {/* Spacer for centering */} + + + {/* Loading Content */} + + + + {isLoadingConstants ? 'Loading constants...' : 'Loading products...'} + + + + + ); + } + + // Show error state if queries failed + if (constantsError || productsError) { + return ( + + + {/* Header */} + + router.back()} + style={tw`p-2 -ml-4`} + > + + + + Popular Items + + {/* Spacer for centering */} + + + {/* Error Content */} + + + Error + + {constantsError ? 'Failed to load constants' : 'Failed to load products'} + + router.back()} + style={tw`mt-6 bg-blue-600 px-6 py-3 rounded-full`} + > + Go Back + + + + + ); + } + + return ( + + + {/* Header */} + + router.back()} + style={tw`p-2 -ml-4`} + > + + + + Popular Items + + + + {updateConstants.isPending ? 'Saving...' : 'Save'} + + + + + {/* Content */} + {popularProducts.length === 0 ? ( + + + + No popular items configured + + + Add products to display as popular items + + + ) : ( + + + + Long press an item to drag and reorder + + + + ( + + )} + keyExtractor={(item) => item.id.toString()} + onDragEnd={handleDragEnd} + showsVerticalScrollIndicator={false} + contentContainerStyle={tw`pb-8`} + /> + + )} + + {/* FAB for Add Product */} + + setShowAddDialog(true)} + style={tw`bg-blue-600 p-4 rounded-full shadow-lg`} + > + + + + + {/* Add Product Dialog */} + setShowAddDialog(false)} + > + + + + + Add Popular Item + + + Select a product to add to popular items + + + + {availableProducts.length === 0 ? ( + + + + All products are already in popular items + + + ) : ( + <> + setSelectedProductId(val as number)} + placeholder="Choose a product..." + /> + + + setShowAddDialog(false)} + style={tw`flex-1 bg-gray-100 p-3 rounded-lg`} + > + + Cancel + + + + + + Add Product + + + + + )} + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard-banners/_layout.tsx b/apps/admin-ui/app/(drawer)/dashboard-banners/_layout.tsx new file mode 100644 index 0000000..44dc7e9 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard-banners/_layout.tsx @@ -0,0 +1,11 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/_layout.tsx b/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/_layout.tsx new file mode 100644 index 0000000..3d5bd69 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/index.tsx b/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/index.tsx new file mode 100644 index 0000000..bf4f606 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard-banners/create-banner/index.tsx @@ -0,0 +1,82 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity, Alert } from 'react-native'; +import { AppContainer, MyText, tw } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { useRouter } from 'expo-router'; +import { FormikHelpers } from 'formik'; +import BannerForm, { BannerFormData } from '@/components/BannerForm'; +import { trpc } from '../../../../src/trpc-client'; + +export default function CreateBanner() { + const router = useRouter(); + const [isSubmitting, setIsSubmitting] = useState(false); + + const initialValues: BannerFormData = { + name: '', + imageUrl: '', + description: '', + productIds: [], + redirectUrl: '', + // serialNum removed - assigned automatically by backend + }; + + const createBannerMutation = trpc.admin.banner.createBanner.useMutation(); + + const handleSubmit = async (values: BannerFormData, imageUrl?: string) => { + if (!imageUrl) { + Alert.alert('Error', 'Image is required'); + return; + } + + setIsSubmitting(true); + + try { + await createBannerMutation.mutateAsync({ + name: values.name, + imageUrl, + description: values.description || undefined, + productIds: values.productIds.length > 0 ? values.productIds : [], + redirectUrl: values.redirectUrl || undefined, + }); + + Alert.alert('Success', 'Banner created successfully', [ + { + text: 'OK', + onPress: () => router.back(), + } + ]); + } catch (error) { + + Alert.alert('Error', 'Failed to create banner. Please try again.'); + } finally { + setIsSubmitting(false); + } + }; + + const handleCancel = () => { + router.back(); + }; + + return ( + + + {/* Header */} + + + + + Create Banner + + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/[id].tsx b/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/[id].tsx new file mode 100644 index 0000000..b53360e --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/[id].tsx @@ -0,0 +1,163 @@ +import React, { useState, useEffect } from 'react'; +import { View, TouchableOpacity, Alert } from 'react-native'; +import { AppContainer, MyText, tw } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { FormikHelpers } from 'formik'; +import BannerForm, { BannerFormData } from '@/components/BannerForm'; +import { trpc } from '../../../../src/trpc-client'; + +interface Banner { + id: number; + name: string; + imageUrl: string; + description?: string; + productIds?: number[]; + redirectUrl?: string; + serialNum: number; + isActive: boolean; + createdAt: string; + lastUpdated: string; +} + +export default function EditBanner() { + const router = useRouter(); + const { id } = useLocalSearchParams(); + const bannerId = id as string; + + const [isLoading, setIsLoading] = useState(true); + const [isSubmitting, setIsSubmitting] = useState(false); + // Load real banner data from API + const {data: bannerData } = trpc.admin.banner.getBanner.useQuery({ + id: parseInt(bannerId) + }); + const [banner, setBanner] = useState(undefined); + + + useEffect(() => { + const loadBanner = async () => { + try { + setIsLoading(true); + + + + if (bannerData) { + // Handle data format compatibility (productId -> productIds migration) + const processedBanner = { + ...bannerData, + productIds: Array.isArray(bannerData.productIds) + ? bannerData.productIds + : (bannerData.productIds ? [bannerData.productIds] : []) + }; + + setBanner(processedBanner); + } else { + Alert.alert('Error', 'Banner not found'); + router.back(); + } + } catch (error) { + console.error('Failed to load banner:', error); + Alert.alert('Error', 'Failed to load banner data'); + router.back(); + } finally { + setIsLoading(false); + } + }; + + loadBanner(); + }, [bannerId, bannerData]); + + const initialValues: BannerFormData = banner ? { + name: banner.name, + imageUrl: banner.imageUrl, + description: banner.description || '', + productIds: banner.productIds || [], + redirectUrl: banner.redirectUrl || '', + // serialNum removed - handled automatically by backend + } : { + name: '', + imageUrl: '', + description: '', + productIds: [], + redirectUrl: '', + // serialNum removed - handled automatically by backend + }; + + const updateBannerMutation = trpc.admin.banner.updateBanner.useMutation(); + + const handleSubmit = async (values: BannerFormData, imageUrl?: string) => { + if (!banner) return; + + setIsSubmitting(true); + + try { + await updateBannerMutation.mutateAsync({ + id: banner.id, + name: values.name, + imageUrl: imageUrl || banner.imageUrl, + description: values.description || undefined, + productIds: values.productIds.length > 0 ? values.productIds : [], + redirectUrl: values.redirectUrl || undefined, + }); + + Alert.alert('Success', 'Banner updated successfully', [ + { + text: 'OK', + onPress: () => router.back(), + } + ]); + } catch (error) { + Alert.alert('Error', 'Failed to update banner. Please try again.'); + } finally { + setIsSubmitting(false); + } + }; + + const handleCancel = () => { + router.back(); + }; + + if (isLoading) { + return ( + + + Loading banner... + + + ); + } + + if (!banner) { + return ( + + + Banner not found + + + ); + } + + return ( + + + {/* Header */} + + + + + Edit Banner + + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/_layout.tsx b/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/_layout.tsx new file mode 100644 index 0000000..1e4f7b1 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard-banners/edit-banner/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard-banners/index.tsx b/apps/admin-ui/app/(drawer)/dashboard-banners/index.tsx new file mode 100644 index 0000000..4123c9a --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard-banners/index.tsx @@ -0,0 +1,467 @@ +import React, { useState } from 'react'; +import { View, ScrollView, TouchableOpacity, Alert, Image, RefreshControl } from 'react-native'; +import { AppContainer, MyText, tw, MyTouchableOpacity } from 'common-ui'; +import { trpc } from '../../../src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { useRouter } from 'expo-router'; + +interface Banner { + id: number; + name: string; + imageUrl: string; + description: string | null; + productIds: number[] | null; + redirectUrl: string | null; + serialNum: number | null; + isActive: boolean; + createdAt: string; + lastUpdated: string; +} + +export default function DashboardBanners() { + const router = useRouter(); + const [refreshing, setRefreshing] = useState(false); + + // Edit mode state + const [editMode, setEditMode] = useState(false); + const [selectedSlot, setSelectedSlot] = useState(null); + const [slotAssignments, setSlotAssignments] = useState<{[slot: number]: number | null}>({}); + const [originalAssignments, setOriginalAssignments] = useState<{[slot: number]: number | null}>({}); + const [saving, setSaving] = useState(false); + + // Real API calls + const { data: bannersData, isLoading, error, refetch } = trpc.admin.banner.getBanners.useQuery(); + + const deleteBannerMutation = trpc.admin.banner.deleteBanner.useMutation(); + const updateBannerMutation = trpc.admin.banner.updateBanner.useMutation(); + const emptySlotMutation = trpc.admin.banner.updateBanner.useMutation(); + + const banners = bannersData?.banners || []; + + // Initialize slot assignments when banners load + React.useEffect(() => { + const assignments: {[slot: number]: number | null} = {1: null, 2: null, 3: null, 4: null}; + banners.forEach(banner => { + if (banner.serialNum && banner.serialNum >= 1 && banner.serialNum <= 4) { + assignments[banner.serialNum] = banner.id; + } + }); + setSlotAssignments(assignments); + setOriginalAssignments({...assignments}); + }, [bannersData]); + + const onRefresh = async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }; + + // Slot and edit mode handlers + const handleSlotClick = (slotNumber: number) => { + setSelectedSlot(slotNumber); + setEditMode(true); + }; + + const handleBannerSelect = (bannerId: number) => { + if (!editMode || selectedSlot === null) return; + + // Remove banner from any existing slot + const newAssignments = {...slotAssignments}; + Object.keys(newAssignments).forEach(slot => { + if (newAssignments[parseInt(slot)] === bannerId) { + newAssignments[parseInt(slot)] = null; + } + }); + + // Assign banner to selected slot + newAssignments[selectedSlot] = bannerId; + setSlotAssignments(newAssignments); + }; + + const handleSave = async () => { + setSaving(true); + try { + // Get banners that need to be updated + const bannersToUpdate: {id: number, serialNum: number | null}[] = []; + + // Clear serial numbers for banners no longer in slots + banners.forEach(banner => { + const currentSlot = banner.serialNum; + const assignedSlot = Object.keys(slotAssignments).find(slot => + slotAssignments[parseInt(slot)] === banner.id + ); + + if (currentSlot !== (assignedSlot ? parseInt(assignedSlot) : null)) { + bannersToUpdate.push({ + id: banner.id, + serialNum: assignedSlot ? parseInt(assignedSlot) : null + }); + } + }); + + // Update banners that gained slots + Object.keys(slotAssignments).forEach(slot => { + const slotNum = parseInt(slot); + const bannerId = slotAssignments[slotNum]; + if (bannerId) { + const banner = banners.find(b => b.id === bannerId); + if (banner && banner.serialNum !== slotNum) { + bannersToUpdate.push({ + id: bannerId, + serialNum: slotNum + }); + } + } + }); + + // Execute updates + await Promise.all( + bannersToUpdate.map(({id, serialNum}) => + updateBannerMutation.mutateAsync({ id, serialNum }) + ) + ); + + setOriginalAssignments({...slotAssignments}); + setEditMode(false); + setSelectedSlot(null); + await refetch(); + Alert.alert('Success', 'Slot assignments saved successfully'); + } catch (error) { + Alert.alert('Error', 'Failed to save slot assignments'); + } finally { + setSaving(false); + } + }; + + const handleCancel = () => { + setSlotAssignments({...originalAssignments}); + setEditMode(false); + setSelectedSlot(null); + }; + + const handleEmptySlot = async () => { + if (!selectedSlot || !slotAssignments[selectedSlot]) return; + + const bannerId = slotAssignments[selectedSlot]; + const banner = banners.find(b => b.id === bannerId); + + if (!banner) return; + + try { + // Update banner's serialNum to null to empty the slot + await emptySlotMutation.mutateAsync({ + id: banner.id, + serialNum: null + }); + + // Update local state + setSlotAssignments(prev => ({ + ...prev, + [selectedSlot]: null + })); + + // Update original assignments for cancel functionality + setOriginalAssignments(prev => ({ + ...prev, + [selectedSlot]: null + })); + + Alert.alert('Success', `Slot ${selectedSlot} has been emptied`); + } catch (error) { + Alert.alert('Error', 'Failed to empty slot'); + } + }; + + // Helper function to get banner name by ID + const getBannerNameById = (id: number | null) => { + if (!id) return null; + const banner = banners.find(b => b.id === id); + return banner ? banner.name : null; + }; + + const handleEdit = (banner: Banner) => { + router.push(`/dashboard-banners/edit-banner/${banner.id}` as any); + }; + + const handleDelete = (id: number) => { + Alert.alert( + 'Delete Banner', + 'Are you sure you want to delete this banner?', + [ + { text: 'Cancel', style: 'cancel' }, + { + text: 'Delete', + style: 'destructive', + onPress: async () => { + try { + await deleteBannerMutation.mutateAsync({ id }); + refetch(); + Alert.alert('Success', 'Banner deleted'); + } catch (error) { + Alert.alert('Error', 'Failed to delete banner'); + } + } + } + ] + ); + }; + + const handleCreate = () => { + router.push('/(drawer)/dashboard-banners/create-banner' as any); + }; + + if (isLoading) { + return ( + + + Loading banners... + + + ); + } + + if (error) { + return ( + + + Error loading banners + + + ); + } + + return ( + + + + } + > + {/* Header */} + {/* + All Banners + + + + + Add New Banner + + + */} + + {/* Slots Row */} + + + {editMode ? `Select banner for Slot ${selectedSlot}` : 'Banner Slots'} + + + {[1, 2, 3, 4].map(slotNum => { + const assignedBannerId = slotAssignments[slotNum]; + const bannerName = getBannerNameById(assignedBannerId); + const isSelected = editMode && selectedSlot === slotNum; + + return ( + handleSlotClick(slotNum)} + style={tw`flex-1 mx-1 p-3 rounded-lg border-2 ${ + isSelected + ? 'border-blue-500 bg-blue-50' + : assignedBannerId + ? 'border-green-300 bg-green-50' + : 'border-gray-300 bg-white' + }`} + > + + Slot {slotNum} + + {bannerName || 'Empty'} + + + + ); + })} + + + {/* Action buttons in edit mode */} + {editMode && ( + + {/* Save/Cancel buttons */} + + + Cancel + + + + {saving ? 'Saving...' : 'Save Changes'} + + + + + {/* Empty Slot button */} + + + + + {emptySlotMutation.isPending ? 'Emptying...' : 'Empty Slot'} + + + + + )} + + + {/* Banners List */} + + {editMode && ( + + + Tap a banner below to assign it to Slot {selectedSlot} + + + )} + + {banners.length === 0 ? ( + + + + + No Banners Yet + + Start by creating your first banner using the button above. + + + ) : ( + banners.map((banner) => { + const isAssignedToSlot = Object.values(slotAssignments).includes(banner.id); + const isAssignedToSelectedSlot = slotAssignments[selectedSlot || 0] === banner.id; + const canInteract = editMode; + + return ( + handleBannerSelect(banner.id) : undefined} + disabled={!canInteract} + style={tw`bg-white rounded-xl p-4 mb-3 shadow-sm border ${ + canInteract && isAssignedToSelectedSlot + ? 'border-blue-500 bg-blue-50' + : canInteract && isAssignedToSlot + ? 'border-green-300 bg-green-50' + : canInteract + ? 'border-gray-200' + : 'border-gray-100' + }`} + > + + + + + + {banner.name} + + + {canInteract && isAssignedToSelectedSlot && ( + + + + )} + {canInteract && isAssignedToSlot && !isAssignedToSelectedSlot && ( + + + + )} + + {!editMode && ( + <> + handleEdit(banner)} style={tw`p-1 mr-1`}> + + + handleDelete(banner.id)} style={tw`p-1`}> + + + + )} + + + {banner.description && ( + + {banner.description} + + )} + + + Created: {new Date(banner.createdAt).toLocaleDateString()} + + {banner.serialNum && banner.serialNum >= 1 && banner.serialNum <= 4 && ( + + Slot {banner.serialNum} + + )} + + + + + ); + }) + )} + + + + {/* Floating Action Button */} + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard/_layout.tsx b/apps/admin-ui/app/(drawer)/dashboard/_layout.tsx new file mode 100644 index 0000000..c9990f0 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/dashboard/index.tsx b/apps/admin-ui/app/(drawer)/dashboard/index.tsx new file mode 100644 index 0000000..55d5b4a --- /dev/null +++ b/apps/admin-ui/app/(drawer)/dashboard/index.tsx @@ -0,0 +1,241 @@ +import React from 'react'; +import { View, ScrollView, Pressable } from 'react-native'; +import { useRouter } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { MyText, tw } from 'common-ui'; +import { LinearGradient } from 'expo-linear-gradient'; +import { theme } from 'common-ui/src/theme'; + +interface MenuItem { + title: string; + icon: string; + description?: string; + route: string; + category: 'quick' | 'products' | 'orders' | 'marketing' | 'settings'; + iconColor?: string; + iconBg?: string; +} + +interface MenuItemComponentProps { + item: MenuItem; + router: any; +} + +const MenuItemComponent: React.FC = ({ item, router }) => ( + router.push(item.route as any)} + style={({ pressed }) => [ + tw`flex-row items-center p-4 bg-white border border-gray-100 rounded-xl mb-3 shadow-sm`, + pressed && tw`bg-gray-50`, + ]} + > + + + + + {item.title} + {item.description && ( + {item.description} + )} + + + +); + +export default function Dashboard() { + const router = useRouter(); + + const menuItems: MenuItem[] = [ + { + title: 'Manage Orders', + icon: 'shopping-bag', + description: 'View and manage customer orders', + route: '/(drawer)/orders', + category: 'orders', + iconColor: '#10B981', + iconBg: '#D1FAE5', + }, + { + title: 'Delivery Sequences', + icon: 'alt-route', + description: 'Plan and optimize delivery routes', + route: '/(drawer)/delivery-sequences', + category: 'orders', + iconColor: '#8B5CF6', + iconBg: '#EDE9FE', + }, + { + title: 'Delivery Slots', + icon: 'schedule', + description: 'Configure delivery times', + route: '/(drawer)/slots' as any, + category: 'quick', + iconColor: '#06B6D4', + iconBg: '#CFFAFE', + }, + { + title: 'Add Product', + icon: 'add-circle', + description: 'Create a new product listing', + route: '/(drawer)/add-product', + category: 'quick', + iconColor: theme.colors.brand500, + iconBg: theme.colors.brand50, + }, + { + title: 'Complaints', + icon: 'report-problem', + description: 'Handle customer complaints', + route: '/(drawer)/complaints', + category: 'quick', + iconColor: '#F59E0B', + iconBg: '#FEF3C7', + }, + { + title: 'Products', + icon: 'inventory-2', + description: 'Manage product catalog', + route: '/(drawer)/products', + category: 'products', + iconColor: '#6366F1', + iconBg: '#E0E7FF', + }, + { + title: 'Prices Overview', + icon: 'attach-money', + description: 'Update product pricing', + route: '/(drawer)/prices-overview', + category: 'products', + iconColor: '#059669', + iconBg: '#ECFDF5', + }, + { + title: 'Product Tags', + icon: 'label', + description: 'Organize with tags', + route: '/(drawer)/product-tags', + category: 'products', + iconColor: '#EC4899', + iconBg: '#FCE7F3', + }, + { + title: 'Product Groupings', + icon: 'category', + description: 'Group products together', + route: '/(drawer)/product-groupings', + category: 'products', + iconColor: '#8B5CF6', + iconBg: '#F3E8FF', + }, + { + title: 'Stores', + icon: 'store', + description: 'Manage store locations', + route: '/(drawer)/stores', + category: 'settings', + iconColor: '#14B8A6', + iconBg: '#CCFBF1', + }, + { + title: 'Coupons', + icon: 'local-offer', + description: 'Create discount coupons', + route: '/(drawer)/coupons', + category: 'marketing', + iconColor: '#F97316', + iconBg: '#FFEDD5', + }, + { + title: 'Address Management', + icon: 'location-on', + description: 'Manage service areas', + route: '/(drawer)/address-management', + category: 'settings', + iconColor: '#EAB308', + iconBg: '#FEF9C3', + }, + { + title: 'App Constants', + icon: 'settings-applications', + description: 'Customize app settings', + route: '/(drawer)/customize-app', + category: 'settings', + iconColor: '#7C3AED', + iconBg: '#F3E8FF', + }, + ]; + + const quickActions = menuItems.filter(item => item.category === 'quick'); + + const categories = [ + { key: 'orders', title: 'Orders', icon: 'receipt-long' }, + { key: 'products', title: 'Products & Inventory', icon: 'inventory' }, + { key: 'marketing', title: 'Marketing & Promotions', icon: 'campaign' }, + { key: 'settings', title: 'Settings & Configuration', icon: 'settings' }, + ]; + + + + return ( + + + {/* Header with Gradient */} + {/* + Dashboard + Manage your business operations + */} + + {/* Quick Actions */} + + Quick Actions + + {quickActions.map((item) => ( + router.push(item.route as any)} + style={({ pressed }) => [ + tw`bg-white rounded-xl p-3 shadow-sm border border-gray-100 items-center`, + { width: 'calc(25% - 9px)' }, + pressed && tw`bg-gray-50`, + ]} + > + + + + + {item.title} + + + ))} + + + + {/* Categorized Menu Items */} + + {categories.map((category) => { + const categoryItems = menuItems.filter(item => item.category === category.key); + if (categoryItems.length === 0) return null; + + return ( + + + + + + {category.title} + + {categoryItems.map(item => )} + + ); + })} + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/delivery-sequences/_layout.tsx b/apps/admin-ui/app/(drawer)/delivery-sequences/_layout.tsx new file mode 100644 index 0000000..36149c3 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/delivery-sequences/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/delivery-sequences/index.tsx b/apps/admin-ui/app/(drawer)/delivery-sequences/index.tsx new file mode 100644 index 0000000..afb2c3c --- /dev/null +++ b/apps/admin-ui/app/(drawer)/delivery-sequences/index.tsx @@ -0,0 +1,978 @@ +import React, { useState, useEffect, useMemo } from "react"; +import { + View, + TouchableOpacity, + Alert, + ActivityIndicator, + Linking, +} from "react-native"; +import DraggableFlatList, { + RenderItemParams, + ScaleDecorator, +} from "react-native-draggable-flatlist"; +import { + AppContainer, + MyText, + tw, + useManualRefresh, + useMarkDataFetchers, + BottomDialog, + Checkbox, + BottomDropdown, +} from "common-ui"; +import { useQueryClient } from "@tanstack/react-query"; +import dayjs from "dayjs"; +import { useLocalSearchParams, useRouter } from "expo-router"; +import { trpc } from "@/src/trpc-client"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import Entypo from "@expo/vector-icons/Entypo"; +import * as Location from "expo-location"; + +// Define types outside +interface OrderWithSequence { + sequenceId: number; + readableId: number; + isPackaged: boolean; + totalAmount: number; + address: string; + latitude: number | null; + longitude: number | null; + id: number; + isDelivered: boolean; + addressId: number; + adminNotes?: string | null; + customerName?: string | null; + assignedUserName?: string | null; +} + +interface SlotProgressProps { + slotId: number; + orders: any[]; +} + +const SlotProgress: React.FC = ({ slotId, orders }) => { + const delivered = orders.filter((o) => o.isDelivered).length; + const undelivered = orders.filter((o) => !o.isDelivered).length; + const packaged = orders.filter((o) => o.isPackaged).length; + const notPackaged = orders.filter((o) => !o.isPackaged).length; + + const stats = [ + { label: "Delivered", value: delivered }, + { label: "Undelivered", value: undelivered }, + { label: "Packaged", value: packaged }, + { label: "Not Packaged", value: notPackaged }, + ]; + + return ( + + + Slot {slotId} Statistics + + + {stats.map((stat, index) => ( + + + + {stat.value} + + {stat.label} + + + ))} + + + ); +}; + +interface OrderItemProps { + item: OrderWithSequence; + drag: () => void; + isActive: boolean; + isPending: boolean; + setSelectedOrder: (order: OrderWithSequence | null) => void; + setShowOrderMenu: (show: boolean) => void; + selectedOrderIds: number[]; + onToggleOrder: (id: number) => void; + assignedUserName?: string | null; + staffData?: { staff?: Array<{ id: number; name: string }> }; + setSelectedUserId?: (id: number) => void; +} + +const OrderItem: React.FC = ({ + item, + drag, + isActive, + isPending, + setSelectedOrder, + setShowOrderMenu, + selectedOrderIds, + onToggleOrder, + assignedUserName, + staffData, + setSelectedUserId, +}) => { + const orderItem = item; + + return ( + + + + + {/* Checkbox and Drag Handle */} + + onToggleOrder(orderItem.id)} + size={20} + fillColor="#3b82f6" + checkColor="#FFFFFF" + /> + + + + + + {/* Content */} + + + + + #{orderItem.readableId} + + + + Pkg + + + + {/* Optional: Add time if available, or just keep ID */} + + + + + ₹{orderItem.totalAmount} + + + { + setSelectedOrder(orderItem); + setShowOrderMenu(true); + }} + style={tw`p-2`} + > + + + + + + + + + {orderItem.address} + + {orderItem.latitude && orderItem.longitude && ( + { + Linking.openURL( + `https://www.google.com/maps?q=${orderItem.latitude},${orderItem.longitude}` + ); + }} + style={tw`ml-2`} + > + + + )} + + {assignedUserName && ( + + + Assigned to{" "} + + { + const assignedUserId = staffData?.staff?.find( + (s: { id: number; name: string }) => s.name === assignedUserName + )?.id; + if (assignedUserId && setSelectedUserId) { + setSelectedUserId(assignedUserId); + } + }} + > + + {assignedUserName} + + + + )} + + + {/* Admin Notes */} + {orderItem.adminNotes && ( + + + {orderItem.adminNotes} + + + )} + + + + ); +}; + +export default function DeliverySequences() { + const { slotId } = useLocalSearchParams(); + const selectedSlotId = slotId ? Number(slotId) : null; + const [localOrderedOrders, setLocalOrderedOrders] = useState< + OrderWithSequence[] + >([]); + const [showOrderMenu, setShowOrderMenu] = useState(false); + const [selectedOrder, setSelectedOrder] = useState( + null + ); + const [selectedUserId, setSelectedUserId] = useState(-1); + const [selectedOrderIds, setSelectedOrderIds] = useState([]); + const [hasSequenceChanged, setHasSequenceChanged] = useState(false); + const router = useRouter(); + + const { data: slotsData, refetch: refetchSlots } = + trpc.admin.slots.getAll.useQuery(); + const { + data: ordersData, + isLoading: ordersLoading, + refetch: refetchOrders, + } = trpc.admin.order.getSlotOrders.useQuery( + { slotId: String(selectedSlotId) }, + { + enabled: !!selectedSlotId, + } + ); + const { data: sequenceData, refetch: refetchSequence } = + trpc.admin.slots.getDeliverySequence.useQuery( + { id: String(selectedSlotId) }, + { + enabled: !!selectedSlotId, + } + ); + + const { data: staffData } = trpc.admin.staffUser.getStaff.useQuery(); + + // Auto-select first slot if no slotId provided + useEffect(() => { + if (!slotId && slotsData?.slots && slotsData.slots.length > 0) { + router.replace(`/delivery-sequences?slotId=${slotsData.slots[0].id}`); + } + }, [slotId, slotsData, router]); + + const updateSequenceMutation = + trpc.admin.slots.updateDeliverySequence.useMutation(); + const updatePackagedMutation = trpc.admin.order.updatePackaged.useMutation(); + const updateDeliveredMutation = + trpc.admin.order.updateDelivered.useMutation(); + const updateAddressCoordsMutation = + trpc.admin.order.updateAddressCoords.useMutation(); + + // Manual refresh functionality + useManualRefresh(() => { + refetchSlots(); + refetchOrders(); + refetchSequence(); + }); + + useMarkDataFetchers(() => { + refetchSlots(); + refetchOrders(); + refetchSequence(); + }); + + const slots = slotsData?.slots || []; + const orders = ordersData?.data || []; + const deliverySequence = sequenceData?.deliverySequence || []; + + const slotOptions = + slots?.map((slot) => ({ + label: dayjs(slot.deliveryTime).format("ddd DD MMM, h:mm a"), + value: slot.id, + })) || []; + + const userOptions = [ + { label: "Unassigned", value: -1 }, + { label: "All Users", value: -2 }, + ...(staffData?.staff?.map((staff) => ({ + label: staff.name, + value: staff.id, + })) || []), + ]; + + // Create ordered orders based on delivery sequence + const computedOrderedOrders = useMemo(() => { + if (orders.length > 0) { + const userSequence = + selectedUserId !== -1 + ? (deliverySequence as any)?.[String(selectedUserId)] || [] + : null; + if (selectedUserId !== -1 && userSequence && userSequence.length > 0) { + // Sort orders according to user's sequence + const sequenceMap = new Map( + userSequence.map((id: number, index: number) => [id, index]) + ); + let ordered = orders + .filter((order) => userSequence.includes(order.id)) + .map((order) => ({ ...order, sequenceId: order.id })) + .sort((a, b) => { + const aIndex = sequenceMap.get(a.sequenceId) ?? Infinity; + const bIndex = sequenceMap.get(b.sequenceId) ?? Infinity; + return aIndex < bIndex ? -1 : aIndex > bIndex ? 1 : 0; + }); + return ordered; + } else if (selectedUserId === -1) { + // Show unassigned orders (not in any user's sequence) + const assignedIds = new Set( + Object.values(deliverySequence as any).flat() + ); + let ordered = orders + .filter((order) => !assignedIds.has(order.id)) + .map((order) => ({ ...order, sequenceId: order.id })) + .sort((a, b) => + a.sequenceId < b.sequenceId + ? -1 + : a.sequenceId > b.sequenceId + ? 1 + : 0 + ); + return ordered; + } else if (selectedUserId === -2) { + // Show all orders with assignment info + const orderToUserMap = new Map(); + Object.entries(deliverySequence as any).forEach(([userId, orderIds]) => { + (orderIds as number[]).forEach((orderId) => { + orderToUserMap.set(orderId, parseInt(userId)); + }); + }); + let ordered = orders + .map((order) => { + const assignedUserId = orderToUserMap.get(order.id); + const assignedUser = staffData?.staff?.find( + (s) => s.id === assignedUserId + ); + return { + ...order, + sequenceId: order.id, + assignedUserName: assignedUser?.name || null, + }; + }) + .sort((a, b) => + a.sequenceId < b.sequenceId + ? -1 + : a.sequenceId > b.sequenceId + ? 1 + : 0 + ); + return ordered; + } else { + // No sequence for user, show empty + return []; + } + } else { + return []; + } + }, [ordersData, sequenceData, selectedUserId]); + + // Sync local state with computed orders + useEffect(() => { + setLocalOrderedOrders(computedOrderedOrders); + }, [computedOrderedOrders]); + + const handleDragEnd = ({ data }: { data: OrderWithSequence[] }) => { + if (selectedUserId !== -1 && selectedUserId !== -2) { + setLocalOrderedOrders(data); + setHasSequenceChanged(true); + } + }; + + const handleSaveSequence = () => { + if (!selectedSlotId || selectedUserId === -1) return; + + const newSequence = { ...(deliverySequence as any) }; + newSequence[String(selectedUserId)] = localOrderedOrders.map( + (order) => order.sequenceId + ); + + updateSequenceMutation.mutate( + { + id: selectedSlotId, + deliverySequence: newSequence, + }, + { + onSuccess: () => { + setHasSequenceChanged(false); + Alert.alert("Success", "Delivery sequence updated successfully"); + }, + onError: (error: any) => { + Alert.alert( + "Error", + `Failed to update delivery sequence: ${ + error.message || "Unknown error" + }` + ); + }, + } + ); + }; + + if (!slotsData) { + return ( + + + Loading slots... + + ); + } + + if (slotsData.slots.length === 0) { + return ( + + + + No slots available + + + ); + } + + return ( + + {selectedSlotId ? ( + <> + {/* Header Section */} + + router.back()} + style={tw`p-2 -ml-4`} + accessibilityLabel="Go back" + > + + + + + { + if (val) { + router.replace(`/delivery-sequences?slotId=${val}`); + } + }} + placeholder="Select slot" + /> + + + setSelectedUserId(val as number)} + placeholder="Select user" + /> + + + + {/* Content Section */} + {ordersLoading ? ( + + + Loading orders... + + ) : localOrderedOrders.length === 0 ? ( + + + + No orders found for this slot + + + ) : ( + + {/* + + Long press an item to drag and reorder + + */} + ( + { + setSelectedOrderIds((prev) => + prev.includes(id) + ? prev.filter((i) => i !== id) + : [...prev, id] + ); + }} + assignedUserName={selectedUserId === -2 ? item.assignedUserName : undefined} + staffData={staffData} + setSelectedUserId={setSelectedUserId} + /> + )} + keyExtractor={(item) => item.sequenceId.toString()} + onDragEnd={handleDragEnd} + showsVerticalScrollIndicator={false} + contentContainerStyle={tw`pb-8`} + ListHeaderComponent={ + + } + /> + + )} + + {/* FAB for Assignment */} + {selectedOrderIds.length > 0 && ( + + opt.value !== -1), + { label: "None", value: -3 }, + ]} + value={-1} + onValueChange={(val) => { + if (val !== -1) { + if (val === -3) { + // Unassign selected orders + const newSequence = { ...(deliverySequence as any) }; + Object.keys(newSequence).forEach((userId) => { + newSequence[userId] = newSequence[userId].filter( + (id: number) => !selectedOrderIds.includes(id) + ); + }); + // Save + updateSequenceMutation.mutate( + { + id: selectedSlotId, + deliverySequence: newSequence, + }, + { + onSuccess: () => { + setSelectedOrderIds([]); + refetchSequence(); + Alert.alert( + "Success", + "Orders unassigned successfully" + ); + }, + onError: (error: any) => { + Alert.alert( + "Error", + `Failed to unassign orders: ${ + error.message || "Unknown error" + }` + ); + }, + } + ); + } else { + // Assign selected orders to the user + // Update deliverySequence map + const newSequence = { ...(deliverySequence as any) }; + // Remove from all other users + Object.keys(newSequence).forEach((userId) => { + newSequence[userId] = newSequence[userId].filter( + (id: number) => !selectedOrderIds.includes(id) + ); + }); + // Add to selected user + if (!newSequence[String(val)]) + newSequence[String(val)] = []; + newSequence[String(val)] = [ + ...new Set([ + ...newSequence[String(val)], + ...selectedOrderIds, + ]), + ]; + // Save + updateSequenceMutation.mutate( + { + id: selectedSlotId, + deliverySequence: newSequence, + }, + { + onSuccess: () => { + setSelectedOrderIds([]); + refetchSequence(); + Alert.alert( + "Success", + "Orders assigned successfully" + ); + }, + onError: (error: any) => { + Alert.alert( + "Error", + `Failed to assign orders: ${ + error.message || "Unknown error" + }` + ); + }, + } + ); + } + } + }} + triggerComponent={({ onPress }) => ( + + + + )} + /> + + )} + + {/* FAB for Save */} + {hasSequenceChanged && ( + + + + + + )} + + ) : ( + + + + No slot selected. Please select a slot to view delivery sequence. + + router.back()} + > + Go Back + + + )} + + {/* Order Menu Dialog */} + setShowOrderMenu(false)} + > + + {/* Handle Bar */} + + + + Order #{selectedOrder?.readableId} + + + Select an action to perform + + + + {/* Actions */} + { + router.push(`/order-details/${selectedOrder?.id}`); + setShowOrderMenu(false); + }} + disabled={updateAddressCoordsMutation.isPending} + > + + + + + + View Details + + + See full order information + + + + + + { + if (!selectedOrder) return; + try { + await updatePackagedMutation.mutateAsync({ + orderId: selectedOrder.id.toString(), + isPackaged: !selectedOrder.isPackaged, + }); + refetchOrders(); + refetchSequence(); + setShowOrderMenu(false); + } catch (error) { + Alert.alert("Error", "Failed to update packaged status"); + } + }} + disabled={updatePackagedMutation.isPending} + > + + + + + + {selectedOrder?.isPackaged + ? "Unmark Packaged" + : "Mark Packaged"} + + + {selectedOrder?.isPackaged + ? "Revert to not packaged" + : "Update status to packaged"} + + + + + + { + if (!selectedOrder) return; + try { + await updateDeliveredMutation.mutateAsync({ + orderId: selectedOrder.id.toString(), + isDelivered: !selectedOrder.isDelivered, + }); + refetchOrders(); + refetchSequence(); + setShowOrderMenu(false); + } catch (error) { + Alert.alert("Error", "Failed to update delivered status"); + } + }} + disabled={updateDeliveredMutation.isPending} + > + + + + + + {selectedOrder?.isDelivered + ? "Unmark Delivered" + : "Mark Delivered"} + + + {selectedOrder?.isDelivered + ? "Revert delivery status" + : "Complete the delivery"} + + + + + + { + if (!selectedOrder) return; + try { + const { status } = + await Location.requestForegroundPermissionsAsync(); + if (status !== "granted") { + Alert.alert( + "Permission Denied", + "Location permission is required to attach coordinates." + ); + return; + } + const location = await Location.getCurrentPositionAsync({ + accuracy: Location.Accuracy.High, + }); + const { latitude, longitude } = location.coords; + await updateAddressCoordsMutation.mutateAsync({ + addressId: selectedOrder.addressId, + latitude, + longitude, + }); + Alert.alert( + "Success", + "Location attached to address successfully." + ); + } catch (error) { + Alert.alert( + "Error", + "Failed to attach location. Please try again." + ); + } + setShowOrderMenu(false); + }} + > + + + + + + Attach Location + + + Save coordinates to address + + + + + + { + const phoneMatch = selectedOrder?.address.match(/Phone: (\d+)/); + const phone = phoneMatch ? phoneMatch[1] : null; + if (phone) { + Linking.openURL(`whatsapp://send?phone=+91${phone}`); + } else { + Alert.alert("No phone number found"); + } + setShowOrderMenu(false); + }} + > + + + + + + Message On WhatsApp + + + Send message via WhatsApp + + + + + + { + const phoneMatch = selectedOrder?.address.match(/Phone: (\d+)/); + const phone = phoneMatch ? phoneMatch[1] : null; + if (phone) { + Linking.openURL(`tel:${phone}`); + } else { + Alert.alert("No phone number found"); + } + setShowOrderMenu(false); + }} + > + + + + + + Dial Mobile Number + + + Call customer directly + + + + + + + + ); +} diff --git a/apps/admin-ui/app/(drawer)/edit-coupon/[id]/index.tsx b/apps/admin-ui/app/(drawer)/edit-coupon/[id]/index.tsx new file mode 100644 index 0000000..c2cdd67 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-coupon/[id]/index.tsx @@ -0,0 +1,83 @@ +import React from 'react'; +import { View, Alert } from 'react-native'; +import { tw, AppContainer, MyText } from 'common-ui'; +import CouponForm from '../../../../src/components/CouponForm'; +import { trpc } from '@/src/trpc-client'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import dayjs from 'dayjs'; +import { CreateCouponPayload } from 'common-ui/shared-types'; + +export default function EditCoupon() { + const router = useRouter(); + const { id } = useLocalSearchParams(); + const couponId = parseInt(id as string); + + const { data: coupon, isLoading } = trpc.admin.coupon.getById.useQuery({ id: couponId }); + const updateCoupon = trpc.admin.coupon.update.useMutation(); + + const handleUpdateCoupon = (values: CreateCouponPayload & { isReservedCoupon?: boolean }) => { + // Transform targetUsers array to targetUser for backend compatibility + const updates = { + ...values, + targetUser: values.targetUsers?.[0] || undefined, + }; + delete updates.targetUsers; + + updateCoupon.mutate({ id: couponId, updates }, { + onSuccess: () => { + Alert.alert('Success', 'Coupon updated successfully', [ + { text: 'OK', onPress: () => router.back() } + ]); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update coupon'); + }, + }); + }; + + if (isLoading) { + return ( + + + Loading... + + + ); + } + + if (!coupon) { + return ( + + + Coupon not found + + + ); + } + + // Transform coupon data for form (targetUser to targetUsers array) + const initialValues: Partial = { + couponCode: coupon.couponCode, + isUserBased: coupon.isUserBased, + isApplyForAll: coupon.isApplyForAll, + targetUsers: coupon.targetUser ? [coupon.targetUser.id] : [], + discountPercent: coupon.discountPercent ? parseFloat(coupon.discountPercent) : undefined, + flatDiscount: coupon.flatDiscount ? parseFloat(coupon.flatDiscount) : undefined, + minOrder: coupon.minOrder ? parseFloat(coupon.minOrder) : undefined, + maxValue: coupon.maxValue ? parseFloat(coupon.maxValue) : undefined, + validTill: coupon.validTill ? dayjs(coupon.validTill).format('YYYY-MM-DD') : undefined, + maxLimitForUser: coupon.maxLimitForUser || undefined, + productIds: coupon.productIds, + isReservedCoupon: false, // Normal coupons + }; + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-product-group/[id].tsx b/apps/admin-ui/app/(drawer)/edit-product-group/[id].tsx new file mode 100644 index 0000000..50834db --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-product-group/[id].tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import { View } from 'react-native'; +import { AppContainer, MyText } from 'common-ui'; +import ProductGroupForm from '../../../components/ProductGroupForm'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { trpc } from '../../../src/trpc-client'; + +export default function EditProductGroup() { + const router = useRouter(); + const { id } = useLocalSearchParams(); + + const groupId = parseInt(id as string); + + const { data: groupsData, isLoading } = trpc.admin.product.getGroups.useQuery(); + const groups = groupsData?.groups || []; + const group = groups.find(g => g.id === groupId); + + if (isLoading) { + return ( + + + Loading group... + + + ); + } + + if (!group) { + return ( + + + Group not found + + + ); + } + + return ( + + router.back()} + onSuccess={() => router.back()} + /> + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-product/_layout.tsx b/apps/admin-ui/app/(drawer)/edit-product/_layout.tsx new file mode 100644 index 0000000..86cc142 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-product/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-product/index.tsx b/apps/admin-ui/app/(drawer)/edit-product/index.tsx new file mode 100644 index 0000000..aa41103 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-product/index.tsx @@ -0,0 +1,150 @@ +import React, { useRef } from 'react'; +import { View, Text, Alert } from 'react-native'; +import { useLocalSearchParams } from 'expo-router'; +import { AppContainer, useManualRefresh, MyText, tw } from 'common-ui'; +import ProductForm, { ProductFormRef } from '../../../src/components/ProductForm'; +import { useUpdateProduct } from '../../../src/api-hooks/product.api'; +import { trpc } from '@/src/trpc-client'; + +export default function EditProduct() { + const { id } = useLocalSearchParams(); + const productId = Number(id); + const productFormRef = useRef(null); + + // const { data: product, isLoading: isFetching, refetch } = useGetProduct(productId); + const { data: product, isLoading: isFetching, refetch } = trpc.admin.product.getProductById.useQuery( + { id: productId }, + { enabled: !!productId } + ); + // + const { mutate: updateProduct, isPending: isUpdating } = useUpdateProduct(); + + useManualRefresh(() => refetch()); + + const handleSubmit = (values: any, newImages?: { uri?: string }[], imagesToDelete?: string[]) => { + const payload = { + name: values.name, + shortDescription: values.shortDescription, + longDescription: values.longDescription, + unitId: parseInt(values.unitId), + storeId: parseInt(values.storeId), + price: parseFloat(values.price), + marketPrice: values.marketPrice ? parseFloat(values.marketPrice) : undefined, + incrementStep: 1, + productQuantity: values.productQuantity || 1, + deals: values.deals?.filter((deal: any) => + deal.quantity && deal.price && deal.validTill + ).map((deal: any) => ({ + quantity: parseInt(deal.quantity), + price: parseFloat(deal.price), + validTill: deal.validTill instanceof Date + ? deal.validTill.toISOString().split('T')[0] + : deal.validTill, // Convert Date to YYYY-MM-DD string + })), + tagIds: values.tagIds, + }; + + console.log({payload}) + + const formData = new FormData(); + Object.entries(payload).forEach(([key, value]) => { + if (key === 'deals' && Array.isArray(value)) { + formData.append(key, JSON.stringify(value)); + } else if (key === 'tagIds' && Array.isArray(value)) { + value.forEach(tagId => { + formData.append('tagIds', tagId.toString()); + }); + } else if (value !== undefined && value !== null) { + formData.append(key, value as string); + } + }); + + // Add new images + if (newImages && newImages.length > 0) { + newImages.forEach((image, index) => { + if (image.uri) { + const fileName = image.uri.split('/').pop() || `image_${index}.jpg`; + formData.append('images', { + uri: image.uri, + name: fileName, + type: 'image/jpeg', + } as any); + } + }); + } + + // Add images to delete + if (imagesToDelete && imagesToDelete.length > 0) { + formData.append('imagesToDelete', JSON.stringify(imagesToDelete)); + } + + updateProduct( + { id: productId, formData }, + { + onSuccess: (data) => { + Alert.alert('Success', 'Product updated successfully!'); + // Clear newly added images after successful update + productFormRef.current?.clearImages(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update product'); + }, + } + ); + }; + + if (isFetching) { + return ( + + + Loading product... + + + ); + } + + if (!product) { + return ( + + + Product not found + + + ); + } + + const productData = product.product; // The API returns { product: Product } + + const initialValues = { + name: productData.name, + shortDescription: productData.shortDescription || '', + longDescription: productData.longDescription || '', + unitId: productData.unitId, + storeId: productData.storeId || 1, + price: productData.price.toString(), + marketPrice: productData.marketPrice?.toString() || '', + deals: productData.deals?.map(deal => ({ + quantity: deal.quantity, + price: deal.price, + validTill: deal.validTill ? new Date(deal.validTill) : null, // Convert to Date object + })) || [{ quantity: '', price: '', validTill: null }], + tagIds: productData.tags?.map((tag: any) => tag.id) || [], + isSuspended: productData.isSuspended || false, + isFlashAvailable: productData.isFlashAvailable || false, + flashPrice: productData.flashPrice?.toString() || '', + productQuantity: productData.productQuantity || 1, + }; + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-slot/[id]/index.tsx b/apps/admin-ui/app/(drawer)/edit-slot/[id]/index.tsx new file mode 100644 index 0000000..c17300d --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-slot/[id]/index.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { View, Text } from 'react-native'; +import { AppContainer } from 'common-ui'; +// import SlotForm from '../../../components/SlotForm'; +// import { trpc } from '../../../src/trpc-client'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { trpc } from '@/src/trpc-client'; +import SlotForm from '@/components/SlotForm'; + +export default function EditSlot() { + const router = useRouter(); + const { id } = useLocalSearchParams(); + const slotId = parseInt(id as string); + + const { data: slot, isLoading } = trpc.admin.slots.getSlotById.useQuery({ id: slotId }); + + const handleSlotUpdated = () => { + router.back(); + }; + + if (isLoading) { + return ( + + + Loading slot... + + + ); + } + + if (!slot) { + return ( + + + Slot not found + + + ); + } + + return ( + + p.id) || []} + onSlotAdded={handleSlotUpdated} + /> + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-slot/_layout.tsx b/apps/admin-ui/app/(drawer)/edit-slot/_layout.tsx new file mode 100644 index 0000000..5a46e47 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-slot/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-store/_layout.tsx b/apps/admin-ui/app/(drawer)/edit-store/_layout.tsx new file mode 100644 index 0000000..de4cfe5 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-store/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-store/index.tsx b/apps/admin-ui/app/(drawer)/edit-store/index.tsx new file mode 100644 index 0000000..74bfdf1 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-store/index.tsx @@ -0,0 +1,76 @@ +import React from 'react'; +import { View, Alert } from 'react-native'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { AppContainer, MyText, tw } from 'common-ui'; +import StoreForm, { StoreFormData } from '@/components/StoreForm'; +import { trpc } from '@/src/trpc-client'; + +export default function EditStore() { + const router = useRouter(); + const { id } = useLocalSearchParams(); + + const storeId = parseInt(id as string); + + const { data: storeData, isLoading: isLoadingStore, refetch } = trpc.admin.store.getStoreById.useQuery( + { id: storeId }, + { enabled: !!storeId } + ); + + const updateStoreMutation = trpc.admin.store.updateStore.useMutation(); + + const handleSubmit = (values: StoreFormData) => { + updateStoreMutation.mutate({ id: storeId, ...values }, { + onSuccess: (data) => { + refetch(); + Alert.alert('Success', data.message); + router.push('/(drawer)/stores' as any); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update store'); + }, + }); + }; + + if (isLoadingStore) { + return ( + + + Loading store... + + + ); + } + + if (!storeData?.store) { + return ( + + + Store not found + + + ); + } + + const initialValues = { + name: storeData.store.name, + description: storeData.store.description || '', + imageUrl: storeData.store.imageUrl || '', + owner: storeData.store.owner.id, + products: [], // Will be set by StoreForm + }; + + return ( + + + Edit Store + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-tag/_layout.tsx b/apps/admin-ui/app/(drawer)/edit-tag/_layout.tsx new file mode 100644 index 0000000..1db11a3 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-tag/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/edit-tag/index.tsx b/apps/admin-ui/app/(drawer)/edit-tag/index.tsx new file mode 100644 index 0000000..260b05e --- /dev/null +++ b/apps/admin-ui/app/(drawer)/edit-tag/index.tsx @@ -0,0 +1,107 @@ +import React from 'react'; +import { View, Alert } from 'react-native'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { AppContainer, MyText, tw } from 'common-ui'; +import TagForm from '@/src/components/TagForm'; +import { useGetTag, useUpdateTag } from '@/src/api-hooks/tag.api'; + +interface TagFormData { + tagName: string; + tagDescription: string; + isDashboardTag: boolean; + existingImageUrl?: string; +} + +export default function EditTag() { + const router = useRouter(); + const { tagId } = useLocalSearchParams<{ tagId: string }>(); + const tagIdNum = tagId ? parseInt(tagId) : null; + + const { data: tagData, isLoading: isLoadingTag, error: tagError } = useGetTag(tagIdNum!); + const { mutate: updateTag, isPending: isUpdating } = useUpdateTag(); + + const handleSubmit = (values: TagFormData, image?: { uri?: string }) => { + if (!tagIdNum) return; + + const formData = new FormData(); + + // Add text fields + formData.append('tagName', values.tagName); + if (values.tagDescription) { + formData.append('tagDescription', values.tagDescription); + } + formData.append('isDashboardTag', values.isDashboardTag.toString()); + + // Add image if uploaded + if (image?.uri) { + const filename = image.uri.split('/').pop() || 'image.jpg'; + const match = /\.(\w+)$/.exec(filename); + const type = match ? `image/${match[1]}` : 'image/jpeg'; + + formData.append('image', { + uri: image.uri, + name: filename, + type, + } as any); + } + + updateTag({ id: tagIdNum, formData }, { + onSuccess: (data) => { + Alert.alert('Success', 'Tag updated successfully', [ + { + text: 'OK', + onPress: () => router.back(), + }, + ]); + }, + onError: (error: any) => { + const errorMessage = error.message || 'Failed to update tag'; + Alert.alert('Error', errorMessage); + }, + }); + }; + + if (isLoadingTag) { + return ( + + + Loading tag... + + + ); + } + + if (tagError || !tagData?.tag) { + return ( + + + Tag not found + + + ); + } + + const tag = tagData.tag; + const initialValues: TagFormData = { + tagName: tag.tagName, + tagDescription: tag.tagDescription || '', + isDashboardTag: tag.isDashboardTag, + existingImageUrl: tag.imageUrl || undefined, + }; + + return ( + + + + {/* Form */} + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/manage-orders/_layout.tsx b/apps/admin-ui/app/(drawer)/manage-orders/_layout.tsx new file mode 100644 index 0000000..37e80fe --- /dev/null +++ b/apps/admin-ui/app/(drawer)/manage-orders/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/manage-orders/index.tsx b/apps/admin-ui/app/(drawer)/manage-orders/index.tsx new file mode 100644 index 0000000..dd8a3ec --- /dev/null +++ b/apps/admin-ui/app/(drawer)/manage-orders/index.tsx @@ -0,0 +1,92 @@ +import { View, TouchableOpacity, Alert } from 'react-native'; +import { MyText, BottomDropdown, tw, MyFlatList, useMarkDataFetchers } from 'common-ui'; +import { useRouter } from 'expo-router'; +import dayjs from 'dayjs'; +import { useState } from 'react'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { trpc } from '@/src/trpc-client'; + +export default function ManageOrders() { + const router = useRouter(); + const [selectedSlotId, setSelectedSlotId] = useState(null); + const { data: slotsData, refetch } = trpc.admin.slots.getAll.useQuery(); + + useMarkDataFetchers(() => { + refetch(); + }); + + // Create slot options with Flash Deliveries as first option + const slotOptions = [ + { label: '⚡ Flash Deliveries', value: 'flash' }, + ...(slotsData?.slots?.map(slot => ({ + label: dayjs(slot.deliveryTime).format('ddd DD MMM, h:mm a'), + value: slot.id.toString() + })) || []) + ]; + + const menuItems = [ + { + title: 'Delivery Sequences', + icon: 'route', + color: 'bg-purple-500', + onPress: () => { + if (selectedSlotId === 'flash') { + Alert.alert('Flash Deliveries', 'Flash deliveries do not have delivery sequences. Use the Orders menu to manage flash deliveries.'); + return; + } + router.push(`/(drawer)/delivery-sequences?slotId=${selectedSlotId}`); + }, + }, + { + title: 'Orders', + icon: 'list', + color: 'bg-cyan-500', + onPress: () => { + if (selectedSlotId === 'flash') { + router.push('/(drawer)/orders?filter=flash'); + } else { + router.push('/(drawer)/orders'); + } + }, + }, + ]; + + return ( + + ( + + + + + {item.title} + + + + )} + keyExtractor={(item, index) => index.toString()} + columnWrapperStyle={tw`justify-between gap-4`} + contentContainerStyle={tw`p-6 gap-4 bg-white flex-1`} + ListHeaderComponent={ + <> + + setSelectedSlotId(String(val))} + placeholder="Select Slot" + /> + + + } + + /> + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/order-details/[id].tsx b/apps/admin-ui/app/(drawer)/order-details/[id].tsx new file mode 100644 index 0000000..266365a --- /dev/null +++ b/apps/admin-ui/app/(drawer)/order-details/[id].tsx @@ -0,0 +1,886 @@ +import React, { useState } from "react"; +import { + View, + ScrollView, + TouchableOpacity, + Platform, + Alert, +} from "react-native"; +import { useLocalSearchParams, useRouter } from "expo-router"; +import { AppContainer, MyText, tw, BottomDialog, MyTextInput, theme } from "common-ui"; +import { trpc } from "@/src/trpc-client"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; +import dayjs from "dayjs"; +import CancelOrderDialog from "@/components/CancelOrderDialog"; + +export default function OrderDetails() { + const { id } = useLocalSearchParams<{ id: string }>(); + const router = useRouter(); + const [generateCouponDialogOpen, setGenerateCouponDialogOpen] = + useState(false); + const [initiateRefundDialogOpen, setInitiateRefundDialogOpen] = + useState(false); + const [cancelDialogOpen, setCancelDialogOpen] = useState(false); + const [refundType, setRefundType] = useState<"percent" | "amount">("percent"); + const [refundValue, setRefundValue] = useState("100"); + const [updatingItems, setUpdatingItems] = useState>(new Set()); + + const { + data: orderData, + isLoading, + error, + refetch, + } = trpc.admin.order.getOrderDetails.useQuery( + { orderId: id ? parseInt(id) : 0 }, + { enabled: !!id } + ); + + const generateCouponMutation = + trpc.admin.coupon.generateCancellationCoupon.useMutation({ + onSuccess: (coupon) => { + Alert.alert( + "Success", + `Refund coupon generated successfully!\n\nCode: ${coupon.couponCode + }\nValue: ₹${coupon.flatDiscount}\nExpires: ${coupon.validTill + ? new Date(coupon.validTill).toLocaleDateString() + : "N/A" + }` + ); + setGenerateCouponDialogOpen(false); + }, + onError: (error: any) => { + Alert.alert( + "Error", + error.message || "Failed to generate refund coupon" + ); + }, + }); + + const initiateRefundMutation = trpc.admin.payments.initiateRefund.useMutation( + { + onSuccess: (result) => { + Alert.alert( + "Success", + `Refund initiated successfully!\n\nAmount: ₹${result.amount}\nStatus: ${result.status}` + ); + setInitiateRefundDialogOpen(false); + }, + onError: (error: any) => { + Alert.alert("Error", error.message || "Failed to initiate refund"); + }, + } + ); + + const updateItemPackagingMutation = trpc.admin.order.updateOrderItemPackaging.useMutation({ + onSuccess: () => { + // Refetch order details to get updated packaging status + refetch(); + }, + onError: (error: any) => { + Alert.alert("Error", error.message || "Failed to update packaging status"); + }, + }); + + if (isLoading) { + return ( + + + Loading order details... + + + ); + } + + if (error || !orderData) { + return ( + + + + + Oops! + + + {error?.message || "Failed to load order details"} + + router.back()} + style={tw`bg-gray-900 px-6 py-3 rounded-xl w-full items-center`} + > + Go Back + + + + ); + } + + const order = orderData; + + // Calculate subtotal and discount for order summary + const subtotal = order.items.reduce((sum, item) => sum + item.amount, 0); + const discountAmount = order.discountAmount || 0; + + const handleGenerateCoupon = () => { + generateCouponMutation.mutate({ orderId: order.id }); + }; + + const handleInitiateRefund = () => { + const value = parseFloat(refundValue); + if (isNaN(value) || value <= 0) { + Alert.alert("Error", "Please enter a valid refund value"); + return; + } + + const mutationData: any = { + orderId: order.id, + }; + + if (refundType === "percent") { + if (value > 100) { + Alert.alert("Error", "Refund percentage cannot exceed 100%"); + return; + } + mutationData.refundPercent = value; + } else { + mutationData.refundAmount = value; + } + + initiateRefundMutation.mutate(mutationData); + setInitiateRefundDialogOpen(false); + }; + + const handlePackagingToggle = (itemId: number, field: 'isPackaged' | 'isPackageVerified', value: boolean) => { + // Add item to updating set to disable UI + setUpdatingItems(prev => new Set(prev).add(itemId)); + + updateItemPackagingMutation.mutate( + { + orderItemId: itemId, + [field]: value, + }, + { + onSettled: () => { + // Remove item from updating set + setUpdatingItems(prev => { + const newSet = new Set(prev); + newSet.delete(itemId); + return newSet; + }); + }, + } + ); + }; + + const getStatusColor = (status: string) => { + switch (status) { + case "delivered": + return "text-green-600 bg-green-50 border-green-100"; + case "cancelled": + return "text-red-600 bg-red-50 border-red-100"; + default: + return "text-yellow-600 bg-yellow-50 border-yellow-100"; + } + }; + + const statusStyle = getStatusColor(order.status); + const showRefundOptions = true; + + const getRefundDotColor = (status: string) => { + if (status === 'success') return 'bg-green-500'; + else if (status === 'pending') return 'bg-yellow-500'; + else if (status === 'failed') return 'bg-red-500'; + else return 'bg-gray-500'; + }; + + const getRefundTextColor = (status: string) => { + if (status === 'success' || status === 'na') return 'text-green-700'; + else if (status === 'pending') return 'text-yellow-700'; + else if (status === 'failed') return 'text-red-700'; + else return 'text-gray-700'; + }; + + const getRefundStatusText = (status: string) => { + if (status === 'success' || status === 'na') return 'Completed'; + else if (status === 'pending') return 'Pending'; + else if (status === 'failed') return 'Failed'; + else if (status === 'none') return 'Not Initiated'; + else if (status === 'na') return 'Not Applicable'; + else return 'Unknown'; + }; + return ( + + + + {/* Order ID & Status Card */} + + + + Order ID + + #{order.readableId} + + + + + + {order.status} + + + {order.isFlashDelivery && ( + + + + )} + + + + + + + {order.isFlashDelivery ? "Flash Delivery:" : "Delivery at:"} {order.isFlashDelivery + ? dayjs(order.createdAt).add(30, 'minutes').format("MMM DD, YYYY • h:mm A") + : order.slotInfo?.time ? dayjs(order.slotInfo.time).format("MMM DD, YYYY • h:mm A") : 'Not scheduled'} + + + {order.isFlashDelivery && ( + + + + ⚡ 30-Minute Flash Delivery • High Priority + + + )} + + + + Placed on {dayjs(order.createdAt).format("MMM DD, YYYY • h:mm A")} + + + + + {/* Order Progress (Simplified Timeline) */} + {order.status !== "cancelled" && ( + + + Order Status + + + {/* Placed */} + + + + + + Placed + + + + + {/* Packaged */} + + + + + + Packaged + + + + + {/* Delivered */} + + + {order.isFlashDelivery && order.isDelivered ? ( + + ) : ( + + )} + + + + {order.isFlashDelivery && order.isDelivered ? "Flash Delivered" : "Delivered"} + + {order.isFlashDelivery && ( + + ⚡ 30-Min + + )} + + + + + )} + + {/* Customer Details */} + + + Customer Details + + + + + + + + + {order.customerName} + + Customer + + + + + + + + + + {order.customerMobile} + + + {order.customerEmail && ( + + + + + + {order.customerEmail} + + + )} + + + + + + + {order.address.line1} + {order.address.line2 ? `, ${order.address.line2}` : ""} + {`\n${order.address.city}, ${order.address.state} - ${order.address.pincode}`} + + + + + + + {/* Order Items */} + + + Items Ordered + + {order.items.map((item, index) => ( + + + + + + + {item.name} + + + {item.quantity} {item.unit} × ₹{item.price} + + + handlePackagingToggle(item.id, 'isPackaged', !item.isPackaged)} + disabled={updatingItems.has(item.id)} + > + + + Packaged + + + handlePackagingToggle(item.id, 'isPackageVerified', !item.isPackageVerified)} + disabled={updatingItems.has(item.id)} + > + + + Pkg Verified + + + + + + ₹{item.amount} + + + ))} + + + + + Subtotal ({order.items.length} items) + + + ₹{subtotal} + + + {discountAmount > 0 && ( + + + Discount + + + -₹{discountAmount} + + + )} + + + + Total Amount + + {order.isFlashDelivery && ( + + ⚡ FLASH + + )} + + + ₹{order.totalAmount} + + + + + + {/* Flash Delivery Priority Notice */} + {order.isFlashDelivery && ( + + + + + Flash Delivery Order + + + + ⚡ This is a high-priority flash delivery order that must be delivered within 30 minutes of placement. + + + + Expected Delivery: {dayjs(order.createdAt).add(30, 'minutes').format("MMM DD, YYYY • h:mm A")} + + + + )} + + {/* Admin Notes */} + {order.adminNotes && ( + + + + + Admin Notes + + + + {order.adminNotes} + + + )} + + {/* Coupon Applied Section */} + {order.couponCode && ( + + + Coupon Applied + + + + + + {order.couponCode} + + + + {order.couponDescription} + + + + Discount Applied: + + + -₹{order.discountAmount} + + + + + )} + + {/* Refund Coupon Section */} + {order.orderStatus?.refundCouponId && ( + + + Refund Coupon + + + + + + {order.couponCode} + + + + Generated refund coupon for order cancellation + + + + Value: + + + ₹{order.couponData?.discountAmount} + + + {/* + + Expires: + + + {order.couponData?. + ? dayjs(order.orderStatus.refundCoupon.validTill).format("DD MMM YYYY") + : "N/A"} + + */} + + + )} + + {/* TEMPORARILY HIDDEN: Refund Details Section */} + {/* WARNING: This section contains functional refund and cancellation management features */} + {/* DO NOT REMOVE - This is temporarily commented out for UI simplification */} + {/* When ready to re-enable, simply uncomment the entire block below */} + {/* + + + {order.status === "cancelled" ? "Cancellation Details" : "Refund Details"} + + {order.status === "cancelled" && order.cancelReason && ( + + + Cancellation Reason + + + {order.cancelReason} + + + )} + + + Refund Status + + + + + {getRefundStatusText(order.refundStatus)} + + + + {order.refundRecord && ( + + + Refund Amount + + + ₹{order.refundRecord.refundAmount} + + + )} + + {(!Boolean(order.refundRecord)) && + {!order.isCod && ( setInitiateRefundDialogOpen(true)} + > + + + Initiate Refund + + + )} + setGenerateCouponDialogOpen(true)} + > + + + Generate Refund Coupon + + + } + + + */} + + + + {/* Bottom Action Bar */} + + {order.status !== "cancelled" && ( + setCancelDialogOpen(true)} + style={tw`bg-red-500 rounded-xl py-4 items-center shadow-lg mb-3`} + > + + Cancel Order + + + )} + router.push("/(drawer)/manage-orders")} + style={tw`bg-gray-900 rounded-xl py-4 items-center shadow-lg`} + > + + Manage Orders + + + + + {/* Generate Coupon Dialog */} + setGenerateCouponDialogOpen(false)} + > + + + + + + + Generate Refund Coupon + + + Create a one-time use coupon for the customer equal to the order amount. Valid for 30 days. + + + + + + + This only works for online payment orders. COD orders cannot generate refund coupons. + + + + + setGenerateCouponDialogOpen(false)} + > + Cancel + + + + {generateCouponMutation.isPending + ? "Generating..." + : "Generate Coupon"} + + + + + + + {/* Initiate Refund Dialog */} + setInitiateRefundDialogOpen(false)} + > + + + + + + + Initiate Refund + + + Process a refund directly to the customer's source account via Razorpay. + + + + {/* Refund Type Selection */} + + + Refund Type + + + setRefundType("percent")} + > + + + Percentage + + + + setRefundType("amount")} + > + + + Fixed Amount + + + + + + {/* Refund Value Input */} + + + + + + + + For COD orders, refunds are processed immediately upon delivery confirmation. + + + + + setInitiateRefundDialogOpen(false)} + > + Cancel + + + + {initiateRefundMutation.isPending + ? "Processing..." + : "Confirm Refund"} + + + + + + + {/* Cancel Order Dialog */} + setCancelDialogOpen(false)} + onSuccess={refetch} + /> + + ); +} + diff --git a/apps/admin-ui/app/(drawer)/order-details/_layout.tsx b/apps/admin-ui/app/(drawer)/order-details/_layout.tsx new file mode 100644 index 0000000..d238e05 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/order-details/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/orders/_layout.tsx b/apps/admin-ui/app/(drawer)/orders/_layout.tsx new file mode 100644 index 0000000..d6319ff --- /dev/null +++ b/apps/admin-ui/app/(drawer)/orders/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/orders/index.tsx b/apps/admin-ui/app/(drawer)/orders/index.tsx new file mode 100644 index 0000000..93ab819 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/orders/index.tsx @@ -0,0 +1,836 @@ +import React, { useState , useEffect } from 'react'; +import { View, TouchableOpacity, Alert, TextInput, ActivityIndicator } from 'react-native'; +import { AppContainer, MyText, tw, MyFlatList, BottomDialog, BottomDropdown, Checkbox, theme, MyTextInput } from 'common-ui'; +import { trpc } from '../../../src/trpc-client'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import dayjs from 'dayjs'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { Entypo } from '@expo/vector-icons'; +import CancelOrderDialog from '@/components/CancelOrderDialog'; + +const AdminNotesForm = ({ orderId, existingNotes, onClose, refetch }: { orderId: string; existingNotes?: string | null; onClose: () => void; refetch: () => void }) => { + const [notesText, setNotesText] = useState(existingNotes || ''); + const updateNotesMutation = trpc.admin.order.updateNotes.useMutation(); + + return ( + + Admin Notes + + + { + updateNotesMutation.mutate( + { orderId: parseInt(orderId), adminNotes: notesText }, + { + onSuccess: () => { + onClose(); + Alert.alert('Success', 'Notes updated successfully'); + refetch(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update notes'); + }, + } + ); + }} + > + Save + + + + ); +}; + + +interface OrderType { + id: number; + orderId: string; + readableId: number; + customerName: string | null; + address: string; + totalAmount: number; + deliveryCharge: number; + items: { + id?: number; + name: string; + quantity: number; + price: number; + amount: number; + unit: string; + isPackaged?: boolean; + isPackageVerified?: boolean; + }[]; + createdAt: string; + deliveryTime: string | null; + status: 'pending' | 'delivered' | 'cancelled'; + isPackaged: boolean; + isDelivered: boolean; + isCod: boolean; + isFlashDelivery: boolean; + couponCode?: string; + couponDescription?: string; + discountAmount?: number; + adminNotes?: string | null; + userNotes?: string | null; +} + +const OrderItem = ({ order, refetch }: { order: OrderType; refetch: () => void }) => { + const id = order.orderId; + const router = useRouter(); + const [menuOpen, setMenuOpen] = useState(false); + const [itemsDialogOpen, setItemsDialogOpen] = useState(false); + const [notesDialogOpen, setNotesDialogOpen] = useState(false); + const [cancelDialogOpen, setCancelDialogOpen] = useState(false); + const [userNotesDialogOpen, setUserNotesDialogOpen] = useState(false); + const [adminNotesDialogOpen, setAdminNotesDialogOpen] = useState(false); + const [updatingItems, setUpdatingItems] = useState>(new Set()); + + const updatePackagedMutation = trpc.admin.order.updatePackaged.useMutation(); + const updateDeliveredMutation = trpc.admin.order.updateDelivered.useMutation(); + const updateItemPackagingMutation = trpc.admin.order.updateOrderItemPackaging.useMutation(); + + const handleOrderPress = () => { + router.push(`/order-details/${order.orderId}` as any); + }; + + const handleMenuOption = () => { + setMenuOpen(false); + router.push(`/order-details/${order.orderId}` as any); + }; + + const handleMarkPackaged = (isPackaged: boolean) => { + updatePackagedMutation.mutate( + { orderId: order.orderId.toString(), isPackaged }, + { + onSuccess: () => { + setMenuOpen(false); + refetch(); + }, + } + ); + }; + + const handleMarkDelivered = (isDelivered: boolean) => { + updateDeliveredMutation.mutate( + { orderId: order.orderId.toString(), isDelivered }, + { + onSuccess: () => { + setMenuOpen(false); + refetch(); + }, + } + ); + }; + + const handleItemPackagingToggle = (itemId: number, field: 'isPackaged' | 'isPackageVerified', value: boolean) => { + setUpdatingItems(prev => new Set(prev).add(itemId)); + + updateItemPackagingMutation.mutate( + { orderItemId: itemId, [field]: value }, + { + onSuccess: () => { + setUpdatingItems(prev => { + const newSet = new Set(prev); + newSet.delete(itemId); + return newSet; + }); + refetch(); + }, + onError: (error: any) => { + setUpdatingItems(prev => { + const newSet = new Set(prev); + newSet.delete(itemId); + return newSet; + }); + Alert.alert("Error", error.message || "Failed to update packaging status"); + }, + } + ); + }; + + const getStatusColor = (status: string) => { + switch (status) { + case 'delivered': return 'bg-green-100 text-green-800'; + case 'cancelled': return 'bg-red-100 text-red-800'; + default: return 'bg-yellow-100 text-yellow-800'; + } + }; + + if(order.id === 162) + console.log({order}) + + return ( + <> + + {/* Header Section */} + + + + + + {order.customerName || 'Unknown Customer'} + + + #{order.readableId} + + {order.isFlashDelivery && ( + + + FLASH + + )} + + + + + {dayjs(order.createdAt).format('MMM D, h:mm A')} + + + + + setMenuOpen(true)} + style={tw`p-2 -mr-2 -mt-2 rounded-full`} + > + + + + + + {/* Main Content */} + + {/* Status Badges */} + + {/* + {order.status} + */} + {/* {order.isCod && ( + + COD + + )} */} + + Packaged + handleMarkPackaged(!order.isPackaged)} + onPress={() => {}} + size={18} + fillColor={theme.colors.gray500} + checkColor="#FFFFFF" + /> + + + Delivered + handleMarkDelivered(!order.isDelivered)} + size={18} + fillColor="#10B981" + checkColor="#FFFFFF" + /> + + + + {/* Delivery Info */} + + + + Delivery Address + + {order.address} + + + + + {order.isFlashDelivery ? "Flash Delivery:" : "Slot:"} {order.isFlashDelivery ? dayjs(order.createdAt).add(30, 'minutes').format('MMM D, h:mm A') : order.deliveryTime ? dayjs(order.deliveryTime).format("ddd, MMM D • h:mm A") : 'Not scheduled'} + + + {order.isFlashDelivery && ( + + + + 30-Minute Delivery • High Priority + + + )} + + + + {/* Items Summary & Total */} + + + + setItemsDialogOpen(true)} + style={tw`flex-row items-center py-2 px-3 bg-blue-50 rounded-lg flex-1 mr-3`} + > + + + {order.items.length} {order.items.length === 1 ? 'item' : 'items'} + + {order.isFlashDelivery && ( + + + + )} + + + Total: + ₹{order.totalAmount} + + + + + + {/* Coupons */} + {order.couponCode && ( + + Applied Coupons + + + {order.couponCode} + + {order.couponDescription && ( + + {order.couponDescription} + + )} + {order.discountAmount && ( + + Discount: ₹{order.discountAmount} + + )} + + + )} + + {/* Notes Section */} + + {order.userNotes && ( + setUserNotesDialogOpen(true)} + > + + + User Notes + + + )} + {order.adminNotes && ( + setNotesDialogOpen(true)} + > + + + Admin Notes + + + )} + + + {/* Footer / Delivery Charge */} + {order.deliveryCharge > 0 && ( + + + Delivery Charge + ₹{order.deliveryCharge} + + + )} + + + + setMenuOpen(false)}> + + + Order Options + + {order.isFlashDelivery && ( + + + + Flash Delivery Order + + Deliver within 30 minutes • High Priority + + + + )} + handleMarkPackaged(!order.isPackaged)} + > + + + {order.isPackaged ? 'Mark Not Packaged' : 'Mark Packaged'} + + + {order.isPackaged && ( + handleMarkDelivered(!order.isDelivered)} + > + + + {order.isDelivered ? 'Mark Not Delivered' : 'Mark Delivered'} + + + )} + + + + Order Details + + + { + setMenuOpen(false); + setNotesDialogOpen(true); + }} + > + + + Admin Notes + + + {order.status !== 'cancelled' && ( + { + setMenuOpen(false); + setCancelDialogOpen(true); + }} + > + + + Cancel Order + + + )} + + + + setItemsDialogOpen(false)}> + + + + Order Items + + {order.isFlashDelivery && ( + + + FLASH + + )} + + + Total: ₹{order.totalAmount} + + {order.items.map((item, idx) => ( + + + + {item.quantity} {item.unit} + + + {item.name.length > 30 ? `${item.name.substring(0, 30)}...` : item.name} + + {item.isPackaged !== undefined && item.isPackageVerified !== undefined && ( + <> + + pkg + handleItemPackagingToggle(item.id!, 'isPackaged', !item.isPackaged)} + size={18} + fillColor={updatingItems.has(item.id!) ? "#F59E0B" : "#10B981"} + checkColor="#FFFFFF" + /> + + + verf + handleItemPackagingToggle(item.id!, 'isPackageVerified', !item.isPackageVerified)} + size={18} + fillColor={updatingItems.has(item.id!) ? "#F59E0B" : "#10B981"} + checkColor="#FFFFFF" + /> + + {updatingItems.has(item.id!) && ( + + )} + + )} + + + ))} + + + + setNotesDialogOpen(false)}> + setNotesDialogOpen(false)} refetch={refetch} /> + + + setCancelDialogOpen(false)} + onSuccess={refetch} + /> + + setUserNotesDialogOpen(false)}> + + + User Notes + + + + {order.userNotes} + + + + + + setAdminNotesDialogOpen(false)}> + + + Admin Notes + + + + {order.adminNotes} + + + + + + ); + }; + +export default function Orders() { + const router = useRouter(); + const { filter } = useLocalSearchParams<{ filter?: string }>(); + const [selectedSlot, setSelectedSlot] = useState(null); + const [selectedSlotType, setSelectedSlotType] = useState<'slot' | 'flash' | null>(null); + const [packagedFilter, setPackagedFilter] = useState<'all' | 'packaged' | 'not_packaged'>('all'); + const [packagedChecked, setPackagedChecked] = useState(false); + const [notPackagedChecked, setNotPackagedChecked] = useState(false); + const [deliveredFilter, setDeliveredFilter] = useState<'all' | 'delivered' | 'not_delivered'>('all'); + const [deliveredChecked, setDeliveredChecked] = useState(false); + const [notDeliveredChecked, setNotDeliveredChecked] = useState(false); + const [cancellationFilter, setCancellationFilter] = useState<'all' | 'cancelled' | 'not_cancelled'>('all'); + const [cancelledChecked, setCancelledChecked] = useState(false); + const [notCancelledChecked, setNotCancelledChecked] = useState(false); + const [flashDeliveryFilter, setFlashDeliveryFilter] = useState<'all' | 'flash' | 'regular'>('all'); + const [flashChecked, setFlashChecked] = useState(false); + const [regularChecked, setRegularChecked] = useState(false); + const [filterDialogOpen, setFilterDialogOpen] = useState(false); + + // Handle initial filter from URL params + useEffect(() => { + if (filter === 'flash') { + setSelectedSlotType('flash'); + setFlashDeliveryFilter('flash'); + setFlashChecked(true); + setRegularChecked(false); + } + }, [filter]); + const { data: slotsData } = trpc.admin.slots.getAll.useQuery(); + const { data, isLoading, isFetchingNextPage, fetchNextPage, hasNextPage, refetch } = trpc.admin.order.getAll.useInfiniteQuery( + { + limit: 20, + slotId: selectedSlotType === 'slot' ? selectedSlot : null, + packagedFilter, + deliveredFilter, + cancellationFilter, + flashDeliveryFilter: selectedSlotType === 'flash' ? 'flash' : flashDeliveryFilter + }, + { + getNextPageParam: (lastPage) => lastPage?.nextCursor, + } + ); + + const orders = data?.pages.flatMap(page => page?.orders) || []; + + if (isLoading) { + return ( + + + Loading orders... + + ); + } + + const slotOptions = [ + { label: '⚡ Flash Deliveries', value: 'flash' }, + ...(slotsData?.slots?.map(slot => ({ + label: dayjs(slot.deliveryTime).format('ddd DD MMM, h:mm a'), + value: slot.id.toString(), + })) || []) + ]; + + + return ( + <> + item!.orderId} + renderItem={({ item }) => item ? : null} + onEndReached={() => { + if (hasNextPage && !isFetchingNextPage) { + fetchNextPage(); + } + }} + onEndReachedThreshold={0.5} + onRefresh={() => refetch()} + ListHeaderComponent={ + <> + + + { + if (val === 'flash') { + setSelectedSlotType('flash'); + setSelectedSlot(null); + setFlashDeliveryFilter('flash'); + // Reset other filters when switching to flash + setPackagedFilter('all'); + setPackagedChecked(false); + setNotPackagedChecked(false); + setDeliveredFilter('all'); + setDeliveredChecked(false); + setNotDeliveredChecked(false); + setCancellationFilter('all'); + setCancelledChecked(false); + setNotCancelledChecked(false); + } else { + setSelectedSlotType('slot'); + setSelectedSlot(val ? Number(val) : null); + setFlashDeliveryFilter('all'); + } + }} + placeholder="All slots" + /> + + setFilterDialogOpen(true)} + style={tw`p-2`} + > + + + + {!isLoading && selectedSlotType && ( + + + {selectedSlotType === 'flash' + ? `${orders.length} Flash delivery orders` + : `${orders.length} Orders in slot` + } + + + )} + + } + ListFooterComponent={ + isFetchingNextPage ? ( + + + Loading more... + + ) : null + } + /> + + setFilterDialogOpen(false)}> + + + Packaged Status + + { + const newValue = !packagedChecked; + setPackagedChecked(newValue); + if (newValue && notPackagedChecked) { + setPackagedFilter('all'); + } else if (newValue) { + setPackagedFilter('packaged'); + } else if (notPackagedChecked) { + setPackagedFilter('not_packaged'); + } else { + setPackagedFilter('all'); + } + }} + /> + Packaged + + + { + const newValue = !notPackagedChecked; + setNotPackagedChecked(newValue); + if (packagedChecked && newValue) { + setPackagedFilter('all'); + } else if (newValue) { + setPackagedFilter('not_packaged'); + } else if (packagedChecked) { + setPackagedFilter('packaged'); + } else { + setPackagedFilter('all'); + } + }} + /> + Not Packaged + + + + Delivered Status + + { + const newValue = !deliveredChecked; + setDeliveredChecked(newValue); + if (newValue && notDeliveredChecked) { + setDeliveredFilter('all'); + } else if (newValue) { + setDeliveredFilter('delivered'); + } else if (notDeliveredChecked) { + setDeliveredFilter('not_delivered'); + } else { + setDeliveredFilter('all'); + } + }} + /> + Delivered + + + { + const newValue = !notDeliveredChecked; + setNotDeliveredChecked(newValue); + if (deliveredChecked && newValue) { + setDeliveredFilter('all'); + } else if (newValue) { + setDeliveredFilter('not_delivered'); + } else if (deliveredChecked) { + setDeliveredFilter('delivered'); + } else { + setDeliveredFilter('all'); + } + }} + /> + Not Delivered + + + + Cancellation Status + + { + const newValue = !cancelledChecked; + setCancelledChecked(newValue); + if (newValue && notCancelledChecked) { + setCancellationFilter('all'); + } else if (newValue) { + setCancellationFilter('cancelled'); + } else if (notCancelledChecked) { + setCancellationFilter('not_cancelled'); + } else { + setCancellationFilter('all'); + } + }} + /> + Cancelled + + + { + const newValue = !notCancelledChecked; + setNotCancelledChecked(newValue); + if (cancelledChecked && newValue) { + setCancellationFilter('all'); + } else if (newValue) { + setCancellationFilter('not_cancelled'); + } else if (cancelledChecked) { + setCancellationFilter('cancelled'); + } else { + setCancellationFilter('all'); + } + }} + /> + Not Cancelled + + + + Delivery Type + + { + const newValue = !flashChecked; + setFlashChecked(newValue); + if (newValue && regularChecked) { + setFlashDeliveryFilter('all'); + } else if (newValue) { + setFlashDeliveryFilter('flash'); + } else if (regularChecked) { + setFlashDeliveryFilter('regular'); + } else { + setFlashDeliveryFilter('all'); + } + }} + /> + ⚡ Flash Delivery + + + { + const newValue = !regularChecked; + setRegularChecked(newValue); + if (flashChecked && newValue) { + setFlashDeliveryFilter('all'); + } else if (newValue) { + setFlashDeliveryFilter('regular'); + } else if (flashChecked) { + setFlashDeliveryFilter('flash'); + } else { + setFlashDeliveryFilter('all'); + } + }} + /> + Regular Delivery + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/prices-overview/_layout.tsx b/apps/admin-ui/app/(drawer)/prices-overview/_layout.tsx new file mode 100644 index 0000000..c65c91a --- /dev/null +++ b/apps/admin-ui/app/(drawer)/prices-overview/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function PricesOverviewLayout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/prices-overview/index.tsx b/apps/admin-ui/app/(drawer)/prices-overview/index.tsx new file mode 100644 index 0000000..2c3ec88 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/prices-overview/index.tsx @@ -0,0 +1,424 @@ +import React, { useState, useEffect, useMemo } from "react"; +import { + View, + TouchableOpacity, + FlatList, + Image, + Alert, + ActivityIndicator, + TextInput, +} from "react-native"; +import { useRouter } from "expo-router"; +import { + AppContainer, + MyText, + tw, + BottomDialog, + BottomDropdown, + Checkbox, +} from "common-ui"; +import { trpc } from "@/src/trpc-client"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { Entypo } from "@expo/vector-icons"; + +interface ProductItemProps { + item: any; + hasChanges: (productId: number) => boolean; + pendingChanges: Record; + setPendingChanges: React.Dispatch>>; + openEditDialog: (product: any) => void; +} + +const ProductItemComponent: React.FC = ({ + item: product, + hasChanges, + pendingChanges, + setPendingChanges, + openEditDialog, +}) => { + const changed = hasChanges(product.id); + const change = pendingChanges[product.id] || {}; + const displayPrice = change.price !== undefined ? change.price : product.price; + const displayMarketPrice = change.marketPrice !== undefined ? change.marketPrice : product.marketPrice; + const displayFlashPrice = change.flashPrice !== undefined ? change.flashPrice : product.flashPrice; + + return ( + + {/* Change indicator */} + + + {changed && } + + + + {/* First row: Image and Name */} + + {/* Product image */} + + + {/* Product name and Flash Checkbox */} + + + {product.name.length > 25 ? product.name.substring(0, 25) + '...' : product.name} + + + { + const currentValue = change.isFlashAvailable ?? product.isFlashAvailable ?? false; + setPendingChanges(prev => ({ + ...prev, + [product.id]: { + ...change, + isFlashAvailable: !currentValue, + }, + })); + }} + style={tw`mr-1`} + /> + Flash + + + + + {/* Second row: Prices */} + + {/* Our Price */} + + Our Price + + ₹{displayPrice} + openEditDialog(product)} style={tw`ml-1`}> + + + + + + {/* Market Price */} + + Market Price + + {displayMarketPrice ? `₹${displayMarketPrice}` : "N/A"} + openEditDialog(product)} style={tw`ml-1`}> + + + + + + {/* Flash Price */} + + Flash Price + + {displayFlashPrice ? `₹${displayFlashPrice}` : "N/A"} + openEditDialog(product)} style={tw`ml-1`}> + + + + + + + ); +}; + +interface PendingChange { + price?: number; + marketPrice?: number | null; + flashPrice?: number | null; + isFlashAvailable?: boolean; +} + +interface EditDialogState { + open: boolean; + product: any; + tempPrice: string; + tempMarketPrice: string; + tempFlashPrice: string; +} + +export default function PricesOverview() { + const router = useRouter(); + const [selectedStores, setSelectedStores] = useState([]); + const [pendingChanges, setPendingChanges] = useState>({}); + const [editDialog, setEditDialog] = useState({ + open: false, + product: null, + tempPrice: "", + tempMarketPrice: "", + tempFlashPrice: "", + }); + const [showMenu, setShowMenu] = useState(false); + + const { data: productsData, isLoading: productsLoading, refetch: refetchProducts } = + trpc.admin.product.getProducts.useQuery(); + const { data: storesData, isLoading: storesLoading } = + trpc.admin.store.getStores.useQuery(); + + const updatePricesMutation = trpc.admin.product.updateProductPrices.useMutation(); + + const stores = storesData?.stores || []; + const allProducts = productsData?.products || []; + + // Sort stores alphabetically + const sortedStores = useMemo(() => + [...stores].sort((a, b) => a.name.localeCompare(b.name)), + [stores] + ); + + // Store options for dropdown + const storeOptions = useMemo(() => + sortedStores.map(store => ({ + label: store.name, + value: store.id.toString(), + })), + [sortedStores] + ); + + // Initialize selectedStores to all if not set + useEffect(() => { + if (stores.length > 0 && selectedStores.length === 0) { + setSelectedStores(stores.map(s => s.id.toString())); + } + }, [stores, selectedStores]); + + // Filter products by selected stores + const filteredProducts = useMemo(() => { + if (selectedStores.length === 0) return allProducts; + return allProducts.filter(product => + product.storeId && selectedStores.includes(product.storeId.toString()) + ); + }, [allProducts, selectedStores]); + + // Check if a product has changes + const hasChanges = (productId: number) => !!pendingChanges[productId]; + + // Open edit dialog + const openEditDialog = (product: any) => { + const change = pendingChanges[product.id] || {}; + setEditDialog({ + open: true, + product, + tempPrice: (change.price ?? product.price)?.toString() || "", + tempMarketPrice: (change.marketPrice ?? product.marketPrice)?.toString() || "", + tempFlashPrice: (change.flashPrice ?? product.flashPrice)?.toString() || "", + }); + }; + + // Save edit dialog + const saveEditDialog = () => { + const price = parseFloat(editDialog.tempPrice); + const marketPrice = editDialog.tempMarketPrice ? parseFloat(editDialog.tempMarketPrice) : null; + const flashPrice = editDialog.tempFlashPrice ? parseFloat(editDialog.tempFlashPrice) : null; + + if (isNaN(price) || price <= 0) { + Alert.alert("Error", "Please enter a valid price"); + return; + } + + if (editDialog.tempMarketPrice && (isNaN(marketPrice!) || marketPrice! <= 0)) { + Alert.alert("Error", "Please enter a valid market price"); + return; + } + + if (editDialog.tempFlashPrice && (isNaN(flashPrice!) || flashPrice! <= 0)) { + Alert.alert("Error", "Please enter a valid flash price"); + return; + } + + setPendingChanges(prev => ({ + ...prev, + [editDialog.product.id]: { + price: price !== editDialog.product.price ? price : undefined, + marketPrice: marketPrice !== editDialog.product.marketPrice ? marketPrice : undefined, + flashPrice: flashPrice !== editDialog.product.flashPrice ? flashPrice : undefined, + }, + })); + + setEditDialog({ open: false, product: null, tempPrice: "", tempMarketPrice: "", tempFlashPrice: "" }); + }; + + // Handle save all changes + const handleSave = () => { + const updates = Object.entries(pendingChanges).map(([productId, change]) => { + const update: any = { productId: parseInt(productId) }; + if (change.price !== undefined) update.price = change.price; + if (change.marketPrice !== undefined) update.marketPrice = change.marketPrice; + if (change.flashPrice !== undefined) update.flashPrice = change.flashPrice; + if (change.isFlashAvailable !== undefined) update.isFlashAvailable = change.isFlashAvailable; + return update; + }); + + updatePricesMutation.mutate( + { updates }, + { + onSuccess: () => { + setPendingChanges({}); + refetchProducts(); + Alert.alert("Success", "Prices updated successfully"); + }, + onError: (error: any) => { + Alert.alert("Error", `Failed to update prices: ${error.message || "Unknown error"}`); + }, + } + ); + }; + + + + const changeCount = Object.keys(pendingChanges).length; + + return ( + + {/* Stores filter, save button, and menu */} + + + setSelectedStores(value as string[])} + multiple={true} + placeholder="Select stores" + /> + + 0 && !updatePricesMutation.isPending ? tw`bg-blue-600` : tw`bg-gray-300`, + ]} + onPress={handleSave} + disabled={changeCount === 0 || updatePricesMutation.isPending} + > + {updatePricesMutation.isPending ? ( + 0 ? "white" : "#6b7280"} style={tw`mr-2`} /> + ) : ( + 0 ? "white" : "#6b7280"} + style={tw`mr-2`} + /> + )} + 0 ? tw`text-white` : tw`text-gray-500`, + ]} + > + Save ({changeCount}) + + + setShowMenu(true)} + style={tw`p-2 -mr-2`} + > + + + + + {/* Content */} + {productsLoading || storesLoading ? ( + + + Loading... + + ) : ( + ( + + )} + keyExtractor={(item) => item.id.toString()} + contentContainerStyle={tw`p-4`} + showsVerticalScrollIndicator={false} + /> + )} + + {/* Edit Dialog */} + setEditDialog({ ...editDialog, open: false, tempFlashPrice: "" })}> + + {editDialog.product?.name} + + + Our Price + setEditDialog({ ...editDialog, tempPrice: text })} + keyboardType="numeric" + placeholder="Enter price" + /> + + + + Market Price (Optional) + setEditDialog({ ...editDialog, tempMarketPrice: text })} + keyboardType="numeric" + placeholder="Enter market price" + /> + + + + Flash Price (Optional) + setEditDialog({ ...editDialog, tempFlashPrice: text })} + keyboardType="numeric" + placeholder="Enter flash price" + /> + + + + Update Price + + + + + {/* Menu Dialog */} + setShowMenu(false)}> + + + Options + + { + router.push('/rebalance-orders' as any); + setShowMenu(false); + }} + > + + + Re-Balance Orders + + + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/product-detail/[id].tsx b/apps/admin-ui/app/(drawer)/product-detail/[id].tsx new file mode 100644 index 0000000..14a21bb --- /dev/null +++ b/apps/admin-ui/app/(drawer)/product-detail/[id].tsx @@ -0,0 +1,547 @@ +import React, { useState, useEffect } from 'react'; +import { View, Text, ScrollView, TouchableOpacity, Alert, TextInput, Dimensions, ActivityIndicator, Platform } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter, useLocalSearchParams, Stack } from 'expo-router'; +import { tw, AppContainer, MyText, useMarkDataFetchers, BottomDialog, ImageUploader, ImageCarousel } from 'common-ui'; +import { MaterialIcons, FontAwesome5, Ionicons, Feather, MaterialCommunityIcons } from '@expo/vector-icons'; +import { trpc } from '@/src/trpc-client'; +import usePickImage from 'common-ui/src/components/use-pick-image'; +import { Formik } from 'formik'; +import { LinearGradient } from 'expo-linear-gradient'; +import { BlurView } from 'expo-blur'; +import Animated, { FadeInDown, FadeInUp, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated'; + +const { width: screenWidth } = Dimensions.get("window"); +const carouselHeight = screenWidth * 0.85; + +interface ReviewResponseFormProps { + reviewId: number; + onClose: () => void; +} + +const ReviewResponseForm: React.FC = ({ reviewId, onClose }) => { + const [adminResponse, setAdminResponse] = useState(''); + const [selectedImages, setSelectedImages] = useState<{ blob: Blob; mimeType: string }[]>([]); + const [displayImages, setDisplayImages] = useState<{ uri?: string }[]>([]); + const [uploadUrls, setUploadUrls] = useState([]); + + const respondToReview = trpc.admin.product.respondToReview.useMutation(); + const generateUploadUrls = trpc.user.fileUpload.generateUploadUrls.useMutation(); + + const handleImagePick = usePickImage({ + setFile: async (assets: any) => { + if (!assets || (Array.isArray(assets) && assets.length === 0)) { + setSelectedImages([]); + setDisplayImages([]); + return; + } + + const files = Array.isArray(assets) ? assets : [assets]; + const blobPromises = files.map(async (asset) => { + const response = await fetch(asset.uri); + const blob = await response.blob(); + return { blob, mimeType: asset.mimeType || 'image/jpeg' }; + }); + + const blobArray = await Promise.all(blobPromises); + setSelectedImages(blobArray); + setDisplayImages(files.map(asset => ({ uri: asset.uri }))); + }, + multiple: true, + }); + + const handleRemoveImage = (uri: string) => { + const index = displayImages.findIndex(img => img.uri === uri); + if (index !== -1) { + const newDisplay = displayImages.filter((_, i) => i !== index); + const newFiles = selectedImages.filter((_, i) => i !== index); + setDisplayImages(newDisplay); + setSelectedImages(newFiles); + } + }; + + const handleSubmit = async (adminResponse: string) => { + try { + const mimeTypes = selectedImages.map(s => s.mimeType); + const { uploadUrls: generatedUrls } = await generateUploadUrls.mutateAsync({ + contextString: 'review', + mimeTypes, + }); + const keys = generatedUrls.map(url => { + const u = new URL(url); + const rawKey = u.pathname.replace(/^\/+/, ""); + const decodedKey = decodeURIComponent(rawKey); + const parts = decodedKey.split('/'); + parts.shift(); + return parts.join('/'); + }); + setUploadUrls(generatedUrls); + + for (let i = 0; i < generatedUrls.length; i++) { + const uploadUrl = generatedUrls[i]; + const { blob, mimeType } = selectedImages[i]; + const uploadResponse = await fetch(uploadUrl, { + method: 'PUT', + body: blob, + headers: { 'Content-Type': mimeType }, + }); + if (!uploadResponse.ok) throw new Error(`Upload failed with status ${uploadResponse.status}`); + } + + await respondToReview.mutateAsync({ + reviewId, + adminResponse, + adminResponseImages: keys, + uploadUrls: generatedUrls, + }); + + Alert.alert('Success', 'Response submitted'); + onClose(); + setAdminResponse(''); + setSelectedImages([]); + setDisplayImages([]); + setUploadUrls([]); + } catch (error:any) { + + Alert.alert('Error', error.message || 'Failed to submit response.'); + } + }; + + return ( + handleSubmit(values.adminResponse)} + > + {({ handleChange, handleSubmit: formikSubmit, values }) => ( + + + + + Attach Images + + + + formikSubmit()} + activeOpacity={0.8} + disabled={respondToReview.isPending} + > + + {respondToReview.isPending ? ( + + ) : ( + Submit Response + )} + + + + )} + + ); +}; + +export default function ProductDetail() { + const { id } = useLocalSearchParams(); + const router = useRouter(); + const productId = parseInt(id as string); + + const { data: productData, isLoading, error, refetch } = trpc.admin.product.getProductById.useQuery({ id: productId }); + const { data: reviewsData } = trpc.admin.product.getProductReviews.useQuery({ productId }); + const [responseDialogOpen, setResponseDialogOpen] = useState(false); + const [selectedReview, setSelectedReview] = useState(null); + + useMarkDataFetchers(() => { + refetch(); + }); + + const toggleOutOfStock = trpc.admin.product.toggleOutOfStock.useMutation(); + + const product = productData?.product; + + const handleEdit = () => { + router.push(`/edit-product?id=${productId}` as any); + }; + + + + if (isLoading) { + return ( + + + Loading... + + ); + } + + if (error || !product) { + return ( + + + Product Not Found + router.back()} style={tw`mt-6 px-8 py-3 bg-gray-100 rounded-full`}> + Go Back + + + ); + } + + return ( + + + + + + {/* Hero Section */} + + {product.images && product.images.length > 0 ? ( + + ) : ( + + )} + + {/* Gradient Overlay */} + + + {/* Floating Header Buttons */} + + router.back()} activeOpacity={0.8}> + + + + + + + + + Edit + + + + + + {/* Content Container - Overlapping the image slightly */} + + + {/* Main Info Card */} + + + {product.name} + { + toggleOutOfStock.mutate({ id: productId }, { + onSuccess: () => Alert.alert('Success', 'Stock status updated'), + onError: (err) => Alert.alert('Error', err.message) + }); + }} + activeOpacity={0.9} + > + + + {product.isOutOfStock ? 'Out of Stock' : 'In Stock'} + + + + + + + ₹{product.price} + / {product.unit?.shortNotation} + {product.marketPrice && ( + + ₹{product.marketPrice} + + )} + + + {/* Increment Step Info */} + + + + Increment: {product.incrementStep || 1} + + + + + {/* Quick Stats Row */} + + + + + + {reviewsData?.reviews.reduce((acc, r) => acc + r.ratings, 0) + ? (reviewsData.reviews.reduce((acc, r) => acc + r.ratings, 0) / reviewsData.reviews.length).toFixed(1) + : '-'} + + + Rating + + + {reviewsData?.reviews.length || 0} + Reviews + + {/* + { + toggleOutOfStock.mutate({ id: productId }, { + onSuccess: () => Alert.alert('Success', 'Stock status updated'), + onError: (err) => Alert.alert('Error', err.message) + }); + }} + activeOpacity={0.9} + > + + + {product.isOutOfStock ? 'Out of Stock' : 'In Stock'} + + + + Stock + */} + + + + {/* Description */} + + + + + + + Description + + + {product.shortDescription && ( + {product.shortDescription} + )} + + + {product.longDescription || "No detailed description available for this product."} + + + + + {/* Availability */} + + + + + + + Availability + + + + This product is currently {product.isOutOfStock ? 'out of stock' : 'in stock'}. + + + { + toggleOutOfStock.mutate({ id: productId }, { + onSuccess: () => { + Alert.alert('Success', 'Stock status updated'); + refetch(); + }, + onError: (err) => Alert.alert('Error', err.message) + }); + }} + activeOpacity={0.8} + style={tw`bg-gray-100 px-4 py-2 rounded-full border border-gray-200 self-start`} + > + + Mark as {product.isOutOfStock ? 'In Stock' : 'Out of Stock'} + + + + + + {/* Special Deals */} + {product.deals && product.deals.length > 0 && ( + + + + + + + Special Deals + + + {product.deals.map((deal, index) => ( + + + Buy {deal.quantity} + Valid until {new Date(deal.validTill).toLocaleDateString()} + + + ₹{deal.price} + Total Price + + + ))} + + + )} + + {/* Reviews Section */} + + + + + + + + Reviews + + + {reviewsData?.reviews.length || 0} Total + + + + {reviewsData && reviewsData.reviews.length > 0 ? ( + reviewsData.reviews.map((review, idx) => ( + + + + + {review.userName} + + {[1, 2, 3, 4, 5].map((star) => ( + + ))} + + + + {review.reviewBody} + + {review.signedImageUrls && review.signedImageUrls.length > 0 && ( + + {review.signedImageUrls.map((url, index) => ( + + ))} + + )} + + {/* Admin Response Section */} + {review.adminResponse ? ( + + + + Admin Response + + {review.adminResponse} + {review.signedAdminImageUrls && review.signedAdminImageUrls.length > 0 && ( + + {review.signedAdminImageUrls.map((url, index) => ( + + ))} + + )} + + ) : ( + { + setSelectedReview(review); + setResponseDialogOpen(true); + }} + style={tw`mt-2 self-end px-4 py-2 bg-white rounded-full border border-gray-200 shadow-sm flex-row items-center`} + > + + Reply + + )} + + + + )) + ) : ( + + + No reviews yet + + )} + + + + + + + {/* Response Dialog */} + setResponseDialogOpen(false)}> + + + Reply to Review + setResponseDialogOpen(false)} style={tw`p-2 bg-gray-100 rounded-full`}> + + + + + {selectedReview && ( + + + + + Replying to {selectedReview.userName} + + + {selectedReview.reviewBody} + + + { + setResponseDialogOpen(false); + setSelectedReview(null); + }} + /> + + )} + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/product-detail/_layout.tsx b/apps/admin-ui/app/(drawer)/product-detail/_layout.tsx new file mode 100644 index 0000000..5056af2 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/product-detail/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/product-groupings/_layout.tsx b/apps/admin-ui/app/(drawer)/product-groupings/_layout.tsx new file mode 100644 index 0000000..322a451 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/product-groupings/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/product-groupings/index.tsx b/apps/admin-ui/app/(drawer)/product-groupings/index.tsx new file mode 100644 index 0000000..5ed34f9 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/product-groupings/index.tsx @@ -0,0 +1,254 @@ +import React, { useState } from "react"; +import { View, ScrollView, TouchableOpacity, Alert } from "react-native"; +import { + theme, + AppContainer, + MyText, + tw, + useManualRefresh, + useMarkDataFetchers, + MyTouchableOpacity, + BottomDialog, +} from "common-ui"; +import { trpc } from "../../../src/trpc-client"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { LinearGradient } from "expo-linear-gradient"; +import dayjs from "dayjs"; +import { useRouter } from "expo-router"; + +interface ProductGroup { + id: number; + groupName: string; + description: string | null; + createdAt: string; + products: any[]; + productCount: number; +} + +const GroupItem = ({ + group, + onEdit, + onDelete, + onViewProducts, + index, +}: { + group: ProductGroup; + onEdit: (group: ProductGroup) => void; + onDelete: (id: number) => void; + onViewProducts: (products: any[]) => void; + index: number; +}) => { + return ( + + + {/* Top Header: Name & Actions */} + + + + + + + + Group Name + + + {group.groupName} + + + + + + onEdit(group)} + style={tw`p-2 mr-2`} + > + + + onDelete(group.id)} + style={tw`p-2`} + > + + + + + + {/* Description */} + {group.description && ( + + + {group.description} + + + )} + + {/* Stats */} + + + onViewProducts(group.products)} + style={tw`flex-row items-center mr-4`} + > + + + {group.productCount} Products + + + + + + {dayjs(group.createdAt).format("MMM DD, YYYY")} + + + + + + + ); +}; + +export default function ProductGroupings() { + const router = useRouter(); + const { + data: groupsData, + isLoading, + error, + refetch, + } = trpc.admin.product.getGroups.useQuery(); + const deleteGroup = trpc.admin.product.deleteGroup.useMutation(); + + const groups = groupsData?.groups || []; + const [viewProducts, setViewProducts] = useState(null); + + useManualRefresh(refetch); + useMarkDataFetchers(() => { + refetch(); + }); + + const handleCreate = () => { + router.push("/(drawer)/create-product-group"); + }; + + const handleEdit = (group: ProductGroup) => { + router.push(`/(drawer)/edit-product-group/${group.id}`); + }; + + const handleDelete = (id: number) => { + Alert.alert("Delete Group", "Are you sure you want to delete this group?", [ + { text: "Cancel", style: "cancel" }, + { + text: "Delete", + style: "destructive", + onPress: () => { + deleteGroup.mutate( + { id }, + { + onSuccess: () => { + refetch(); + }, + } + ); + }, + }, + ]); + }; + + if (isLoading) { + return ( + + + Loading product groups... + + + ); + } + + if (error) { + return ( + + + Error loading groups + + + ); + } + + return ( + + + {groups.length === 0 ? ( + + + + + + No Groups Yet + + + Start by creating your first product group using the button below. + + + ) : ( + groups.map((group, index) => ( + + + {index < groups.length - 1 && ( + + )} + + )) + )} + + {/* Global Floating Action Button */} + + + + + + + + ); +} diff --git a/apps/admin-ui/app/(drawer)/product-tags/_layout.tsx b/apps/admin-ui/app/(drawer)/product-tags/_layout.tsx new file mode 100644 index 0000000..d3b51c0 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/product-tags/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/product-tags/index.tsx b/apps/admin-ui/app/(drawer)/product-tags/index.tsx new file mode 100644 index 0000000..01e060d --- /dev/null +++ b/apps/admin-ui/app/(drawer)/product-tags/index.tsx @@ -0,0 +1,132 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity, Alert, RefreshControl } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter } from 'expo-router'; +import { MaterialIcons } from '@expo/vector-icons'; +import { tw, MyText, useManualRefresh, useMarkDataFetchers, MyFlatList } from 'common-ui'; +import { TagMenu } from '@/src/components/TagMenu'; +import { useGetTags, Tag } from '@/src/api-hooks/tag.api'; + +interface TagItemProps { + item: Tag; + onDeleteSuccess: () => void; +} + +const TagItem: React.FC = ({ item, onDeleteSuccess }) => ( + + + + {item.imageUrl && ( + + )} + + {item.tagName} + {item.tagDescription && ( + {item.tagDescription} + )} + {item.isDashboardTag && ( + + + Dashboard Tag + + )} + + + + + +); + +interface TagHeaderProps { + onAddNewTag: () => void; +} + +const TagHeader: React.FC = ({ onAddNewTag }) => ( + + Product Tags + + + Add New Tag + + +); + +export default function ProductTags() { + const router = useRouter(); + const { data: tagsData, isLoading, error, refetch } = useGetTags(); + const [refreshing, setRefreshing] = useState(false); + + const tags = tagsData?.tags || []; + + useManualRefresh(refetch); + + useMarkDataFetchers(() => { + refetch(); + }); + + const handleRefresh = async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }; + + const handleAddNewTag = () => { + router.push('/(drawer)/add-tag'); + }; + + + + if (isLoading) { + return ( + + Loading tags... + + ); + } + + if (error) { + return ( + + + Error + {error?.message || 'Failed to load tags'} + refetch()} + style={tw`mt-4 bg-blue-500 px-4 py-2 rounded-lg`} + > + Retry + + + ); + } + + return ( + + } + keyExtractor={(item) => item.id.toString()} + showsVerticalScrollIndicator={false} + refreshControl={ + + } + ListHeaderComponent={} + contentContainerStyle={tw`pb-4`} + ListEmptyComponent={ + + + No tags yet + Create your first product tag + + } + /> + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/products/_layout.tsx b/apps/admin-ui/app/(drawer)/products/_layout.tsx new file mode 100644 index 0000000..1e70cdf --- /dev/null +++ b/apps/admin-ui/app/(drawer)/products/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/products/index.tsx b/apps/admin-ui/app/(drawer)/products/index.tsx new file mode 100644 index 0000000..9bcdbed --- /dev/null +++ b/apps/admin-ui/app/(drawer)/products/index.tsx @@ -0,0 +1,271 @@ +import React, { useState, useMemo } from 'react'; +import { View, ScrollView, TouchableOpacity, Alert, RefreshControl } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { AppContainer, MyText, tw, MyButton, useManualRefresh, MyTextInput, SearchBar, useMarkDataFetchers } from 'common-ui'; + +import { trpc } from '@/src/trpc-client'; +import { Product } from '@/src/api-hooks/product.api'; + +type FilterType = 'all' | 'in-stock' | 'out-of-stock'; + +export default function Products() { + const router = useRouter(); + const [searchTerm, setSearchTerm] = useState(''); + const [activeFilter, setActiveFilter] = useState('all'); + const [refreshing, setRefreshing] = useState(false); + + const { data: productsData, isLoading, error, refetch } = trpc.admin.product.getProducts.useQuery(); + + const toggleOutOfStockMutation = trpc.admin.product.toggleOutOfStock.useMutation(); + + useManualRefresh(refetch); + + useMarkDataFetchers(() => { + refetch(); + }); + + const products = productsData?.products || []; + + const handleRefresh = async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }; + + const filteredProducts = useMemo(() => { + return products.filter(product => { + const matchesSearch = product.name.toLowerCase().includes(searchTerm.toLowerCase()) || + (product.shortDescription?.toLowerCase().includes(searchTerm.toLowerCase())); + + const matchesFilter = activeFilter === 'all' || + (activeFilter === 'in-stock' && !product.isOutOfStock) || + (activeFilter === 'out-of-stock' && product.isOutOfStock); + + return matchesSearch && matchesFilter; + }); + }, [products, searchTerm, activeFilter]); + + const handleEdit = (productId: number) => { + router.push(`/edit-product?id=${productId}` as any); + }; + + + + // const handleToggleStock = (product: any) => { + const handleToggleStock = (product: Pick) => { + const action = product.isOutOfStock ? 'mark as in stock' : 'mark as out of stock'; + Alert.alert( + 'Update Stock Status', + `Are you sure you want to ${action} "${product.name}"?`, + [ + { text: 'Cancel', style: 'cancel' }, + { + text: 'Confirm', + onPress: () => { + toggleOutOfStockMutation.mutate({ id: product.id }, { + onSuccess: (data) => { + Alert.alert('Success', data.message); + refetch(); // Refresh the list + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update stock status'); + }, + }); + }, + }, + ] + ); + }; + + const handleViewDetails = (productId: number) => { + router.push(`/product-detail/${productId}` as any); + }; + + const FilterButton = ({ filter, label, count }: { filter: FilterType; label: string; count: number }) => ( + setActiveFilter(filter)} + style={tw`px-4 py-2 rounded-lg ${activeFilter === filter ? 'bg-blue-500' : 'bg-gray-200'}`} + > + + {label} ({count}) + + + ); + + if (isLoading) { + return ( + + + Loading products... + + + ); + } + + if (error) { + return ( + + + Error loading products + refetch()} + style={tw`mt-4 bg-blue-500 px-4 py-2 rounded-lg`} + > + Retry + + + + ); + } + + const inStockCount = products.filter(p => !p.isOutOfStock).length; + const outOfStockCount = products.filter(p => p.isOutOfStock).length; + + return ( + + + {/* Header */} + + Products + router.push('/add-product' as any)}> + Add Product + + + + {/* Search Bar */} + + {}} + placeholder="Search products..." + containerStyle={tw`mb-0`} + /> + + + + {/* Filter Tabs */} + + + + + + + {/* Products List */} + + } + > + {filteredProducts.length === 0 ? ( + + + + {searchTerm || activeFilter !== 'all' ? 'No products match your filters' : 'No products found'} + + + {searchTerm || activeFilter !== 'all' ? 'Try adjusting your search or filters' : 'Start by adding your first product'} + + {(searchTerm || activeFilter !== 'all') && ( + { + setSearchTerm(''); + setActiveFilter('all'); + }} + style={tw`mt-4 bg-blue-500 px-4 py-2 rounded-lg`} + > + Clear Filters + + )} + + ) : ( + + {filteredProducts.map(product => ( + + {/* Product Image */} + {product.images && product.images.length > 0 ? ( + + ) : ( + + + + )} + + {/* Product Info */} + + + + {product.name} + + + + + {product.isOutOfStock ? 'Out' : 'In'} + + + + + {product.shortDescription && ( + + {product.shortDescription} + + )} + + + + + ₹{product.price} + + {product.marketPrice && ( + + ₹{product.marketPrice} + + )} + + + + {/* Action Buttons */} + + handleViewDetails(product.id)} + style={tw`flex-1 bg-gray-500 p-3 rounded-lg flex-row items-center justify-center`} + > + + View + + + handleEdit(product.id)} + style={tw`flex-1 bg-blue-500 p-3 rounded-lg flex-row items-center justify-center`} + > + + Edit + + + handleToggleStock(product)} + style={tw`flex-1 ${product.isOutOfStock ? 'bg-green-500' : 'bg-orange-500'} p-3 rounded-lg flex-row items-center justify-center`} + > + + + {product.isOutOfStock ? 'Stock' : 'Out'} + + + + + + ))} + + )} + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/rebalance-orders/_layout.tsx b/apps/admin-ui/app/(drawer)/rebalance-orders/_layout.tsx new file mode 100644 index 0000000..83ba2bd --- /dev/null +++ b/apps/admin-ui/app/(drawer)/rebalance-orders/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; + +export default function RebalanceOrdersLayout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/rebalance-orders/index.tsx b/apps/admin-ui/app/(drawer)/rebalance-orders/index.tsx new file mode 100644 index 0000000..223bf16 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/rebalance-orders/index.tsx @@ -0,0 +1,239 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity, Alert, FlatList } from 'react-native'; +import { MaterialCommunityIcons } from '@expo/vector-icons'; +import { MyText, tw, MyTouchableOpacity, MyFlatList, BottomDialog } from 'common-ui'; +import { trpc } from '../../../src/trpc-client'; +import dayjs from 'dayjs'; +import { LinearGradient } from 'expo-linear-gradient'; + +interface SlotItemProps { + item: any; + selectedSlots: number[]; + toggleSlotSelection: (slotId: number) => void; + setDialogProducts: React.Dispatch>; + setDialogOpen: React.Dispatch>; +} + +const SlotItemComponent: React.FC = ({ + item: slot, + selectedSlots, + toggleSlotSelection, + setDialogProducts, + setDialogOpen, +}) => { + const isSelected = selectedSlots.includes(slot.id); + const slotProducts = slot.products?.map((p: any) => p.name).filter(Boolean) || []; + const displayProducts = slotProducts.slice(0, 2).join(', '); + const isActive = slot.isActive; + const statusColor = isActive ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'; + const statusText = isActive ? 'Active' : 'Inactive'; + + return ( + toggleSlotSelection(slot.id)} + activeOpacity={0.7} + style={tw`bg-white p-5 mb-4 rounded-3xl shadow-sm border border-gray-100`} + > + {/* Header: Checkbox, ID and Status */} + + + toggleSlotSelection(slot.id)} style={tw`mr-3`}> + + + + + + + Slot #{slot.id} + ID: {slot.id} + + + + + {statusText} + + + + + {/* Divider */} + + + {/* Details Grid */} + + {/* Delivery Time */} + + + + Delivery + + + {dayjs(slot.deliveryTime).format('DD MMM, h:mm A')} + + + + {/* Freeze Time */} + + + + Freeze + + + {dayjs(slot.freezeTime).format('DD MMM, h:mm A')} + + + + + {/* Products */} + {slotProducts.length > 0 ? ( + + + + + Products + + {displayProducts} + {slotProducts.length > 2 && ( + { + setDialogProducts(slotProducts); + setDialogOpen(true); + }} + > + + +{slotProducts.length - 2} more + + + )} + + + + + ) : null} + + ); +}; + +export default function RebalanceOrders() { + const [selectedSlots, setSelectedSlots] = useState([]); + const [dialogOpen, setDialogOpen] = useState(false); + const [dialogProducts, setDialogProducts] = useState([]); + const [refreshing, setRefreshing] = useState(false); + + const { data: slotsData, isLoading, refetch: refetchSlots } = trpc.admin.slots.getAll.useQuery(); + + const upcomingSlots = slotsData?.slots?.filter(slot => dayjs(slot.deliveryTime).isAfter(dayjs())) || []; + + const handleRefresh = async () => { + setRefreshing(true); + await refetchSlots(); + setRefreshing(false); + }; + + const { mutate: rebalanceSlots } = trpc.admin.order.rebalanceSlots.useMutation({ + onSuccess: () => { + refetchSlots(); + }, + onSettled: () => { + Alert.alert("Rebalance Complete", "Slots have been rebalanced."); + } + }); + + const toggleSlotSelection = (slotId: number) => { + setSelectedSlots(prev => + prev.includes(slotId) + ? prev.filter(id => id !== slotId) + : [...prev, slotId] + ); + }; + + const handleRebalance = () => { + Alert.alert("Rebalancing...", "Please wait while we rebalance the selected slots.", [{ text: "OK" }]); + rebalanceSlots({ slotIds: selectedSlots }); + }; + + + + if (isLoading) { + return ( + + Loading slots... + + ); + } + + return ( + + + Rebalance Upcoming Slots + {upcomingSlots.length === 0 ? ( + + No upcoming slots available for rebalancing. + + ) : ( + item.id.toString()} + renderItem={({ item }) => ( + + )} + contentContainerStyle={tw`pb-24 flex-1`} // Space for floating button + showsVerticalScrollIndicator={false} + onRefresh={handleRefresh} + refreshing={refreshing} + /> + )} + + + {/* Floating Rebalance Button */} + + + + + + + {/* Products Dialog */} + setDialogOpen(false)}> + + All Products + index.toString()} + renderItem={({ item }) => ( + + {item} + + )} + showsVerticalScrollIndicator={false} + style={tw`max-h-80`} + /> + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/slots/_layout.tsx b/apps/admin-ui/app/(drawer)/slots/_layout.tsx new file mode 100644 index 0000000..3e880a2 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/slots/_layout.tsx @@ -0,0 +1,10 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/slots/index.tsx b/apps/admin-ui/app/(drawer)/slots/index.tsx new file mode 100644 index 0000000..139161c --- /dev/null +++ b/apps/admin-ui/app/(drawer)/slots/index.tsx @@ -0,0 +1,202 @@ +import React, { useState } from 'react'; +import { MaterialCommunityIcons } from '@expo/vector-icons'; +import { View, TouchableOpacity, FlatList } from 'react-native'; +import { AppContainer, MyText, tw, MyFlatList , BottomDialog, MyTouchableOpacity } from 'common-ui'; +import { trpc } from '../../../src/trpc-client'; +import { useRouter } from 'expo-router'; +import dayjs from 'dayjs'; +import { LinearGradient } from 'expo-linear-gradient'; + +interface SlotItemProps { + item: any; + router: any; + setDialogProducts: React.Dispatch>; + setDialogOpen: React.Dispatch>; +} + +const SlotItemComponent: React.FC = ({ + item: slot, + router, + setDialogProducts, + setDialogOpen, +}) => { + const slotProducts = slot.products?.map((p: any) => p.name).filter(Boolean) || []; + const displayProducts = slotProducts.slice(0, 2).join(', '); + + const isActive = slot.isActive; + const statusColor = isActive ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'; + const statusText = isActive ? 'Active' : 'Inactive'; + + return ( + router.push(`/(drawer)/slots/slot-details?slotId=${slot.id}`)} + activeOpacity={0.7} + > + + {/* Header: ID and Status */} + + + + + + + Slot #{slot.id} + ID: {slot.id} + + + + router.push(`/edit-slot/${slot.id}` as any)} + style={tw`px-3 py-1 rounded-full bg-pink2 mr-2`} + > + + + Edit + + + + {statusText} + + + + + {/* Divider */} + + + {/* Details Grid */} + + {/* Delivery Time */} + + + + Delivery + + + {dayjs(slot.deliveryTime).format('DD MMM, h:mm A')} + + + + {/* Freeze Time */} + + + + Freeze + + + {dayjs(slot.freezeTime).format('DD MMM, h:mm A')} + + + + + {/* Products */} + {slotProducts.length > 0 ? ( + + + + + Products + + {displayProducts} + {slotProducts.length > 2 && ( + { + setDialogProducts(slotProducts); + setDialogOpen(true); + }} + > + + +{slotProducts.length - 2} more + + + )} + + + + + ) : null} + + + ); +}; + +export default function Slots() { + const router = useRouter(); + const { data: slotsData, isLoading, refetch } = trpc.admin.slots.getAll.useQuery(); + + const slots = slotsData?.slots || []; + + // Dialog state + const [dialogOpen, setDialogOpen] = useState(false); + const [dialogProducts, setDialogProducts] = useState([]); + const [refreshing, setRefreshing] = useState(false); + + const handleRefresh = async () => { + setRefreshing(true); + await refetch(); + setRefreshing(false); + }; + + + + if (isLoading) { + return ( + + Loading slots... + + ); + } + + return ( + + item.id.toString()} + renderItem={({ item }) => ( + + )} + contentContainerStyle={tw`p-4`} + onRefresh={handleRefresh} + refreshing={refreshing} + /> + + {/* FAB for Add New Slot */} + router.push('/add-slot' as any)} + activeOpacity={0.95} + style={{ position: 'absolute', bottom: 32, right: 24, zIndex: 100 }} + > + + + + + + {/* Products Dialog */} + setDialogOpen(false)}> + + All Products + index.toString()} + renderItem={({ item }) => ( + + {item} + + )} + showsVerticalScrollIndicator={false} + style={tw`max-h-80`} + /> + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/slots/slot-details.tsx b/apps/admin-ui/app/(drawer)/slots/slot-details.tsx new file mode 100644 index 0000000..d780486 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/slots/slot-details.tsx @@ -0,0 +1,245 @@ +import React, { useState } from 'react'; +import { View, ScrollView, TouchableOpacity, Alert, Share } from 'react-native'; +import { theme, AppContainer, MyText, tw, MyTouchableOpacity, BottomDialog } from 'common-ui'; +import { trpc } from '../../../src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import dayjs from "dayjs"; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { LinearGradient } from 'expo-linear-gradient'; + +export default function SlotDetails() { + const router = useRouter(); + const { slotId } = useLocalSearchParams(); + + const { data: slotData, isLoading, error } = trpc.admin.slots.getSlotById.useQuery({ + id: parseInt(slotId as string), + }); + + const slot = slotData?.slot; + const products = slot?.products || []; + const vendorSnippets = slot?.vendorSnippets || []; + + // Dialog state for snippet products + const [dialogOpen, setDialogOpen] = useState(false); + const [dialogProducts, setDialogProducts] = useState([]); + + if (isLoading) { + return ( + + + Loading slot details... + + + ); + } + + if (error || !slot) { + return ( + + + Error loading slot details + + + ); + } + + return ( + + + + {/* Header */} + + + Slot #{slot.id} + + + + + Delivery: {dayjs(slot.deliveryTime).format('MMM DD, YYYY hh:mm A')} + + + Freeze: {dayjs(slot.freezeTime).format('MMM DD, YYYY hh:mm A')} + + + + + {slot.isActive ? 'Active' : 'Inactive'} + + + + + + {/* Vendor Snippets Section */} + + + Vendor Snippets + + {vendorSnippets.length} snippets + + + + {vendorSnippets.length === 0 ? ( + + + No vendor snippets for this slot + + ) : ( + + {vendorSnippets.map((snippet, index) => { + const isExpired = snippet.validTill && dayjs(snippet.validTill).isBefore(dayjs()); + + return ( + + + + + {snippet.snippetCode} + + + + + + {isExpired ? 'Expired' : 'Active'} + + + + + + + + { + const snippetProducts = products.filter(p => snippet.productIds.includes(p.id)); + setDialogProducts(snippetProducts); + setDialogOpen(true); + }} + style={tw`flex-row items-center mr-4`} + > + + + {snippet.productIds.length} products + + + + { + try { + await Share.share({ + message: snippet.accessUrl, + }); + } catch (error) { + Alert.alert('Error', 'Failed to share link'); + } + }} + style={tw`flex-row items-center`} + > + + + Share + + + + + {snippet.validTill && ( + + + + Expires {dayjs(snippet.validTill).format('MMM DD')} + + + )} + + + {snippet.createdAt && ( + + + Created {dayjs(snippet.createdAt).format('MMM DD, YYYY')} + + + )} + + ); + })} + + )} + + + {/* Products Section */} + + + Products + + {products.length} items + + + + {products.length === 0 ? ( + + + No products in this slot + + ) : ( + + {products.map((product) => ( + + + {product.name} + + + ))} + + )} + + + + {/* FAB for Edit Slot */} + router.push(`/edit-slot/${slot.id}` as any)} + activeOpacity={0.95} + style={{ position: 'absolute', bottom: 32, right: 24, zIndex: 100 }} + > + + + + + + setDialogOpen(false)}> + + Snippet Products + + {dialogProducts.length === 0 ? ( + + + No products found for this snippet + + + ) : ( + dialogProducts.map(product => ( + + + {product.name} + + {product.shortDescription && ( + + {product.shortDescription} + + )} + + )) + )} + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/stores/_layout.tsx b/apps/admin-ui/app/(drawer)/stores/_layout.tsx new file mode 100644 index 0000000..4e26ba9 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/stores/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/stores/index.tsx b/apps/admin-ui/app/(drawer)/stores/index.tsx new file mode 100644 index 0000000..e923171 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/stores/index.tsx @@ -0,0 +1,224 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity, Dimensions, ActivityIndicator, RefreshControl, Alert } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter } from 'expo-router'; +import { MaterialIcons, Feather } from '@expo/vector-icons'; +import { MyText, tw, MyButton, useMarkDataFetchers } from 'common-ui'; +import MyFlatList from 'common-ui/src/components/flat-list'; +import { trpc } from '@/src/trpc-client'; +import { LinearGradient } from 'expo-linear-gradient'; +import Animated, { FadeInDown, FadeInUp } from 'react-native-reanimated'; + +const { width: screenWidth } = Dimensions.get('window'); + +interface StoreItemProps { + item: any; + index: number; + isEditMode: boolean; + onEdit: (storeId: number) => void; + onDelete: (storeId: number) => void; +} + +const StoreItem: React.FC = ({ item, index, isEditMode, onEdit, onDelete }) => { + const CARD_MARGIN = 8; + const cardWidth = (screenWidth - 32 - CARD_MARGIN * 2) / 2; + + return ( + + + {/* Delete Button - Only visible in edit mode */} + {isEditMode && ( + onDelete(item.id)} + style={tw`absolute top-2 right-2 z-10 bg-red-500 p-2 rounded-full shadow-lg`} + > + + + )} + + onEdit(item.id)} + style={tw`flex-1`} + disabled={isEditMode} // Disable navigation in edit mode + > + {/* Image Section - Portrait oriented */} + + {item.imageUrl ? ( + + ) : ( + + + + )} + + {/* Status Dot */} + + + + {/* Content Section */} + + + {item.name} + + + + ID: #{item.id} + + + {item.createdAt ? new Date(item.createdAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) : 'N/A'} + + + + {/* Action Footer */} + + View Details + + + + + + + ); +}; + +export default function Stores() { + const router = useRouter(); + const [isEditMode, setIsEditMode] = useState(false); + + const { data: storesData, isLoading, error, refetch } = trpc.admin.store.getStores.useQuery(); + const { mutate: deleteStore, mutateAsync: deleteStoreAsync} = trpc.admin.store.deleteStore.useMutation(); + + useMarkDataFetchers(() => { + refetch(); + }); + + const stores = storesData?.stores || []; + + const handleEdit = (storeId: number) => { + router.push({ pathname: '/edit-store', params: { id: storeId } }); + }; + + const handleDelete = (storeId: number) => { + Alert.alert( + "Delete Store", + "Are you sure you want to delete this store? This action cannot be undone. All products will be unassigned from this store.", + [ + { text: "Cancel", style: "cancel" }, + { + text: "Delete", + style: "destructive", + onPress: async () => { + try { + await deleteStoreAsync({ storeId }); + refetch(); + Alert.alert("Success", "Store deleted successfully"); + } catch (error: any) { + Alert.alert("Error", error.message || "Failed to delete store"); + } + } + } + ] + ); + }; + + const CARD_MARGIN = 8; + const cardWidth = (screenWidth - 32 - CARD_MARGIN * 2) / 2; + + + + if (isLoading) { + return ( + + + Loading stores... + + ); + } + + if (error) { + return ( + + + + + Oops! + We couldn't load the stores. Please try again. + refetch()} style={tw`bg-red-500 px-8 py-3 rounded-xl`}> + Retry + + + ); + } + + return ( + + item.id.toString()} + renderItem={({ item, index }) => } + numColumns={2} + columnWrapperStyle={tw`justify-start`} + contentContainerStyle={tw`p-2 pb-24`} + refreshControl={} + ListHeaderComponent={ + + + + Stores + Manage your outlets + + + setIsEditMode(!isEditMode)} + style={tw`bg-white border border-gray-200 px-4 py-2 rounded-full shadow-sm mr-2`} + > + + {isEditMode ? 'Done' : 'Edit'} + + + + {stores.length} Locations + + + + + } + ListEmptyComponent={ + + + No stores found + Get started by adding your first store location. + + } + /> + + {/* Floating Action Button for Adding New Store */} + + router.push('/add-store' as any)} + > + + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/user-details/[id]/index.tsx b/apps/admin-ui/app/(drawer)/user-details/[id]/index.tsx new file mode 100644 index 0000000..8d8d420 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/user-details/[id]/index.tsx @@ -0,0 +1,158 @@ +import React from 'react'; +import { View, TouchableOpacity, Alert } from 'react-native'; +import { useLocalSearchParams, useRouter } from 'expo-router'; +import { AppContainer, MyText, tw } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import dayjs from 'dayjs'; + +export default function UserDetails() { + const { id } = useLocalSearchParams<{ id: string }>(); + const router = useRouter(); + + const { data: userData, isLoading, error, refetch } = trpc.admin.staffUser.getUserDetails.useQuery( + { userId: id ? parseInt(id) : 0 }, + { enabled: !!id } + ); + + const updateSuspensionMutation = trpc.admin.staffUser.updateUserSuspension.useMutation({ + onSuccess: () => { + refetch(); + Alert.alert('Success', 'User suspension status updated'); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update suspension'); + }, + }); + + const handleToggleSuspension = () => { + if (!userData) return; + const newStatus = !userData.isSuspended; + updateSuspensionMutation.mutate({ + userId: userData.id, + isSuspended: newStatus, + }); + }; + + if (isLoading) { + return ( + + + Loading user details... + + + ); + } + + if (error || !userData) { + return ( + + + + + Error + + + {error?.message || "Failed to load user details"} + + router.back()} + style={tw`mt-6 bg-gray-900 px-6 py-3 rounded-xl`} + > + Go Back + + + + ); + } + + const user = userData; + + return ( + + + {/* User Info */} + + + + + + + + {user.name || 'n/a'} + User ID: {user.id} + + + + + + + {user.mobile} + + + + + {user.email} + + + + + + Added on {dayjs(user.addedOn).format('MMM DD, YYYY')} + + + + + + + {user.lastOrdered + ? `Last ordered ${dayjs(user.lastOrdered).format('MMM DD, YYYY')}` + : 'No orders yet' + } + + + + + + {/* Suspension Status */} + + + + + + + {user.isSuspended ? 'Suspended' : 'Active'} + + + {user.isSuspended ? 'User is suspended' : 'User is active'} + + + + + + {updateSuspensionMutation.isPending + ? 'Updating...' + : user.isSuspended + ? 'Revoke Suspension' + : 'Suspend User' + } + + + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/users/index.tsx b/apps/admin-ui/app/(drawer)/users/index.tsx new file mode 100644 index 0000000..b009f7a --- /dev/null +++ b/apps/admin-ui/app/(drawer)/users/index.tsx @@ -0,0 +1,93 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter } from 'expo-router'; +import { AppContainer, MyText, tw, MyFlatList, MyTextInput } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import Ionicons from '@expo/vector-icons/Ionicons'; + +interface UserItemProps { + item: any; + onPress: (userId: string) => void; +} + +const UserItem: React.FC = ({ item, onPress }) => ( + onPress(item.id)} + > + {item.image ? ( + + ) : ( + + + + )} + + {item.name} + {item.email} + {item.mobile} + + +); + +export default function Users() { + const router = useRouter(); + const [search, setSearch] = useState(''); + + const { + data, + isLoading, + fetchNextPage, + hasNextPage, + refetch, + } = trpc.admin.staffUser.getUsers.useInfiniteQuery( + { search }, + { + getNextPageParam: (lastPage) => lastPage.nextCursor, + } + ); + + const users = data?.pages.flatMap(page => page.users) || []; + + const handleUserPress = (userId: string) => { + router.push(`/user-details/${userId}`); + }; + + return ( + + + + + + + } + keyExtractor={(item) => item.id.toString()} + onRefresh={refetch} + onEndReached={() => { + if (hasNextPage) { + fetchNextPage(); + } + }} + onEndReachedThreshold={0.5} + ListEmptyComponent={ + + No users found + + } + /> + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/vendor-snippets/_layout.tsx b/apps/admin-ui/app/(drawer)/vendor-snippets/_layout.tsx new file mode 100644 index 0000000..578ff56 --- /dev/null +++ b/apps/admin-ui/app/(drawer)/vendor-snippets/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router'; + +export default function Layout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/(drawer)/vendor-snippets/index.tsx b/apps/admin-ui/app/(drawer)/vendor-snippets/index.tsx new file mode 100644 index 0000000..cd7e94b --- /dev/null +++ b/apps/admin-ui/app/(drawer)/vendor-snippets/index.tsx @@ -0,0 +1,307 @@ +import React, { useState } from 'react'; +import { View, ScrollView, TouchableOpacity, Alert, Dimensions, Share } from 'react-native'; +import { theme, AppContainer, MyText, tw, useManualRefresh, useMarkDataFetchers, MyTouchableOpacity } from 'common-ui'; +import { trpc, trpcClient } from '../../../src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { Ionicons } from "@expo/vector-icons"; +import dayjs from "dayjs"; +import { LinearGradient } from "expo-linear-gradient"; +import { useRouter } from 'expo-router'; + +import VendorSnippetForm from '../../../components/VendorSnippetForm'; +import SnippetOrdersView from '../../../components/SnippetOrdersView'; +import { SnippetMenu } from '../../../components/SnippetMenu'; + +interface VendorSnippet { + id: number; + snippetCode: string; + slotId: number; + productIds: number[]; + validTill: string | null; + createdAt: string; + accessUrl: string; + slot?: { + id: number; + deliveryTime: string; + freezeTime: string; + isActive: boolean; + deliverySequence?: unknown; + }; +} + +const SnippetItem = ({ + snippet, + onEdit, + onDelete, + onViewOrders, + index +}: { + snippet: VendorSnippet; + onEdit: (snippet: VendorSnippet) => void; + onDelete: (id: number) => void; + onViewOrders: (snippetCode: string) => void; + index: number; +}) => { + const isExpired = snippet.validTill && dayjs(snippet.validTill).isBefore(dayjs()); + + const handleCopyLink = async () => { + try { + await Share.share({ + message: snippet.accessUrl, + }); + } catch (error) { + Alert.alert('Error', 'Failed to share link'); + } + }; + + return ( + + + {/* Top Header: ID & Status */} + + + + + + + + Identifier + + + {snippet.snippetCode} + + + + + + + + + {isExpired ? 'Expired' : 'Active'} + + + + + + + {/* Middle: Delivery Banner */} + + + + + + + {snippet.slot?.deliveryTime ? dayjs(snippet.slot.deliveryTime).format('ddd, MMM DD') : 'Schedule Pending'} + + + Time: {snippet.slot?.deliveryTime ? dayjs(snippet.slot.deliveryTime).format('hh:mm A') : 'N/A'} + + + {snippet.validTill && ( + + Expires + + {dayjs(snippet.validTill).format('MMM DD')} + + + )} + + + {/* Stats & Actions */} + + + + + {snippet.productIds.length} Items + + + + Share + + + + router.push(`/(drawer)/slots/slot-details?slotId=${snippet.slotId}`)} + onPress={() => {}} + activeOpacity={0.7} + style={tw`flex-row items-center`} + > + View Slot + + + + + + ); +}; + +export default function VendorSnippets() { + // const { data: snippets, isLoading, error, refetch } = useVendorSnippets(); + const { data: snippets, isLoading, error, refetch } = trpc.admin.vendorSnippets.getAll.useQuery(); + + const createSnippet = trpc.admin.vendorSnippets.create.useMutation(); + const updateSnippet = trpc.admin.vendorSnippets.update.useMutation(); + const deleteSnippet = trpc.admin.vendorSnippets.delete.useMutation(); + // const createSnippet = useCreateVendorSnippet(); + // const updateSnippet = useUpdateVendorSnippet(); + // const deleteSnippet = useDeleteVendorSnippet(); + + const router = useRouter(); + + const [showCreateForm, setShowCreateForm] = useState(false); + const [editingSnippet, setEditingSnippet] = useState(null); + const [showOrdersView, setShowOrdersView] = useState(false); + const [ordersData, setOrdersData] = useState(null); + + + useManualRefresh(refetch); + + useMarkDataFetchers(() => { + refetch(); + }); + + const handleCreate = () => { + setShowCreateForm(true); + setEditingSnippet(null); + }; + + const handleEdit = (snippet: VendorSnippet) => { + setEditingSnippet(snippet); + setShowCreateForm(true); + }; + + const handleDelete = (id: number) => { + deleteSnippet.mutate({ id }, { + onSuccess: () => { + refetch(); + } + }); + }; + + const handleViewOrders = async (snippetCode: string) => { + try { + const result = await trpcClient.admin.vendorSnippets.getOrdersBySnippet.query({ snippetCode }); + if (result.success) { + setOrdersData({ + orders: result.data, + snippetCode: snippetCode, + }); + setShowOrdersView(true); + } else { + Alert.alert('Error', 'Failed to fetch orders'); + } + } catch (error: any) { + Alert.alert('Error', error.message || 'Failed to fetch orders'); + } + }; + + if (isLoading) { + return ( + + + Loading vendor snippets... + + + ); + } + + if (error) { + return ( + + + Error loading snippets + + + ); + } + + if (showOrdersView && ordersData) { + return ( + { + setShowOrdersView(false); + setOrdersData(null); + }} + /> + ); + } + + if (showCreateForm) { + return ( + { + setShowCreateForm(false); + setEditingSnippet(null); + }} + onSuccess={() => { + setShowCreateForm(false); + setEditingSnippet(null); + refetch(); + }} + /> + ); + } + + return ( + + + + {snippets && snippets.length === 0 ? ( + + + + + No Snippets Yet + + Start by creating your first vendor identifier using the button below. + + + ) : ( + snippets?.map((snippet, index) => ( + + + {index < snippets.length - 1 && ( + + )} + + )) + )} + + + {/* Global Floating Action Button */} + + + + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/app/_layout.tsx b/apps/admin-ui/app/_layout.tsx new file mode 100644 index 0000000..4382da7 --- /dev/null +++ b/apps/admin-ui/app/_layout.tsx @@ -0,0 +1,23 @@ +import { QueryClientProvider } from "@tanstack/react-query"; +import queryClient from "../utils/queryClient"; +import { Stack } from "expo-router"; +import { StaffAuthProvider } from "@/components/context/staff-auth-context"; +import { trpc, trpcClient } from "@/src/trpc-client"; +import { SafeAreaView } from "react-native-safe-area-context"; +import { RefreshProvider } from '../../../packages/ui/src/lib/refresh-context'; + +export default function Layout() { + return ( + + + + + + + + + + + + ); +} diff --git a/apps/admin-ui/app/index.tsx b/apps/admin-ui/app/index.tsx new file mode 100644 index 0000000..01ac0aa --- /dev/null +++ b/apps/admin-ui/app/index.tsx @@ -0,0 +1,27 @@ +import { Redirect } from 'expo-router'; +import { useStaffAuth } from '@/components/context/staff-auth-context'; +import { View, ActivityIndicator } from 'react-native'; +import { AppContainer } from 'common-ui'; + +export default function Index() { + const { isLoggedIn, isLoading } = useStaffAuth() ; + + // Show loading while checking auth + if (isLoading) { + return ( + + + + + + ); + } + + if(isLoggedIn){ + return ; + } + else { + return ; + } + +} \ No newline at end of file diff --git a/apps/admin-ui/app/login.tsx b/apps/admin-ui/app/login.tsx new file mode 100644 index 0000000..4e5e098 --- /dev/null +++ b/apps/admin-ui/app/login.tsx @@ -0,0 +1,91 @@ +import React, { useState } from "react"; +import { View, Alert } from "react-native"; +import { useRouter } from "expo-router"; +import MyTextInput from "common-ui/src/components/textinput"; +import MyButton from "common-ui/src/components/button"; +import AppContainer from "common-ui/src/components/app-container"; +import MyText from "common-ui/src/components/text"; +import { useStaffAuth } from "@/components/context/staff-auth-context"; + +export default function LoginScreen() { + const [name, setName] = useState(""); + const [password, setPassword] = useState(""); + const { login, isLoggingIn, loginError } = useStaffAuth(); + const router = useRouter(); + + const handleLogin = async () => { + if (!name.trim() || !password.trim()) { + Alert.alert("Error", "Please enter both name and password"); + return; + } + + try { + await login(name.trim(), password); + } catch (error) { + // Error is handled in the context + } + }; + + console.log('from the login page') + + + return ( + + + + Admin Login + + + + + + + {loginError && ( + + {loginError} + + )} + + + + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/assets/fonts/SpaceMono-Regular.ttf b/apps/admin-ui/assets/fonts/SpaceMono-Regular.ttf new file mode 100755 index 0000000..28d7ff7 Binary files /dev/null and b/apps/admin-ui/assets/fonts/SpaceMono-Regular.ttf differ diff --git a/apps/admin-ui/assets/images/adaptive-icon.png b/apps/admin-ui/assets/images/adaptive-icon.png new file mode 100755 index 0000000..03d6f6b Binary files /dev/null and b/apps/admin-ui/assets/images/adaptive-icon.png differ diff --git a/apps/admin-ui/assets/images/farm2door-logo.png b/apps/admin-ui/assets/images/farm2door-logo.png new file mode 100644 index 0000000..95f9b8b Binary files /dev/null and b/apps/admin-ui/assets/images/farm2door-logo.png differ diff --git a/apps/admin-ui/assets/images/favicon.png b/apps/admin-ui/assets/images/favicon.png new file mode 100755 index 0000000..e75f697 Binary files /dev/null and b/apps/admin-ui/assets/images/favicon.png differ diff --git a/apps/admin-ui/assets/images/icon.png b/apps/admin-ui/assets/images/icon.png new file mode 100755 index 0000000..a0b1526 Binary files /dev/null and b/apps/admin-ui/assets/images/icon.png differ diff --git a/apps/admin-ui/assets/images/partial-react-logo.png b/apps/admin-ui/assets/images/partial-react-logo.png new file mode 100755 index 0000000..66fd957 Binary files /dev/null and b/apps/admin-ui/assets/images/partial-react-logo.png differ diff --git a/apps/admin-ui/assets/images/react-logo.png b/apps/admin-ui/assets/images/react-logo.png new file mode 100755 index 0000000..9d72a9f Binary files /dev/null and b/apps/admin-ui/assets/images/react-logo.png differ diff --git a/apps/admin-ui/assets/images/react-logo@2x.png b/apps/admin-ui/assets/images/react-logo@2x.png new file mode 100755 index 0000000..2229b13 Binary files /dev/null and b/apps/admin-ui/assets/images/react-logo@2x.png differ diff --git a/apps/admin-ui/assets/images/react-logo@3x.png b/apps/admin-ui/assets/images/react-logo@3x.png new file mode 100755 index 0000000..a99b203 Binary files /dev/null and b/apps/admin-ui/assets/images/react-logo@3x.png differ diff --git a/apps/admin-ui/assets/images/splash-icon.png b/apps/admin-ui/assets/images/splash-icon.png new file mode 100755 index 0000000..03d6f6b Binary files /dev/null and b/apps/admin-ui/assets/images/splash-icon.png differ diff --git a/apps/admin-ui/assets/images/symbuyoteadmin.png b/apps/admin-ui/assets/images/symbuyoteadmin.png new file mode 100644 index 0000000..a6c3c99 Binary files /dev/null and b/apps/admin-ui/assets/images/symbuyoteadmin.png differ diff --git a/apps/admin-ui/components/AddressPlaceForm.tsx b/apps/admin-ui/components/AddressPlaceForm.tsx new file mode 100644 index 0000000..89ea40f --- /dev/null +++ b/apps/admin-ui/components/AddressPlaceForm.tsx @@ -0,0 +1,64 @@ +import React from 'react' +import { Formik } from 'formik' +import * as Yup from 'yup' +import { View, Text, TouchableOpacity } from 'react-native' +import { MyTextInput, BottomDropdown, tw } from 'common-ui' +import { trpc } from '@/src/trpc-client' + +interface AddressPlaceFormProps { + onSubmit: (values: { placeName: string; zoneId: number | null }) => void + onClose: () => void +} + +const AddressPlaceForm: React.FC = ({ onSubmit, onClose }) => { + const { data: zones } = trpc.admin.address.getZones.useQuery() + + const validationSchema = Yup.object({ + placeName: Yup.string().required('Place name is required'), + zoneId: Yup.number().optional(), + }) + + const zoneOptions = zones?.map(z => ({ label: z.zoneName, value: z.id })) || [] + + return ( + + Add Place + { + onSubmit(values) + onClose() + }} + > + {({ handleChange, setFieldValue, handleSubmit, values, errors, touched }) => ( + + + setFieldValue('zoneId', value as number | undefined)} + placeholder="Select Zone" + /> + + + Cancel + + handleSubmit()}> + Create + + + + )} + + + ) +} + +export default AddressPlaceForm \ No newline at end of file diff --git a/apps/admin-ui/components/AddressZoneForm.tsx b/apps/admin-ui/components/AddressZoneForm.tsx new file mode 100644 index 0000000..db00ecd --- /dev/null +++ b/apps/admin-ui/components/AddressZoneForm.tsx @@ -0,0 +1,51 @@ +import React from 'react' +import { Formik } from 'formik' +import * as Yup from 'yup' +import { View, Text, TouchableOpacity } from 'react-native' +import { MyTextInput, tw } from 'common-ui' + +interface AddressZoneFormProps { + onSubmit: (values: { zoneName: string }) => void + onClose: () => void +} + +const AddressZoneForm: React.FC = ({ onSubmit, onClose }) => { + const validationSchema = Yup.object({ + zoneName: Yup.string().required('Zone name is required'), + }) + + return ( + + Add Zone + { + onSubmit(values) + onClose() + }} + > + {({ handleChange, handleSubmit, values, errors, touched }) => ( + + + + + Cancel + + handleSubmit()}> + Create + + + + )} + + + ) +} + +export default AddressZoneForm \ No newline at end of file diff --git a/apps/admin-ui/components/BannerForm.tsx b/apps/admin-ui/components/BannerForm.tsx new file mode 100644 index 0000000..a95f4bd --- /dev/null +++ b/apps/admin-ui/components/BannerForm.tsx @@ -0,0 +1,262 @@ +import React, { useState } from 'react'; +import { View, ScrollView, TouchableOpacity, Alert } from 'react-native'; +import { Formik, FormikHelpers } from 'formik'; +import * as Yup from 'yup'; +import { MyText, tw, MyTextInput, MyTouchableOpacity, ImageUploader, BottomDropdown } from 'common-ui'; +import { DropdownOption } from 'common-ui/src/components/bottom-dropdown'; +import { trpc } from '../src/trpc-client'; +import usePickImage from 'common-ui/src/components/use-pick-image'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +export interface BannerFormData { + name: string; + imageUrl: string; + description: string; + productIds: number[]; + redirectUrl: string; + // serialNum removed - will be assigned automatically by backend +} + +interface BannerFormProps { + initialValues: BannerFormData; + onSubmit: (values: BannerFormData, imageUrl?: string) => Promise | void; + onCancel: () => void; + submitButtonText?: string; + isSubmitting?: boolean; + existingImageUrl?: string; + mode?: 'create' | 'edit'; +} + +const validationSchema = Yup.object().shape({ + name: Yup.string().trim().required('Banner name is required').max(255), + description: Yup.string().max(500), + productIds: Yup.array() + .of(Yup.number()) + .optional(), + redirectUrl: Yup.string() + .url('Please enter a valid URL') + .optional(), + // serialNum validation removed - assigned automatically by backend +}); + +export default function BannerForm({ + initialValues, + onSubmit, + onCancel, + submitButtonText = 'Create Banner', + isSubmitting = false, + existingImageUrl, + mode = 'create', +}: BannerFormProps) { + const [selectedImages, setSelectedImages] = useState<{ blob: Blob; mimeType: string }[]>([]); + const [displayImages, setDisplayImages] = useState<{ uri?: string }[]>([]); + + const generateUploadUrls = trpc.common.generateUploadUrls.useMutation(); + + // Fetch products for dropdown + const { data: productsData } = trpc.common.product.getAllProductsSummary.useQuery({}); + const products = productsData?.products || []; + + // Create product options for dropdown + const productOptions: DropdownOption[] = products.map(product => ({ + label: `${product.name} (${product.price})`, + value: product.id, + })); + + + const handleImagePick = usePickImage({ + setFile: async (assets: any) => { + if (!assets || (Array.isArray(assets) && assets.length === 0)) { + setSelectedImages([]); + setDisplayImages([]); + return; + } + + const files = Array.isArray(assets) ? assets : [assets]; + const blobPromises = files.map(async (asset) => { + const response = await fetch(asset.uri); + const blob = await response.blob(); + return { blob, mimeType: asset.mimeType || 'image/jpeg' }; + }); + + const blobArray = await Promise.all(blobPromises); + setSelectedImages(blobArray); + setDisplayImages(files.map(asset => ({ uri: asset.uri }))); + }, + multiple: false, // Single image for banners + }); + + const handleRemoveImage = (uri: string) => { + const index = displayImages.findIndex(img => img.uri === uri); + if (index !== -1) { + const newDisplay = displayImages.filter((_, i) => i !== index); + const newFiles = selectedImages.filter((_, i) => i !== index); + setDisplayImages(newDisplay); + setSelectedImages(newFiles); + } + }; + const handleFormikSubmit = async (values: BannerFormData) => { + try { + let imageUrl: string | undefined; + + if (selectedImages.length > 0) { + // Generate upload URLs + const mimeTypes = selectedImages.map(s => s.mimeType); + const { uploadUrls } = await generateUploadUrls.mutateAsync({ + contextString: 'store', // Using 'store' for now + mimeTypes, + }); + + // Upload image + const uploadUrl = uploadUrls[0]; + const { blob, mimeType } = selectedImages[0]; + + const uploadResponse = await fetch(uploadUrl, { + method: 'PUT', + body: blob, + headers: { + 'Content-Type': mimeType, + }, + }); + + if (!uploadResponse.ok) { + throw new Error(`Upload failed with status ${uploadResponse.status}`); + } + + imageUrl = uploadUrl; + } + + // Call onSubmit with form values and imageUrl + await onSubmit(values, imageUrl); + } catch (error) { + console.error('Upload error:', error); + Alert.alert('Error', 'Failed to upload image'); + } + }; + + return ( + + {({ + handleChange, + handleBlur, + handleSubmit, + values, + errors, + touched, + isValid, + dirty, + setFieldValue, + }) => ( + + + + {errors.name && touched.name && ( + {errors.name} + )} + + + Banner Image + { + // Handle removing existing image in edit mode + }} + allowMultiple={false} + /> + + + + {errors.description && touched.description && ( + {errors.description} + )} + + + { + const selectedValues = Array.isArray(value) ? value : [value]; + setFieldValue('productIds', selectedValues.map(v => Number(v))); + }} + placeholder="Select products for banner (optional)" + multiple={true} + /> + + + + {errors.redirectUrl && touched.redirectUrl && ( + {errors.redirectUrl} + )} + + + + {/* Action Buttons */} + + + Cancel + + + handleSubmit()} + disabled={isSubmitting || !isValid || !dirty} + style={tw`flex-1 rounded-lg py-4 items-center ${ + isSubmitting || !isValid || !dirty + ? 'bg-blue-400' + : 'bg-blue-600' + }`} + > + + {isSubmitting ? 'Saving...' : submitButtonText} + + + + + + )} + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/components/CancelOrderDialog.tsx b/apps/admin-ui/components/CancelOrderDialog.tsx new file mode 100644 index 0000000..c9805fe --- /dev/null +++ b/apps/admin-ui/components/CancelOrderDialog.tsx @@ -0,0 +1,97 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity } from 'react-native'; +import { MyText, tw, BottomDialog, MyTextInput } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { Alert } from 'react-native'; + +interface CancelOrderDialogProps { + orderId: number; + open: boolean; + onClose: () => void; + onSuccess?: () => void; +} + +export default function CancelOrderDialog({ orderId, open, onClose, onSuccess }: CancelOrderDialogProps) { + const [cancelReason, setCancelReason] = useState(''); + const cancelOrderMutation = trpc.admin.order.cancelOrder.useMutation(); + + const handleCancel = () => { + if (!cancelReason.trim()) { + Alert.alert('Error', 'Please enter a cancellation reason'); + return; + } + + Alert.alert( + 'Cancel Order', + 'Are you sure you want to cancel this order? This action cannot be undone.', + [ + { text: 'No', style: 'cancel' }, + { + text: 'Yes, Cancel', + style: 'destructive', + onPress: () => { + cancelOrderMutation.mutate( + { orderId, reason: cancelReason }, + { + onSuccess: () => { + onClose(); + setCancelReason(''); + onSuccess?.(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to cancel order'); + }, + } + ); + }, + }, + ] + ); + }; + + return ( + + + + + + + + Cancel Order + + + This will cancel the order and mark it as cancelled by admin. A refund record will be created. + + + + + + + + Keep Order + + + + {cancelOrderMutation.isPending ? 'Cancelling...' : 'Cancel Order'} + + + + + + ); +} diff --git a/apps/admin-ui/components/FullOrderView.tsx b/apps/admin-ui/components/FullOrderView.tsx new file mode 100644 index 0000000..0671492 --- /dev/null +++ b/apps/admin-ui/components/FullOrderView.tsx @@ -0,0 +1,197 @@ +import React from 'react'; +import { View, ScrollView, Dimensions } from 'react-native'; +import { Image } from 'expo-image'; +import { MyText, tw } from 'common-ui'; +import { trpc } from '../src/trpc-client'; + +interface FullOrderViewProps { + orderId: number; +} + +export const FullOrderView: React.FC = ({ orderId }) => { + const { data: order, isLoading, error } = trpc.admin.order.getFullOrder.useQuery({ orderId }); + + if (isLoading) { + return ( + + Loading order details... + + ); + } + + if (error || !order) { + return ( + + Failed to load order details + + ); + } + + const totalAmount = order.items.reduce((sum, item) => sum + item.amount, 0); + + return ( + + + Order #{order.readableId} + + {/* Customer Information */} + + Customer Details + + + Name: + {order.customerName} + + {order.customerEmail && ( + + Email: + {order.customerEmail} + + )} + + Mobile: + {order.customerMobile} + + + + + {/* Delivery Address */} + + Delivery Address + + {order.address.line1} + {order.address.line2 && {order.address.line2}} + + {order.address.city}, {order.address.state} - {order.address.pincode} + + Phone: {order.address.phone} + + + + {/* Order Details */} + + Order Details + + + Order Date: + + {new Date(order.createdAt).toLocaleDateString('en-IN', { + day: 'numeric', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit' + })} + + + + Payment Method: + + {order.isCod ? 'Cash on Delivery' : 'Online Payment'} + + + {order.slotInfo && ( + + Delivery Slot: + + {new Date(order.slotInfo.time).toLocaleDateString('en-IN', { + day: 'numeric', + month: 'short', + hour: '2-digit', + minute: '2-digit' + })} + + + )} + + + + {/* Items */} + + Items ({order.items.length}) + {order.items.map((item, index) => ( + + + + {item.productName} + + + Qty: {item.quantity} {item.unit} × ₹{parseFloat(item.price.toString()).toFixed(2)} + + + ₹{item.amount.toFixed(2)} + + ))} + + + {/* Payment Information */} + {(order.payment || order.paymentInfo) && ( + + Payment Information + {order.payment && ( + + Payment Details: + + Status: + {order.payment.status} + + + Gateway: + {order.payment.gateway} + + + Order ID: + {order.payment.merchantOrderId} + + + )} + {order.paymentInfo && ( + + Payment Info: + + Status: + {order.paymentInfo.status} + + + Gateway: + {order.paymentInfo.gateway} + + + Order ID: + {order.paymentInfo.merchantOrderId} + + + )} + + )} + + {/* User Notes */} + {order.userNotes && ( + + Customer Notes + {order.userNotes} + + )} + + {/* Admin Notes */} + {order.adminNotes && ( + + Admin Notes + {order.adminNotes} + + )} + + {/* Total */} + + + Total Amount + ₹{parseFloat(order.totalAmount.toString()).toFixed(2)} + + + + + ); +}; \ No newline at end of file diff --git a/apps/admin-ui/components/HorizontalImageScroller.tsx b/apps/admin-ui/components/HorizontalImageScroller.tsx new file mode 100755 index 0000000..b7afad8 --- /dev/null +++ b/apps/admin-ui/components/HorizontalImageScroller.tsx @@ -0,0 +1,45 @@ +import React from "react"; +import { ScrollView, View, StyleSheet } from "react-native"; +import { ImageViewerURI } from "common-ui"; + +interface HorizontalImageScrollerProps { + urls: string[]; + imageHeight?: number; + imageWidth?: number; +} + +const HorizontalImageScroller: React.FC = ({ + urls, + imageHeight = 128, + imageWidth = 128, +}) => { + if (!urls || urls.length === 0) return null; + + + return ( + + + {urls.map((url, idx) => ( + + + + ))} + + + ); +}; + +const styles = StyleSheet.create({ + container: { + marginVertical: 8, + }, +}); + +export default HorizontalImageScroller; diff --git a/apps/admin-ui/components/OrderNotesForm.tsx b/apps/admin-ui/components/OrderNotesForm.tsx new file mode 100644 index 0000000..4315e70 --- /dev/null +++ b/apps/admin-ui/components/OrderNotesForm.tsx @@ -0,0 +1,80 @@ +import React, { useState } from 'react'; +import { View, TextInput, TouchableOpacity, Alert } from 'react-native'; +import { MyText, MyButton } from 'common-ui'; +import { trpc } from '../src/trpc-client'; + +interface OrderNotesFormProps { + orderId: number; + initialNotes?: string; + onSuccess?: () => void; + onCancel?: () => void; +} + +export const OrderNotesForm: React.FC = ({ + orderId, + initialNotes = '', + onSuccess, + onCancel, +}) => { + const [notes, setNotes] = useState(initialNotes); + const updateNotesMutation = trpc.admin.order.updateNotes.useMutation(); + + const handleSubmit = async () => { + if (!notes.trim()) { + Alert.alert('Error', 'Please enter some notes'); + return; + } + + try { + await updateNotesMutation.mutateAsync({ + orderId, + adminNotes: notes.trim(), + }); + Alert.alert('Success', 'Notes updated successfully'); + onSuccess?.(); + } catch (error) { + Alert.alert('Error', 'Failed to update notes'); + } + }; + + return ( + + + Add Order Notes + + + + + + + + + + ); +}; \ No newline at end of file diff --git a/apps/admin-ui/components/ProductGroupForm.tsx b/apps/admin-ui/components/ProductGroupForm.tsx new file mode 100644 index 0000000..5bc2fe7 --- /dev/null +++ b/apps/admin-ui/components/ProductGroupForm.tsx @@ -0,0 +1,151 @@ +import React from 'react'; +import { View, TouchableOpacity, Alert, ScrollView } from 'react-native'; +import { useFormik } from 'formik'; +import { MyText, tw, MyTextInput, MyTouchableOpacity, theme, BottomDropdown } from 'common-ui'; +import { trpc } from '../src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +interface ProductGroup { + id: number; + groupName: string; + description: string | null; + createdAt: string; + products: any[]; + productCount: number; +} + +interface ProductGroupFormProps { + group?: ProductGroup | null; + onClose: () => void; + onSuccess: () => void; +} + +const ProductGroupForm: React.FC = ({ + group, + onClose, + onSuccess, +}) => { + // Fetch products + const { data: productsData } = trpc.common.product.getAllProductsSummary.useQuery({}); + + const createGroup = trpc.admin.product.createGroup.useMutation(); + const updateGroup = trpc.admin.product.updateGroup.useMutation(); + + const isEditing = !!group; + + const products = productsData?.products || []; + + const productOptions = products.map(product => ({ + label: `${product.name}${product.shortDescription ? ` - ${product.shortDescription}` : ''}`, + value: product.id, + })); + + const formik = useFormik({ + initialValues: { + group_name: group?.groupName || '', + description: group?.description || '', + product_ids: group?.products?.map(p => p.id) || [], + }, + validate: (values) => { + const errors: {[key: string]: string} = {}; + + if (!values.group_name.trim()) { + errors.group_name = 'Group name is required'; + } + + return errors; + }, + onSubmit: async (values) => { + try { + if (isEditing) { + await updateGroup.mutateAsync({ + id: group.id, + group_name: values.group_name, + description: values.description, + product_ids: values.product_ids, + }); + } else { + await createGroup.mutateAsync({ + group_name: values.group_name, + description: values.description, + product_ids: values.product_ids, + }); + } + onSuccess(); + } catch (error: any) { + Alert.alert('Error', error.message || 'Failed to save group'); + } + }, + }); + + return ( + + {/* Header */} + + + {isEditing ? 'Edit Product Group' : 'Create Product Group'} + + + + + + + + {/* Group Name */} + formik.setFieldValue('group_name', text)} + style={{ marginBottom: 16 }} + /> + {formik.errors.group_name && ( + {formik.errors.group_name} + )} + + {/* Description */} + formik.setFieldValue('description', text)} + style={{ marginBottom: 16 }} + /> + + {/* Products Selection */} + formik.setFieldValue('product_ids', value as number[])} + multiple={true} + placeholder="Select products" + style={{ marginBottom: 16 }} + /> + + {/* Actions */} + + + Cancel + + formik.handleSubmit()} + disabled={createGroup.isPending || updateGroup.isPending} + style={tw`flex-1 bg-brand600 rounded-lg py-4 items-center`} + > + + {createGroup.isPending || updateGroup.isPending ? 'Saving...' : 'Save'} + + + + + + ); +}; + +export default ProductGroupForm; \ No newline at end of file diff --git a/apps/admin-ui/components/SlotForm.tsx b/apps/admin-ui/components/SlotForm.tsx new file mode 100644 index 0000000..9894084 --- /dev/null +++ b/apps/admin-ui/components/SlotForm.tsx @@ -0,0 +1,285 @@ +import React, { useState, useEffect, useMemo } from 'react'; +import { View, Text, TouchableOpacity, Alert } from 'react-native'; +import { Formik, FieldArray } from 'formik'; +import DateTimePickerMod from 'common-ui/src/components/date-time-picker'; +import { tw, MyTextInput } from 'common-ui'; +import { trpc } from '../src/trpc-client'; +import BottomDropdown, { DropdownOption } from 'common-ui/src/components/bottom-dropdown'; + +interface VendorSnippet { + name: string; + groupIds: number[]; + productIds: number[]; + validTill?: string; +} + +interface SlotFormProps { + onSlotAdded?: () => void; + initialDeliveryTime?: Date | null; + initialFreezeTime?: Date | null; + initialIsActive?: boolean; + slotId?: number; + initialProductIds?: number[]; +} + +export default function SlotForm({ + onSlotAdded, + initialDeliveryTime, + initialFreezeTime, + initialIsActive = true, + slotId, + initialProductIds = [], +}: SlotFormProps) { + const initialValues = { + deliveryTime: initialDeliveryTime || null, + freezeTime: initialFreezeTime || null, + selectedGroupIds: [] as number[], + selectedProductIds: initialProductIds, + vendorSnippetList: [] as VendorSnippet[], + }; + + const { mutate: createSlot, isPending: isCreating } = trpc.admin.slots.createSlot.useMutation(); + const { mutate: updateSlot, isPending: isUpdating } = trpc.admin.slots.updateSlot.useMutation(); + + const isEditMode = !!slotId; + const isPending = isCreating || isUpdating; + + // Fetch products and groups + const { data: productsData } = trpc.common.product.getAllProductsSummary.useQuery({}); + const { data: groupsData } = trpc.admin.product.getGroups.useQuery(); + const products = productsData?.products || []; + + + + + + + + const handleFormSubmit = (values: typeof initialValues) => { + if (!values.deliveryTime || !values.freezeTime) { + Alert.alert('Error', 'Please fill all fields'); + return; + } + + const slotData = { + deliveryTime: values.deliveryTime.toISOString(), + freezeTime: values.freezeTime.toISOString(), + isActive: initialIsActive, + productIds: values.selectedProductIds, + vendorSnippets: values.vendorSnippetList.map(snippet => ({ + name: snippet.name, + productIds: snippet.productIds, + validTill: snippet.validTill, + })), + }; + + console.log({snippetList: values.vendorSnippetList}) + + values.vendorSnippetList.forEach((snippet, index) => { + console.log({snippet}) + + }); + + + if (isEditMode && slotId) { + updateSlot( + { id: slotId, ...slotData }, + { + onSuccess: () => { + Alert.alert('Success', 'Slot updated successfully!'); + onSlotAdded?.(); + }, + onError: (error: any) => { + console.log({msg: JSON.stringify(error.message)}) + + Alert.alert('Error', error.message || 'Failed to update slot'); + }, + } + ); + } else { + createSlot( + slotData, + { + onSuccess: () => { + Alert.alert('Success', 'Slot created successfully!'); + // Reset form + // Formik will handle reset + onSlotAdded?.(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to create slot'); + }, + } + ); + } + }; + + return ( + + {({ handleSubmit, values, setFieldValue }) => { + // Collect all product IDs from selected groups + const allGroupProductIds = (values?.selectedGroupIds || []).flatMap(groupId => { + const group = (groupsData?.groups || []).find(g => g.id === groupId); + return group?.products.map(p => p.id) || []; + }); + // Remove duplicates + const groupProductIds = [...new Set(allGroupProductIds)]; + + const productOptions: DropdownOption[] = products.map(product => ({ + label: `${product.name}${groupProductIds.includes(product.id) ? ' (from group)' : ''}`, + value: product.id.toString(), + disabled: groupProductIds.includes(product.id), + })); + + const groupOptions: DropdownOption[] = (groupsData?.groups || []).map(group => ({ + label: group.groupName, + value: group.id.toString(), + })); + + return ( + + + {isEditMode ? 'Edit Slot' : 'Create New Slot'} + + + + Delivery Date & Time + setFieldValue('deliveryTime', value)} /> + + + + Freeze Date & Time + setFieldValue('freezeTime', value)} /> + + + + Select Product Groups (Optional) + id.toString())} + onValueChange={(value) => { + const selectedValues = Array.isArray(value) ? value : typeof value === 'string' ? [value] : []; + const groupIds = selectedValues.map(v => parseInt(v as string)); + setFieldValue('selectedGroupIds', groupIds); + + // Collect all products from selected groups + const allGroupProducts = groupIds.flatMap(groupId => { + const group = (groupsData?.groups || []).find(g => g.id === groupId); + return group?.products.map(p => p.id) || []; + }); + // Remove duplicates + const uniqueProducts = [...new Set(allGroupProducts)]; + setFieldValue('selectedProductIds', uniqueProducts); + }} + placeholder="Select product groups" + multiple={true} + /> + + + + Select Products (Optional) + id.toString())} + onValueChange={(value) => { + const selectedValues = Array.isArray(value) ? value : typeof value === 'string' ? [value] : []; + setFieldValue('selectedProductIds', selectedValues.map(v => Number(v))); + }} + placeholder="Select products for this slot" + multiple={true} + /> + + + {/* Vendor Snippets */} + + {({ push, remove }) => ( + + Vendor Snippets + {values.vendorSnippetList.map((snippet, index) => ( + + + setFieldValue(`vendorSnippetList.${index}.name`, text)} + /> + + + + + values.selectedGroupIds.includes(Number(option.value)) + )} + value={snippet.groupIds?.map(id => id.toString()) || []} + onValueChange={(value) => { + const selectedValues = Array.isArray(value) ? value : [value]; + const selectedGroupIds = selectedValues.map(v => parseInt(v as string)); + setFieldValue(`vendorSnippetList.${index}.groupIds`, selectedGroupIds); + + // Auto-populate products from selected groups + const allSnippetProducts = selectedGroupIds.flatMap(groupId => { + const group = (groupsData?.groups || []).find(g => g.id === groupId); + return group?.products.map(p => p.id) || []; + }); + // Remove duplicates + const uniqueSnippetProducts = [...new Set(allSnippetProducts)]; + setFieldValue(`vendorSnippetList.${index}.productIds`, uniqueSnippetProducts); + }} + placeholder="Select groups for snippet" + multiple={true} + /> + + + + values.selectedProductIds.includes(Number(option.value)) + )} + value={snippet.productIds?.map(id => id.toString()) || []} + onValueChange={(value) => { + const selectedValues = Array.isArray(value) ? value : [value]; + setFieldValue(`vendorSnippetList.${index}.productIds`, selectedValues.map(v => parseInt(v as string))); + }} + placeholder="Select products for snippet" + multiple={true} + /> + + remove(index)} + style={tw`bg-red-500 px-4 py-2 rounded-lg self-end`} + > + Remove Snippet + + + ))} + push({ name: '', groupIds: [], productIds: [], validTill: '' })} + style={tw`bg-blue-500 px-4 py-3 rounded-lg items-center`} + > + Add Vendor Snippet + + + )} + + + handleSubmit()} + disabled={isPending} + style={tw`${isPending ? 'bg-pink2' : 'bg-pink1'} p-3 rounded-lg items-center mt-6 pb-4`} + > + + {isPending ? (isEditMode ? 'Updating...' : 'Creating...') : (isEditMode ? 'Update Slot' : 'Create Slot')} + + + + )}} + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/components/SnippetMenu.tsx b/apps/admin-ui/components/SnippetMenu.tsx new file mode 100644 index 0000000..6c90367 --- /dev/null +++ b/apps/admin-ui/components/SnippetMenu.tsx @@ -0,0 +1,145 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity, Alert, Clipboard } from 'react-native'; +import { Entypo } from '@expo/vector-icons'; +import { MyText, tw, BottomDialog } from 'common-ui'; +import { SuccessToast } from '../services/toaster'; + +export interface SnippetMenuOption { + title: string; + icon: keyof typeof Entypo.glyphMap; + onPress: () => void; + disabled?: boolean; +} + +export interface SnippetMenuProps { + snippet: { + id: number; + snippetCode: string; + accessUrl: string; + }; + onEdit: (snippet: any) => void; + onDelete: (id: number) => void; + onViewOrders: (snippetCode: string) => void; + triggerStyle?: any; + iconSize?: number; + iconColor?: string; +} + +export const SnippetMenu: React.FC = ({ + snippet, + onEdit, + onDelete, + onViewOrders, + triggerStyle = tw`p-2 rounded-full bg-gray-50`, + iconSize = 16, + iconColor = '#6B7280', +}) => { + const [isOpen, setIsOpen] = useState(false); + + const handleOpenMenu = () => { + setIsOpen(true); + }; + + const handleCloseMenu = () => { + setIsOpen(false); + }; + + const handleViewOrders = () => { + setIsOpen(false); + onViewOrders(snippet.snippetCode); + }; + + const handleEdit = () => { + setIsOpen(false); + onEdit(snippet); + }; + + const handleDelete = () => { + setIsOpen(false); + Alert.alert( + 'Delete Snippet', + 'Are you sure you want to delete this vendor snippet?', + [ + { text: 'Cancel', style: 'cancel' }, + { + text: 'Delete', + style: 'destructive', + onPress: () => onDelete(snippet.id), + }, + ] + ); + }; + + const handleCopyUrl = async () => { + setIsOpen(false); + await Clipboard.setString(snippet.accessUrl); + SuccessToast('URL copied to clipboard'); + }; + + const options: SnippetMenuOption[] = [ + { + title: 'View Orders', + icon: 'eye', + onPress: handleViewOrders, + }, + { + title: 'Edit', + icon: 'edit', + onPress: handleEdit, + }, + { + title: 'Copy URL', + icon: 'link', + onPress: handleCopyUrl, + }, + { + title: 'Delete', + icon: 'trash', + onPress: handleDelete, + }, + ]; + + const handleOptionPress = (option: SnippetMenuOption) => { + if (option.disabled) return; + option.onPress(); + }; + + return ( + <> + {/* Menu Trigger */} + + + + + {/* Menu Dialog */} + + + + Snippet Options + + + {options.map((option, index) => ( + handleOptionPress(option)} + disabled={option.disabled} + > + + + {option.title} + + + ))} + + + + ); +}; \ No newline at end of file diff --git a/apps/admin-ui/components/SnippetOrdersView.tsx b/apps/admin-ui/components/SnippetOrdersView.tsx new file mode 100644 index 0000000..f48b6ef --- /dev/null +++ b/apps/admin-ui/components/SnippetOrdersView.tsx @@ -0,0 +1,158 @@ +import React from 'react'; +import { View, ScrollView, TouchableOpacity } from 'react-native'; +import { MyText, tw, AppContainer } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +interface OrderProduct { + productId: number; + productName: string; + quantity: number; + price: number; + unit: string; + subtotal: number; +} + +interface SnippetOrder { + orderId: string; + orderDate: string; + customerName: string; + totalAmount: string; + slotInfo: { + time: string; + sequence: any[]; + } | null; + products: OrderProduct[]; + matchedProducts: number[]; + snippetCode: string; +} + +interface SnippetOrdersViewProps { + orders: SnippetOrder[]; + snippetCode: string; + onClose: () => void; +} + +const OrderCard: React.FC<{ order: SnippetOrder; index: number }> = ({ order, index }) => { + const orderDate = new Date(order.orderDate); + const slotTime = order.slotInfo ? new Date(order.slotInfo.time) : null; + + return ( + + {/* Order Header */} + + + {order.orderId} + {order.customerName} + + + ₹{order.totalAmount} + + {orderDate.toLocaleDateString()} + + + + + {/* Slot Info */} + {slotTime && ( + + + Delivery: {slotTime.toLocaleString()} + + + )} + + {/* Products */} + + Products: + {order.products.map((product, index) => { + const isMatched = order.matchedProducts.includes(product.productId); + return ( + + + + {product.productName} + {isMatched && ' ⭐'} + + + {product.quantity} {product.unit} × ₹{product.price} + + + + ₹{product.subtotal.toFixed(2)} + + + ); + })} + + + {/* Matched Products Summary */} + + + Matched {order.matchedProducts.length} product(s) from snippet "{order.snippetCode}" + + + + ); +}; + +const SnippetOrdersView: React.FC = ({ + orders, + snippetCode, + onClose, +}) => { + const totalOrders = orders.length; + const totalRevenue = orders.reduce((sum, order) => sum + parseFloat(order.totalAmount), 0); + + return ( + + + {/* Header */} + + + + Orders for "{snippetCode}" + + {totalOrders} order{totalOrders !== 1 ? 's' : ''} • Total: ₹{totalRevenue.toFixed(2)} + + + + + + + + + {/* Orders List */} + + {orders.length === 0 ? ( + + + No matching orders + + No orders found that match this snippet's criteria + + + ) : ( + + {orders.map((order, index) => ( + + + {index < orders.length - 1 && ( + + )} + + ))} + + )} + + + + ); +}; + +export default SnippetOrdersView; \ No newline at end of file diff --git a/apps/admin-ui/components/StoreForm.tsx b/apps/admin-ui/components/StoreForm.tsx new file mode 100644 index 0000000..03b8eb6 --- /dev/null +++ b/apps/admin-ui/components/StoreForm.tsx @@ -0,0 +1,226 @@ +import React, { forwardRef, useState, useEffect, useMemo } from 'react'; +import { View, TouchableOpacity, Alert } from 'react-native'; +import { Formik } from 'formik'; +import * as Yup from 'yup'; +import { MyTextInput, BottomDropdown, MyText, tw, ImageUploader } from 'common-ui'; +import { trpc } from '../src/trpc-client'; +import usePickImage from 'common-ui/src/components/use-pick-image'; + +export interface StoreFormData { + name: string; + description: string; + imageUrl?: string; + owner: number; + products: number[]; +} + +export interface StoreFormRef { + // Add methods if needed +} + +interface StoreFormProps { + mode: 'create' | 'edit'; + initialValues: StoreFormData; + onSubmit: (values: StoreFormData) => void; + isLoading: boolean; + storeId?: number; +} + +const validationSchema = Yup.object().shape({ + name: Yup.string().required('Name is required'), + description: Yup.string(), + imageUrl: Yup.string(), + owner: Yup.number().required('Owner is required'), + products: Yup.array().of(Yup.number()), +}); + +const StoreForm = forwardRef((props, ref) => { + const { mode, initialValues, onSubmit, isLoading, storeId } = props; + const { data: staffData } = trpc.admin.staffUser.getStaff.useQuery(); + const { data: productsData } = trpc.admin.product.getProducts.useQuery(); + + const [formInitialValues, setFormInitialValues] = useState(initialValues); + const [selectedImages, setSelectedImages] = useState<{ blob: Blob; mimeType: string }[]>([]); + const [displayImages, setDisplayImages] = useState<{ uri?: string }[]>([]); + + // For edit mode, pre-select products belonging to this store + const initialSelectedProducts = useMemo(() => { + if (mode !== 'edit' || !productsData?.products) return []; + return productsData.products + .filter(p => p.storeId === storeId) + .map(p => p.id); + }, [mode, productsData?.products, storeId]); + + useEffect(() => { + setFormInitialValues({ + ...initialValues, + products: initialSelectedProducts, + }); + }, [initialValues, initialSelectedProducts]); + + const staffOptions = staffData?.staff.map(staff => ({ + label: staff.name, + value: staff.id, + })) || []; + + const productOptions = productsData?.products.map(product => ({ + label: `${product.name} - ₹${product.price}`, + value: product.id, + disabled: product.storeId !== null && product.storeId !== storeId, // Disable if belongs to another store + })) || []; + + const generateUploadUrls = trpc.common.generateUploadUrls.useMutation(); + + const handleImagePick = usePickImage({ + setFile: async (assets: any) => { + if (!assets || (Array.isArray(assets) && assets.length === 0)) { + setSelectedImages([]); + setDisplayImages([]); + return; + } + + const files = Array.isArray(assets) ? assets : [assets]; + const blobPromises = files.map(async (asset) => { + const response = await fetch(asset.uri); + const blob = await response.blob(); + return { blob, mimeType: asset.mimeType || 'image/jpeg' }; + }); + + const blobArray = await Promise.all(blobPromises); + setSelectedImages(blobArray); + setDisplayImages(files.map(asset => ({ uri: asset.uri }))); + }, + multiple: false, // Single image for stores + }); + + const handleRemoveImage = (uri: string) => { + const index = displayImages.findIndex(img => img.uri === uri); + if (index !== -1) { + const newDisplay = displayImages.filter((_, i) => i !== index); + const newFiles = selectedImages.filter((_, i) => i !== index); + setDisplayImages(newDisplay); + setSelectedImages(newFiles); + } + }; + + return ( + + {({ handleChange, handleSubmit, values, setFieldValue, errors, touched }) => { + const submit = async () => { + try { + let imageUrl: string | undefined; + + if (selectedImages.length > 0) { + // Generate upload URLs + const mimeTypes = selectedImages.map(s => s.mimeType); + const { uploadUrls } = await generateUploadUrls.mutateAsync({ + contextString: 'store', + mimeTypes, + }); + + // Upload images + for (let i = 0; i < uploadUrls.length; i++) { + const uploadUrl = uploadUrls[i]; + const { blob, mimeType } = selectedImages[i]; + + const uploadResponse = await fetch(uploadUrl, { + method: 'PUT', + body: blob, + headers: { + 'Content-Type': mimeType, + }, + }); + + if (!uploadResponse.ok) { + throw new Error(`Upload failed with status ${uploadResponse.status}`); + } + } + + // Extract key from first upload URL + // const u = new URL(uploadUrls[0]); + // const rawKey = u.pathname.replace(/^\/+/, ""); + // imageUrl = decodeURIComponent(rawKey); + imageUrl = uploadUrls[0]; + } + + // Submit form with imageUrl + onSubmit({ ...values, imageUrl }); + } catch (error) { + console.error('Upload error:', error); + Alert.alert('Error', 'Failed to upload image'); + } + }; + + return ( + + + + setFieldValue('owner', value)} + placeholder="Select owner" + error={!!(touched.owner && errors.owner)} + style={{ marginBottom: 16 }} + /> + setFieldValue('products', value)} + placeholder="Select products" + multiple + style={{ marginBottom: 16 }} + /> + + Store Image + setFormInitialValues({ ...formInitialValues, imageUrl: undefined })} + allowMultiple={false} + /> + + + + {generateUploadUrls.isPending ? 'Uploading...' : isLoading ? (mode === 'create' ? 'Creating...' : 'Updating...') : (mode === 'create' ? 'Create Store' : 'Update Store')} + + + + ); + }} + + ); +}); + +StoreForm.displayName = 'StoreForm'; + +export default StoreForm; \ No newline at end of file diff --git a/apps/admin-ui/components/TabNavigation.tsx b/apps/admin-ui/components/TabNavigation.tsx new file mode 100755 index 0000000..02ec64c --- /dev/null +++ b/apps/admin-ui/components/TabNavigation.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { View, TouchableOpacity } from 'react-native'; +import { MyText , tw } from "common-ui"; + +interface TabNavigationProps { + tabs: { key: string; title: string }[]; + activeTab: string; + onTabChange: (tabKey: string) => void; +} + +const TabNavigation: React.FC = ({ tabs, activeTab, onTabChange }) => { + return ( + + {tabs.map((tab) => ( + onTabChange(tab.key)} + > + + {tab.title} + + + ))} + + ); +}; + +export default TabNavigation; \ No newline at end of file diff --git a/apps/admin-ui/components/VendorSnippetForm.tsx b/apps/admin-ui/components/VendorSnippetForm.tsx new file mode 100644 index 0000000..cbea7b7 --- /dev/null +++ b/apps/admin-ui/components/VendorSnippetForm.tsx @@ -0,0 +1,220 @@ +import React, { useState, useEffect } from 'react'; +import { View, TouchableOpacity, Alert, ScrollView } from 'react-native'; +import { useFormik } from 'formik'; +import { MyText, tw, DatePicker, MyTextInput } from 'common-ui'; +import BottomDropdown from 'common-ui/src/components/bottom-dropdown'; +import { trpc } from '../src/trpc-client'; + + +interface VendorSnippet { + id: number; + snippetCode: string; + slotId: number; + productIds: number[]; + validTill: string | null; + createdAt: string; +} + +interface VendorSnippetFormProps { + snippet?: VendorSnippet | null; + onClose: () => void; + onSuccess: () => void; +} + +const VendorSnippetForm: React.FC = ({ + snippet, + onClose, + onSuccess, +}) => { + + // Fetch slots and products + const { data: slotsData } = trpc.user.slots.getSlots.useQuery(); + const { data: productsData } = trpc.common.product.getAllProductsSummary.useQuery({}); + + const createSnippet = trpc.admin.vendorSnippets.create.useMutation(); + const updateSnippet = trpc.admin.vendorSnippets.update.useMutation(); + + const isEditing = !!snippet; + + const formik = useFormik({ + initialValues: { + snippetCode: snippet?.snippetCode || '', + slotId: snippet?.slotId?.toString() || '', + productIds: snippet?.productIds?.map(id => id.toString()) || [], + validTill: snippet?.validTill ? new Date(snippet.validTill) : null, + }, + validate: (values) => { + const errors: {[key: string]: string} = {}; + + if (!values.snippetCode.trim()) { + errors.snippetCode = 'Snippet code is required'; + } + + if (!values.slotId) { + errors.slotId = 'Slot selection is required'; + } + + if (values.productIds.length === 0) { + errors.productIds = 'At least one product must be selected'; + } + + return errors; + }, + onSubmit: async (values) => { + try { + const submitData = { + snippetCode: values.snippetCode, + slotId: parseInt(values.slotId), + productIds: values.productIds.map(id => parseInt(id)), + validTill: values.validTill?.toISOString(), + }; + + if (isEditing && snippet) { + await updateSnippet.mutateAsync({ + id: snippet.id, + updates: submitData, + }); + Alert.alert('Success', 'Vendor snippet updated successfully'); + } else { + await createSnippet.mutateAsync(submitData); + Alert.alert('Success', 'Vendor snippet created successfully'); + } + + onSuccess(); + onClose(); + } catch (error: any) { + Alert.alert('Error', error.message || 'Failed to save vendor snippet'); + } + }, + }); + + // Generate unique snippet code if creating new (only on mount) + useEffect(() => { + if (!isEditing && !formik.values.snippetCode) { + const timestamp = Date.now(); + const random = Math.random().toString(36).substring(2, 8); + formik.setFieldValue('snippetCode', `VS_${timestamp}_${random}`.toUpperCase()); + } + }, [isEditing]); // Removed formik.values.snippetCode from deps + + + + const slotOptions = slotsData?.slots.map(slot => ({ + label: new Date(slot.deliveryTime).toLocaleString(), + value: slot.id.toString(), + })) || []; + + const productOptions = productsData?.products.map(product => ({ + label: `${product.name} (${product.unit})`, + value: product.id.toString(), + })) || []; + + const selectedProductLabels = formik.values.productIds + .map(id => productOptions.find(opt => opt.value === id)?.label) + .filter(Boolean) + .join(', '); + + return ( + + + + + {isEditing ? 'Edit Vendor Snippet' : 'Create Vendor Snippet'} + + + + + + + + + + {/* Snippet Code */} + + + {formik.errors.snippetCode && formik.touched.snippetCode && ( + {formik.errors.snippetCode} + )} + + + {/* Slot Selection */} + + Delivery Slot + formik.setFieldValue('slotId', value)} + placeholder="Choose a delivery slot" + /> + {formik.errors.slotId && formik.touched.slotId && ( + {formik.errors.slotId} + )} + + + {/* Product Selection */} + + Products + formik.setFieldValue('productIds', values)} + multiple={true} + placeholder="Select products" + /> + {formik.values.productIds.length > 0 && ( + + Selected: {selectedProductLabels} + + )} + {formik.errors.productIds && formik.touched.productIds && ( + {formik.errors.productIds} + )} + + + {/* Valid Till Date */} + + Valid Till (Optional) + formik.setFieldValue('validTill', date)} + placeholder="Select expiry date" + showLabel={false} + /> + + Leave empty for no expiry + + + + + + {/* Submit Button */} + + formik.handleSubmit()} + disabled={formik.isSubmitting} + style={tw`bg-blue-500 py-3 rounded-lg ${formik.isSubmitting ? 'opacity-50' : ''}`} + > + + {formik.isSubmitting + ? 'Saving...' + : isEditing ? 'Update Snippet' : 'Create Snippet' + } + + + + + ); +}; + +export default VendorSnippetForm; \ No newline at end of file diff --git a/apps/admin-ui/components/app-container.tsx b/apps/admin-ui/components/app-container.tsx new file mode 100755 index 0000000..50e2b54 --- /dev/null +++ b/apps/admin-ui/components/app-container.tsx @@ -0,0 +1,3 @@ +import { AppContainer } from "common-ui"; + +export default AppContainer; \ No newline at end of file diff --git a/apps/admin-ui/components/context/auth-context.tsx b/apps/admin-ui/components/context/auth-context.tsx new file mode 100755 index 0000000..ed365b9 --- /dev/null +++ b/apps/admin-ui/components/context/auth-context.tsx @@ -0,0 +1,270 @@ +// import React, { +// createContext, +// useContext, +// useEffect, +// useState, +// ReactNode, +// } from "react"; +// import { +// getJWT, +// deleteJWT, +// getRoles, +// saveJWT, +// saveRoles, +// saveUserId, +// getUserId, +// } from "../../hooks/useJWT"; +// import { useFocusEffect, usePathname, useRouter } from "expo-router"; +// import queryClient from "@/utils/queryClient"; +// import { DeviceEventEmitter } from "react-native"; +// import { FORCE_LOGOUT_EVENT, SESSION_EXPIRED_MSG } from "common-ui/src/lib/const-strs"; +// import { useLogin, useLogout } from "@/api-hooks/auth.api"; +// import { +// useUserResponsibilities, +// UserResponsibilities, +// } from "@/api-hooks/user.api"; +// import { InfoToast, SuccessToast } from "@/services/toaster"; +// import { useNotification } from "@/services/notif-service/notif-context"; + +// interface LoginFormInputs { +// login: string; +// password: string; +// useUsername?: boolean; +// expoPushToken?: string | null; +// } + +// interface AuthContextType { +// isLoggedIn: boolean; +// setIsLoggedIn: (value: boolean) => void; +// logout: ({ +// isSessionExpired, +// }: { +// isSessionExpired?: boolean; +// }) => Promise; +// responsibilities: UserResponsibilities | null; +// responsibilitiesLoading: boolean; +// responsibilitiesError: Error | null; +// roles: string[] | null; +// setRoles: (roles: string[] | null) => void; +// refreshRoles: () => Promise; +// loginFunc: (payload: LoginFormInputs) => Promise; +// userId: number | null; +// isLoggingIn: boolean; +// loginError?: string; +// } + +// const defaultResponsibilities: UserResponsibilities = { +// hospitalAdminFor: null, +// secretaryFor: [], +// }; + +// export const AuthContext = createContext( +// undefined +// ); + +// export const AuthProvider = ({ children }: { children: ReactNode }) => { +// const { mutate: loginApi, isPending: isLoggingIn, error: loginError } = useLogin(); +// const [isLoggedIn, setIsLoggedIn] = useState(false); +// const [roles, setRoles] = useState(null); +// const [userId, setUserId] = useState(null); + +// const refreshRoles = async () => { +// const r = await getRoles(); +// setRoles(r); +// }; + + + +// useEffect(() => { +// refreshRoles(); +// }, []); +// const { mutate: logoutApi } = useLogout(); +// const router = useRouter(); +// const [responsibilitiesError, setResponsibilitiesError] = +// useState(null); + +// const { +// data: responsibilities, +// isLoading: responsibilitiesLoading, +// isFetching: responsibilitiesFetching, +// refetch: refetchResponsibilities, +// error: queryError, +// } = useUserResponsibilities(userId); + + +// React.useEffect(() => { +// (async () => { +// const token = await getJWT(); + +// setIsLoggedIn(!!token); +// if (!token) { +// if (!pathname.includes("login")) { +// router.replace("/login" as any); +// } +// } else { +// refetchResponsibilities(); +// router.replace("/(drawer)/dashboard"); +// const userId = await getUserId(); +// setUserId(userId ? parseInt(userId) : null); +// } +// })(); +// }, []); + +// const pathname = usePathname(); + + +// const logout = async ({ +// isSessionExpired, +// }: { +// isSessionExpired?: boolean; +// }) => { + +// const pageConditon = +// pathname.includes("/login") || +// pathname.includes("/signup") || +// pathname === "/"; + +// if (!isSessionExpired) { +// logoutApi({} as any, { +// onSuccess: () => {}, +// onSettled: () => { + +// if (!pageConditon) { +// router.replace({ +// pathname: "/login" as any, +// params: isSessionExpired ? { message: SESSION_EXPIRED_MSG } : {}, +// }); +// } +// deleteJWT(); +// }, +// }); +// setIsLoggedIn(false); +// } else { +// deleteJWT(); +// setIsLoggedIn(false); +// InfoToast("Session expired. Please log in again."); +// if (!pageConditon) { +// router.replace({ +// pathname: "/login" as any, +// params: { message: SESSION_EXPIRED_MSG }, +// }); +// } +// } +// queryClient.clear(); +// }; + +// const loginFunc = async (data: LoginFormInputs) => { +// loginApi(data, { +// onSuccess: async (result) => { + +// // refetchUserId(); +// // await refetchUserData(); + +// await saveUserId(result.user.id.toString()); +// setUserId(result.user.id); + +// await saveJWT(result.token); + +// // Update login state in auth context +// setIsLoggedIn(true); + +// // Handle roles if available +// if (result.user.roles) { +// await saveRoles(result.user.roles); +// await refreshRoles(); +// } +// await refetchResponsibilities(); + +// // Clear the 'message' search param from the URL after login +// router.replace({ +// pathname: "/(drawer)/dashboard", +// params: {}, +// }); +// }, +// onError: (e: any) => { +// // setError("login", { +// // type: "manual", +// // message: e.message || "Login failed", +// // }); +// }, +// }); +// }; + +// React.useEffect(() => { +// const subscription = DeviceEventEmitter.addListener( +// FORCE_LOGOUT_EVENT, +// () => { +// logout({ isSessionExpired: true }); +// } +// ); + +// return () => { +// subscription.remove(); +// }; +// }, []); + + +// return ( +// +// {children} +// +// ); +// }; + +// export const useAuth = () => { +// const context = useContext(AuthContext); +// if (!context) { +// throw new Error("useAuth must be used within an AuthProvider"); +// } +// return context; +// }; + +// /** +// * Hook to check if the current user is a hospital admin +// * @param hospitalId Hospital ID to check against +// * @returns Boolean indicating if user is admin for that hospital +// */ +// export const useIsHospitalAdmin = (hospitalId?: number | string): boolean => { +// const { responsibilities } = useAuth(); + +// // If no hospitalId provided, return false +// if (hospitalId === undefined) { +// return false; +// } + +// // Check if user is admin for the specified hospital +// return responsibilities?.hospitalAdminFor === hospitalId; +// }; + +// /** +// * Hook to check if the current user is a secretary for a specific doctor +// * @param doctorId Doctor ID to check against +// * @returns Boolean indicating if user is a secretary for that doctor +// */ +// export const useIsDoctorSecretary = (doctorId?: number): boolean => { +// const { responsibilities } = useAuth(); + +// // If no doctorId provided, return false +// if (doctorId === undefined) { +// return false; +// } + +// // Check if user is a secretary for the specified doctor +// return responsibilities?.secretaryFor?.includes(doctorId) || false; +// }; diff --git a/apps/admin-ui/components/context/roles-context.tsx b/apps/admin-ui/components/context/roles-context.tsx new file mode 100755 index 0000000..e8936d5 --- /dev/null +++ b/apps/admin-ui/components/context/roles-context.tsx @@ -0,0 +1,43 @@ +import React, { createContext, useContext, useEffect, useState, ReactNode } from "react"; +import { AuthContext } from "./auth-context"; +import { ROLE_NAMES } from "common-ui"; +// import { getRoles, saveRoles, deleteRoles } from "../../hooks/useJWT"; +// import { ROLE_NAMES } from "../../lib/constants"; + +// interface RolesContextType { +// roles: string[] | null; +// setRoles: (roles: string[] | null) => void; +// refreshRoles: () => Promise; +// } + +// const RolesContext = createContext(undefined); + +// export const RolesProvider = ({ children }: { children: ReactNode }) => { +// const [roles, setRoles] = useState(null); + +// const refreshRoles = async () => { +// const r = await getRoles(); +// setRoles(r); +// }; + +// useEffect(() => { +// refreshRoles(); +// }, []); + +// return ( +// +// {children} +// +// ); +// }; + +export const useRoles = () => { + const ctx = useContext(AuthContext); + if (!ctx) throw new Error("useRoles must be used within a RolesProvider"); + return ctx.roles; +}; + +export const useIsAdmin = () => { + const roles = useRoles(); + return roles?.includes(ROLE_NAMES.ADMIN); +} diff --git a/apps/admin-ui/components/context/staff-auth-context.tsx b/apps/admin-ui/components/context/staff-auth-context.tsx new file mode 100644 index 0000000..fc14804 --- /dev/null +++ b/apps/admin-ui/components/context/staff-auth-context.tsx @@ -0,0 +1,116 @@ +import React, { createContext, useContext, useEffect, useState, ReactNode } from "react"; +import { useRouter, usePathname } from "expo-router"; +import queryClient from "@/utils/queryClient"; +import { DeviceEventEmitter } from "react-native"; +import { FORCE_LOGOUT_EVENT } from "common-ui/src/lib/const-strs"; +import { trpc } from "@/src/trpc-client"; +import { saveJWT, getJWT, deleteJWT } from "@/hooks/useJWT"; + +interface Staff { + id: number; + name: string; +} + +interface StaffAuthContextType { + isLoggedIn: boolean; + isLoading: boolean; + staff: Staff | null; + login: (name: string, password: string) => Promise; + logout: () => void; + isLoggingIn: boolean; + loginError: string | null; +} + +const StaffAuthContext = createContext(undefined); + +export const StaffAuthProvider = ({ children }: { children: ReactNode }) => { + const [isLoggedIn, setIsLoggedIn] = useState(false); + const [isLoading, setIsLoading] = useState(true); + const [staff, setStaff] = useState(null); + const [loginError, setLoginError] = useState(null); + + const loginMutation = trpc.admin.staffUser.login.useMutation(); + const router = useRouter(); + const pathname = usePathname(); + + useEffect(() => { + const checkAuth = async () => { + const token = await getJWT(); + if (token) { + // TODO: Optionally decode token to get staff info + setIsLoggedIn(true); + // For now, assume staff info is not needed beyond login state + } else { + setIsLoggedIn(false); + if (!pathname.includes("login")) { + router.replace("/login" as any); + } + } + setIsLoading(false); + }; + + checkAuth(); + }, []); + + const login = async (name: string, password: string) => { + setLoginError(null); + loginMutation.mutate( + { name, password }, + { + onSuccess: async (data) => { + await saveJWT(data.token); + setStaff(data.staff); + setIsLoggedIn(true); + router.replace("/(drawer)/dashboard"); + }, + onError: (error: any) => { + setLoginError(error.message || "Login failed"); + }, + } + ); + }; + + const logout = async () => { + await deleteJWT(); + setIsLoggedIn(false); + setStaff(null); + queryClient.clear(); + router.replace("/login" as any); + }; + + useEffect(() => { + const subscription = DeviceEventEmitter.addListener(FORCE_LOGOUT_EVENT, () => { + console.log('force logout event received'); + + logout(); + }); + + return () => { + subscription.remove(); + }; + }, []); + + return ( + + {children} + + ); +}; + +export const useStaffAuth = () => { + const context = useContext(StaffAuthContext); + if (!context) { + throw new Error("useStaffAuth must be used within a StaffAuthProvider"); + } + return context; +}; \ No newline at end of file diff --git a/apps/admin-ui/components/dashboard-header.tsx b/apps/admin-ui/components/dashboard-header.tsx new file mode 100755 index 0000000..000f7c4 --- /dev/null +++ b/apps/admin-ui/components/dashboard-header.tsx @@ -0,0 +1,115 @@ +import React from 'react'; +import { View, TouchableOpacity, Animated, Easing } from 'react-native'; +import { SafeAreaView } from 'react-native-safe-area-context'; +import { MyText , tw , colors } from "common-ui"; +import { Ionicons } from '@expo/vector-icons'; +import { useThemeColor } from '@/hooks/useThemeColor'; +import { IconButton } from 'react-native-paper'; + +interface DashboardHeaderProps { + onMenuPress: () => void; + onNotificationsPress: () => void; + onProfilePress: () => void; + onRefreshPress?: () => void; + refreshing?: boolean; +} + +const DashboardHeader: React.FC = ({ + onMenuPress, + onNotificationsPress, + onProfilePress, + onRefreshPress, + refreshing = false +}) => { + const accentColor = useThemeColor({ light: '#4f46e5', dark: '#818cf8' }, 'tint'); + + // For the refresh animation + const spinAnim = React.useRef(new Animated.Value(0)).current; + + // Update animation when refreshing prop changes + React.useEffect(() => { + let animation: Animated.CompositeAnimation | null = null; + + if (refreshing) { + animation = Animated.loop( + Animated.timing(spinAnim, { + toValue: 1, + duration: 1000, + easing: Easing.linear, + useNativeDriver: true, + }) + ); + animation.start(); + } else { + spinAnim.stopAnimation(); + spinAnim.setValue(0); + } + + return () => { + if (animation) { + animation.stop(); + } + }; + }, [refreshing]); + + const spin = spinAnim.interpolate({ + inputRange: [0, 1], + outputRange: ['0deg', '360deg'], + }); + + return ( + + + {/* Menu Button */} + + + + + {/* Logo/App Name */} + + HealthPetal + + + {/* Right Actions */} + + {/* Refresh Button */} + {onRefreshPress && ( + + + + )} + + {/* Notifications */} + + + {/* Notification Badge */} + + + + {/* Profile */} + + + + + + + ); +}; + +export default DashboardHeader; \ No newline at end of file diff --git a/apps/admin-ui/components/date-time-picker.tsx b/apps/admin-ui/components/date-time-picker.tsx new file mode 100755 index 0000000..ca43829 --- /dev/null +++ b/apps/admin-ui/components/date-time-picker.tsx @@ -0,0 +1,278 @@ +// import { useTheme } from "@/hooks/theme-context"; +import { MaterialCommunityIcons } from "@expo/vector-icons"; +import DateTimePicker, { + AndroidNativeProps, + DateTimePickerAndroid, + DateTimePickerEvent, +} from "@react-native-community/datetimepicker"; +import React, { useState } from "react"; +import { + Modal, + Platform, + StyleSheet, + Text, + TouchableOpacity, + View, +} from "react-native"; + +import { useTheme, MyText } from "common-ui"; + +interface Props { + value: Date | null; + setValue: (date: Date | null) => void; + showLabels?: boolean; // Optional prop to control label visibility + timeOnly?: boolean; // Optional prop to show only time picker +} + +type Mode = "date" | "time" | "datetime"; + +function DateTimePickerMod(props: Props) { + const { value, setValue, showLabels = true, timeOnly = false } = props; + const [show, setShow] = useState(false); + const [mode, setMode] = useState("date"); + + const onChange = (event: DateTimePickerEvent, selectedDate?: Date) => { + const currentDate = selectedDate || value; + if (Platform.OS === "ios") setShow(false); + setValue(currentDate); + }; + + const showMode = (currentMode: Mode) => { + if (Platform.OS === "android") { + DateTimePickerAndroid.open({ + value: value || new Date(), + onChange: onChange, + mode: currentMode, + is24Hour: true, + display: "default", + } as AndroidNativeProps); + } else { + setShow(true); + setMode(currentMode); + } + }; + const showDatepicker = () => { + showMode("date"); + }; + + const showTimepicker = () => { + showMode("time"); + }; + const { theme } = useTheme(); + + return ( + + {timeOnly ? ( + + {showLabels && Select Time} + + + {value?.toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + }) || "Select Time"} + + + + + ) : ( + + + {showLabels && Select Date} + + {value?.toLocaleDateString() || "Select Date"} + + + + + + {showLabels && Select Time} + + + {value?.toLocaleTimeString([], { + hour: "2-digit", + minute: "2-digit", + }) || "Select Time"} + + + + + + )} + {/* Conditional rendering for iOS, as it uses the declarative API */} + {show && Platform.OS === "ios" && ( + setShow(false)} + > + + + + setShow(false)} + style={styles.doneButton} + > + Done + + + + + )} + + ); +} + +export default DateTimePickerMod; + +const styles = StyleSheet.create({ + container: { + // flex: 1, // Remove flex to avoid taking up extra space + justifyContent: "center", + alignItems: "flex-start", + padding: 0, // Reduce padding for compactness + marginBottom: 16, // Add margin for spacing in forms + }, + iconRow: { + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + marginBottom: 20, + }, + iconRowSingleLine: { + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + marginBottom: 0, + }, + iconNoBg: { + backgroundColor: "transparent", + borderRadius: 0, + padding: 0, + elevation: 0, + }, + spacerHorizontal: { + width: 30, + }, + spacerHorizontalSmall: { + width: 8, + }, + spacer: { + height: 20, // Add some space between buttons + }, + selectedText: { + marginTop: 30, + fontSize: 18, + fontWeight: "bold", + textAlign: "center", + }, + timeTextContainer: { + justifyContent: "center", + alignItems: "center", + }, + timeText: { + fontSize: 15, + fontWeight: "500", + color: "#333", + marginLeft: 2, + }, + dateText: { + fontSize: 15, + fontWeight: "500", + color: "#333", + marginLeft: 2, + marginRight: 2, + }, + + modalOverlay: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "rgba(0, 0, 0, 0.5)", + }, + pickerContainer: { + width: "80%", + backgroundColor: "white", + borderRadius: 10, + padding: 20, + elevation: 5, + }, + doneButton: { + marginTop: 10, + backgroundColor: "#007bff", + borderRadius: 5, + padding: 10, + alignItems: "center", + }, + doneButtonText: { + color: "white", + fontWeight: "bold", + }, +}); diff --git a/apps/admin-ui/components/day-account-view.tsx b/apps/admin-ui/components/day-account-view.tsx new file mode 100755 index 0000000..686d9e7 --- /dev/null +++ b/apps/admin-ui/components/day-account-view.tsx @@ -0,0 +1,77 @@ +import React from 'react'; +import { View } from 'react-native'; +import { MyText , tw } from "common-ui"; +import { Ionicons } from '@expo/vector-icons'; + +// Define the types +export interface DoctorWiseCount { + doctorName: string; + doctorId: number; + fee: number; + issuedTokens: number; + totalAmount: number; +} + +export interface DayAccountData { + doctorWiseCount: DoctorWiseCount[]; + date: string; + totalAmount: number; + settled: boolean; +} + +interface DayAccountViewProps { + dayData: DayAccountData; +} + +const DayAccountView: React.FC = ({ dayData }) => { + return ( + + + + {dayData.date} + + + + ₹{dayData.totalAmount} + + {dayData.settled ? ( + + + Settled + + ) : ( + + + Pending + + )} + + + + + {dayData.doctorWiseCount.map((doctor, idx) => ( + + + + {doctor.doctorName} + + + ₹{doctor.fee} × {doctor.issuedTokens} tokens + + + + ₹{doctor.totalAmount} + + + ))} + + + ); +}; + +export default DayAccountView; \ No newline at end of file diff --git a/apps/admin-ui/components/ui/IconSymbol.ios.tsx b/apps/admin-ui/components/ui/IconSymbol.ios.tsx new file mode 100755 index 0000000..9177f4d --- /dev/null +++ b/apps/admin-ui/components/ui/IconSymbol.ios.tsx @@ -0,0 +1,32 @@ +import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols'; +import { StyleProp, ViewStyle } from 'react-native'; + +export function IconSymbol({ + name, + size = 24, + color, + style, + weight = 'regular', +}: { + name: SymbolViewProps['name']; + size?: number; + color: string; + style?: StyleProp; + weight?: SymbolWeight; +}) { + return ( + + ); +} diff --git a/apps/admin-ui/components/ui/IconSymbol.tsx b/apps/admin-ui/components/ui/IconSymbol.tsx new file mode 100755 index 0000000..b7ece6b --- /dev/null +++ b/apps/admin-ui/components/ui/IconSymbol.tsx @@ -0,0 +1,41 @@ +// Fallback for using MaterialIcons on Android and web. + +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { SymbolWeight, SymbolViewProps } from 'expo-symbols'; +import { ComponentProps } from 'react'; +import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native'; + +type IconMapping = Record['name']>; +type IconSymbolName = keyof typeof MAPPING; + +/** + * Add your SF Symbols to Material Icons mappings here. + * - see Material Icons in the [Icons Directory](https://icons.expo.fyi). + * - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app. + */ +const MAPPING = { + 'house.fill': 'home', + 'paperplane.fill': 'send', + 'chevron.left.forwardslash.chevron.right': 'code', + 'chevron.right': 'chevron-right', +} as IconMapping; + +/** + * An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web. + * This ensures a consistent look across platforms, and optimal resource usage. + * Icon `name`s are based on SF Symbols and require manual mapping to Material Icons. + */ +export function IconSymbol({ + name, + size = 24, + color, + style, +}: { + name: IconSymbolName; + size?: number; + color: string | OpaqueColorValue; + style?: StyleProp; + weight?: SymbolWeight; +}) { + return ; +} diff --git a/apps/admin-ui/components/ui/TabBarBackground.ios.tsx b/apps/admin-ui/components/ui/TabBarBackground.ios.tsx new file mode 100755 index 0000000..495b2d4 --- /dev/null +++ b/apps/admin-ui/components/ui/TabBarBackground.ios.tsx @@ -0,0 +1,19 @@ +import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs'; +import { BlurView } from 'expo-blur'; +import { StyleSheet } from 'react-native'; + +export default function BlurTabBarBackground() { + return ( + + ); +} + +export function useBottomTabOverflow() { + return useBottomTabBarHeight(); +} diff --git a/apps/admin-ui/components/ui/TabBarBackground.tsx b/apps/admin-ui/components/ui/TabBarBackground.tsx new file mode 100755 index 0000000..70d1c3c --- /dev/null +++ b/apps/admin-ui/components/ui/TabBarBackground.tsx @@ -0,0 +1,6 @@ +// This is a shim for web and Android where the tab bar is generally opaque. +export default undefined; + +export function useBottomTabOverflow() { + return 0; +} diff --git a/apps/admin-ui/constants/Colors.ts b/apps/admin-ui/constants/Colors.ts new file mode 100755 index 0000000..14e6784 --- /dev/null +++ b/apps/admin-ui/constants/Colors.ts @@ -0,0 +1,26 @@ +/** + * Below are the colors that are used in the app. The colors are defined in the light and dark mode. + * There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc. + */ + +const tintColorLight = '#0a7ea4'; +const tintColorDark = '#fff'; + +export const Colors = { + light: { + text: '#11181C', + background: '#fff', + tint: tintColorLight, + icon: '#687076', + tabIconDefault: '#687076', + tabIconSelected: tintColorLight, + }, + dark: { + text: '#ECEDEE', + background: '#151718', + tint: tintColorDark, + icon: '#9BA1A6', + tabIconDefault: '#9BA1A6', + tabIconSelected: tintColorDark, + }, +}; diff --git a/apps/admin-ui/eas.json b/apps/admin-ui/eas.json new file mode 100755 index 0000000..ec2e587 --- /dev/null +++ b/apps/admin-ui/eas.json @@ -0,0 +1,22 @@ +{ + "cli": { + "version": ">= 16.17.4", + "appVersionSource": "remote" + }, + "build": { + "development": { + "developmentClient": true, + "distribution": "internal" + }, + "preview": { + "distribution": "internal", + "channel": "preview" + }, + "production": { + "autoIncrement": true + } + }, + "submit": { + "production": {} + } +} diff --git a/apps/admin-ui/eslint.config.js b/apps/admin-ui/eslint.config.js new file mode 100755 index 0000000..5025da6 --- /dev/null +++ b/apps/admin-ui/eslint.config.js @@ -0,0 +1,10 @@ +// https://docs.expo.dev/guides/using-eslint/ +const { defineConfig } = require('eslint/config'); +const expoConfig = require('eslint-config-expo/flat'); + +module.exports = defineConfig([ + expoConfig, + { + ignores: ['dist/*'], + }, +]); diff --git a/apps/admin-ui/hooks/useColorScheme.ts b/apps/admin-ui/hooks/useColorScheme.ts new file mode 100755 index 0000000..17e3c63 --- /dev/null +++ b/apps/admin-ui/hooks/useColorScheme.ts @@ -0,0 +1 @@ +export { useColorScheme } from 'react-native'; diff --git a/apps/admin-ui/hooks/useColorScheme.web.ts b/apps/admin-ui/hooks/useColorScheme.web.ts new file mode 100755 index 0000000..7eb1c1b --- /dev/null +++ b/apps/admin-ui/hooks/useColorScheme.web.ts @@ -0,0 +1,21 @@ +import { useEffect, useState } from 'react'; +import { useColorScheme as useRNColorScheme } from 'react-native'; + +/** + * To support static rendering, this value needs to be re-calculated on the client side for web + */ +export function useColorScheme() { + const [hasHydrated, setHasHydrated] = useState(false); + + useEffect(() => { + setHasHydrated(true); + }, []); + + const colorScheme = useRNColorScheme(); + + if (hasHydrated) { + return colorScheme; + } + + return 'light'; +} diff --git a/apps/admin-ui/hooks/useCurrentUserId.ts b/apps/admin-ui/hooks/useCurrentUserId.ts new file mode 100755 index 0000000..7f92190 --- /dev/null +++ b/apps/admin-ui/hooks/useCurrentUserId.ts @@ -0,0 +1,13 @@ +import React, { useEffect, useState } from 'react'; +import { getCurrentUserId } from '@/utils/getCurrentUserId'; + +export function useCurrentUserId(): {userId:number|null, refetchUserId: () => void} { + const [userId, setUserId] = useState(null); + const refetchUserId = React.useCallback(() => { + getCurrentUserId().then(setUserId); + },[]) + useEffect(() => { + getCurrentUserId().then(setUserId); + }, []); + return {userId,refetchUserId}; +} diff --git a/apps/admin-ui/hooks/useHideDrawerHeader.ts b/apps/admin-ui/hooks/useHideDrawerHeader.ts new file mode 100755 index 0000000..c277ec2 --- /dev/null +++ b/apps/admin-ui/hooks/useHideDrawerHeader.ts @@ -0,0 +1,26 @@ +import { useFocusEffect, useNavigation } from "expo-router"; +import React from "react"; + + +function useHideDrawerHeader() { + + const navigation = useNavigation(); + useFocusEffect(() => { + let drawerNav = navigation.getParent(); + const drawerNavList:any = []; + // Collect all parent navigators + while (drawerNav) { + drawerNavList.push(drawerNav); + drawerNav = drawerNav.getParent(); + } + + drawerNavList.at(-3)?.setOptions({ headerShown: false }); + + return () => { + drawerNavList.at(-3)?.setOptions({ headerShown: true }); + }; + }); + return null; +} + +export default useHideDrawerHeader; diff --git a/apps/admin-ui/hooks/useJWT.ts b/apps/admin-ui/hooks/useJWT.ts new file mode 100755 index 0000000..03a9246 --- /dev/null +++ b/apps/admin-ui/hooks/useJWT.ts @@ -0,0 +1,49 @@ +// import { StorageService } from '@/lib/StorageService'; +import {StorageService} from 'common-ui'; + +export const JWT_KEY = 'jwt_token'; +export const ROLES_KEY = 'user_roles'; +export const USER_ID_KEY = 'userId'; + +export async function saveUserId(userId:string) { + await StorageService.setItem(USER_ID_KEY, userId); +} + +export async function getUserId() { + return await StorageService.getItem(USER_ID_KEY); +} + +export async function saveJWT(token: string) { + await StorageService.setItem(JWT_KEY, token); +} + +export async function getJWT() { + return await StorageService.getItem(JWT_KEY); +} + +export async function deleteJWT() { + await StorageService.removeItem(JWT_KEY); +} + +export async function saveRoles(roles: string[]) { + await StorageService.setItem(ROLES_KEY, JSON.stringify(roles)); +} + +export async function getRoles(): Promise { + const jwt = await getJWT(); + if (!jwt) { + StorageService.removeItem(ROLES_KEY); + return null; + } + const rolesStr = await StorageService.getItem(ROLES_KEY); + if (!rolesStr) return null; + try { + return JSON.parse(rolesStr); + } catch { + return null; + } +} + +export async function deleteRoles() { + await StorageService.removeItem(ROLES_KEY); +} diff --git a/apps/admin-ui/hooks/usePhonepeSdk.ts b/apps/admin-ui/hooks/usePhonepeSdk.ts new file mode 100755 index 0000000..0ba4f0a --- /dev/null +++ b/apps/admin-ui/hooks/usePhonepeSdk.ts @@ -0,0 +1,31 @@ +import { usePhonepeCreds } from '@/api-hooks/payment.api'; +import { useEffect } from 'react'; +import PhonePePaymentSDK from 'react-native-phonepe-pg'; + +export function usePhonepeSdk() { + const { data: creds, isLoading, isError } = usePhonepeCreds(); + + useEffect(() => { + if (creds && creds.clientId && creds.clientVersion) { + PhonePePaymentSDK.init('SANDBOX', creds.clientId, creds.clientId, true); + } + }, [creds]); + + const startTransaction = async (orderId: string, token: string) => { + try { + const request = { + orderId, + token, + merchantId: creds?.merchantId, + paymentMode: { type: 'PAY_PAGE' } + }; + const stringReq = JSON.stringify(request); + const response = await PhonePePaymentSDK.startTransaction(stringReq, null); + return response; + } catch (error) { + throw error; + } + }; + + return { startTransaction, isLoading, isError, creds }; +} diff --git a/apps/admin-ui/hooks/useThemeColor.ts b/apps/admin-ui/hooks/useThemeColor.ts new file mode 100755 index 0000000..0608e73 --- /dev/null +++ b/apps/admin-ui/hooks/useThemeColor.ts @@ -0,0 +1,21 @@ +/** + * Learn more about light and dark modes: + * https://docs.expo.dev/guides/color-schemes/ + */ + +import { Colors } from '@/constants/Colors'; +import { useColorScheme } from '@/hooks/useColorScheme'; + +export function useThemeColor( + props: { light?: string; dark?: string }, + colorName: keyof typeof Colors.light & keyof typeof Colors.dark +) { + const theme = useColorScheme() ?? 'light'; + const colorFromProps = props[theme]; + + if (colorFromProps) { + return colorFromProps; + } else { + return Colors[theme][colorName]; + } +} diff --git a/apps/admin-ui/metro.config.js b/apps/admin-ui/metro.config.js new file mode 100755 index 0000000..f7ac395 --- /dev/null +++ b/apps/admin-ui/metro.config.js @@ -0,0 +1,27 @@ +// Learn more on how to setup config for the app: https://docs.expo.dev/guides/config-plugins/#metro-config +const { getDefaultConfig } = require('expo/metro-config'); +const path = require('path'); + +// Find the project root and workspace root +const projectRoot = __dirname; +const workspaceRoot = path.resolve(projectRoot, '../..'); // Adjust this path as needed + +const config = getDefaultConfig(projectRoot); + +// 1. Watch all files within the monorepo +config.watchFolders = [workspaceRoot]; + +// 2. Let Metro know where to resolve modules from +config.resolver.nodeModulesPaths = [ + path.resolve(workspaceRoot, 'node_modules'), + path.resolve(projectRoot, 'node_modules'), +]; + +// 3. Force Metro to resolve (sub)dependencies only from the top-level `node_modules` +config.resolver.disableHierarchicalLookup = true; + +// 4. Ensure Metro correctly resolves the entry point for expo-router +// This is crucial for web builds in a monorepo with expo-router +config.resolver.entryExts = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs']; + +module.exports = config; diff --git a/apps/admin-ui/package.json b/apps/admin-ui/package.json new file mode 100644 index 0000000..ad57921 --- /dev/null +++ b/apps/admin-ui/package.json @@ -0,0 +1,79 @@ +{ + "name": "admin-ui", + "main": "expo-router/entry", + "version": "1.0.0", + "scripts": { + "start": "expo start", + "reset-project": "node ./scripts/reset-project.js", + "android": "expo run:android", + "ios": "expo run:ios", + "web": "expo start --web", + "lint": "expo lint" + }, + "dependencies": { + "@expo/vector-icons": "^14.1.0", + "@react-native-community/datetimepicker": "8.4.1", + "@react-native-picker/picker": "2.11.1", + "@react-navigation/bottom-tabs": "^7.3.10", + "@react-navigation/drawer": "^7.3.9", + "@react-navigation/elements": "^2.3.8", + "@react-navigation/material-top-tabs": "^7.4.11", + "@react-navigation/native": "^7.1.6", + "@tanstack/react-query": "^5.85.9", + "@trpc/client": "^11.6.0", + "@trpc/react-query": "^11.6.0", + "axios": "^1.11.0", + "buffer": "^6.0.3", + "dayjs": "^1.11.18", + "expo": "~53.0.22", + "expo-blur": "~14.1.5", + "expo-constants": "~17.1.7", + "expo-device": "~7.1.4", + "expo-document-picker": "~13.1.6", + "expo-font": "~13.3.2", + "expo-haptics": "~14.1.4", + "expo-image": "~2.4.0", + "expo-image-picker": "~16.1.4", + "expo-linear-gradient": "~14.1.5", + "expo-linking": "~7.1.7", + "expo-location": "^19.0.8", + "expo-notifications": "~0.31.4", + "expo-router": "~5.1.5", + "expo-secure-store": "~14.2.4", + "expo-splash-screen": "~0.30.10", + "expo-status-bar": "~2.2.3", + "expo-symbols": "~0.4.5", + "expo-system-ui": "~5.0.11", + "expo-updates": "~0.28.17", + "expo-web-browser": "~14.2.0", + "formik": "^2.4.6", + "jwt-decode": "^4.0.0", + "react": "19.0.0", + "react-dom": "19.0.0", + "react-hook-form": "^7.62.0", + "react-native": "0.79.6", + "react-native-draggable-flatlist": "^4.0.3", + "react-native-element-dropdown": "^2.12.4", + "react-native-gesture-handler": "~2.24.0", + "react-native-pager-view": "6.7.1", + "react-native-paper": "^5.14.5", + "react-native-reanimated": "~3.17.4", + "react-native-safe-area-context": "5.4.0", + "react-native-screens": "~4.11.1", + "react-native-tab-view": "^4.1.3", + "react-native-toast-message": "^2.3.3", + "react-native-web": "~0.20.0", + "react-native-webview": "13.13.5", + "twrnc": "^4.9.1", + "yup": "^1.7.0" + }, + "devDependencies": { + "@babel/core": "^7.25.2", + "@types/react": "~19.0.10", + "@types/react-native-razorpay": "^2.2.6", + "eslint": "^9.25.0", + "eslint-config-expo": "~9.2.0", + "typescript": "~5.8.3" + }, + "private": true +} diff --git a/apps/admin-ui/scripts/reset-project.js b/apps/admin-ui/scripts/reset-project.js new file mode 100755 index 0000000..51dff15 --- /dev/null +++ b/apps/admin-ui/scripts/reset-project.js @@ -0,0 +1,112 @@ +#!/usr/bin/env node + +/** + * This script is used to reset the project to a blank state. + * It deletes or moves the /app, /components, /hooks, /scripts, and /constants directories to /app-example based on user input and creates a new /app directory with an index.tsx and _layout.tsx file. + * You can remove the `reset-project` script from package.json and safely delete this file after running it. + */ + +const fs = require("fs"); +const path = require("path"); +const readline = require("readline"); + +const root = process.cwd(); +const oldDirs = ["app", "components", "hooks", "constants", "scripts"]; +const exampleDir = "app-example"; +const newAppDir = "app"; +const exampleDirPath = path.join(root, exampleDir); + +const indexContent = `import { Text, View } from "react-native"; + +export default function Index() { + return ( + + Edit app/index.tsx to edit this screen. + + ); +} +`; + +const layoutContent = `import { Stack } from "expo-router"; + +export default function RootLayout() { + return ; +} +`; + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); + +const moveDirectories = async (userInput) => { + try { + if (userInput === "y") { + // Create the app-example directory + await fs.promises.mkdir(exampleDirPath, { recursive: true }); + console.log(`📁 /${exampleDir} directory created.`); + } + + // Move old directories to new app-example directory or delete them + for (const dir of oldDirs) { + const oldDirPath = path.join(root, dir); + if (fs.existsSync(oldDirPath)) { + if (userInput === "y") { + const newDirPath = path.join(root, exampleDir, dir); + await fs.promises.rename(oldDirPath, newDirPath); + console.log(`➡️ /${dir} moved to /${exampleDir}/${dir}.`); + } else { + await fs.promises.rm(oldDirPath, { recursive: true, force: true }); + console.log(`❌ /${dir} deleted.`); + } + } else { + console.log(`➡️ /${dir} does not exist, skipping.`); + } + } + + // Create new /app directory + const newAppDirPath = path.join(root, newAppDir); + await fs.promises.mkdir(newAppDirPath, { recursive: true }); + console.log("\n📁 New /app directory created."); + + // Create index.tsx + const indexPath = path.join(newAppDirPath, "index.tsx"); + await fs.promises.writeFile(indexPath, indexContent); + console.log("📄 app/index.tsx created."); + + // Create _layout.tsx + const layoutPath = path.join(newAppDirPath, "_layout.tsx"); + await fs.promises.writeFile(layoutPath, layoutContent); + console.log("📄 app/_layout.tsx created."); + + console.log("\n✅ Project reset complete. Next steps:"); + console.log( + `1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${ + userInput === "y" + ? `\n3. Delete the /${exampleDir} directory when you're done referencing it.` + : "" + }` + ); + } catch (error) { + console.error(`❌ Error during script execution: ${error.message}`); + } +}; + +rl.question( + "Do you want to move existing files to /app-example instead of deleting them? (Y/n): ", + (answer) => { + const userInput = answer.trim().toLowerCase() || "y"; + if (userInput === "y" || userInput === "n") { + moveDirectories(userInput).finally(() => rl.close()); + } else { + console.log("❌ Invalid input. Please enter 'Y' or 'N'."); + rl.close(); + } + } +); diff --git a/apps/admin-ui/services/axios-admin-ui.ts b/apps/admin-ui/services/axios-admin-ui.ts new file mode 100644 index 0000000..5fac5e4 --- /dev/null +++ b/apps/admin-ui/services/axios-admin-ui.ts @@ -0,0 +1,59 @@ +import axiosParent from 'axios'; +import { FORCE_LOGOUT_EVENT } from 'common-ui/src/lib/const-strs'; +import { DeviceEventEmitter } from 'react-native' +import { getJWT } from '@/hooks/useJWT'; +import { BASE_API_URL } from 'common-ui'; + +// export const API_BASE_URL = 'http://192.168.100.95:4000'; // Change to your API base URL +// const API_BASE_URL = 'https://www.technocracy.ovh/mf'; // Change to your API base URL +// const API_BASE_URL = 'http://10.195.26.42:4000'; // Change to your API base URL +// const API_BASE_URL = 'http://localhost:4000/api/mobile/'; // Change to your API base URL +// const API_BASE_URL = 'https://car-safar.com/api/mobile/'; // Change to your API base URL + +const axios = axiosParent.create({ + baseURL: BASE_API_URL + '/api/v1', + timeout: 60000, + // headers: { + // 'Content-Type': 'application/json', + // }, +}); + + +axios.interceptors.request.use( + async (config) => { + const token = await getJWT(); + + if (token) { + config.headers = config.headers || {}; + config.headers['Authorization'] = `Bearer ${token}`; + } + return config; + }, + (error) => Promise.reject(error) +); + +axios.interceptors.response.use( + (response) => response, + (error) => { + + const status = error?.status; + const msg = error.response?.data?.error; + + if (status === 401 && msg.startsWith('Access denied')) { + // Handle unauthorized access + DeviceEventEmitter.emit(FORCE_LOGOUT_EVENT); + } + const message = error?.response?.data?.error; + + if (msg) { + // Optionally, you can attach the message to the error object or throw a new error + const err = new Error(msg); + // Optionally attach the original error for debugging + (err as any).original = error; + return Promise.reject(err); + } + return Promise.reject(error); + } +); + +export default axios; diff --git a/apps/admin-ui/services/notif-service/notif-checker.tsx b/apps/admin-ui/services/notif-service/notif-checker.tsx new file mode 100755 index 0000000..40cd786 --- /dev/null +++ b/apps/admin-ui/services/notif-service/notif-checker.tsx @@ -0,0 +1,71 @@ +import {useAddPushToken, useHasPushToken } from "@/api-hooks/user.api"; +import React from "react"; +import { useNotification } from "./notif-context"; +import { BottomDialog } from "common-ui"; +import { MyText } from "common-ui"; +import { View, Linking } from "react-native"; +import { tw } from "common-ui"; +import { MyButton } from "common-ui"; +import { useAuth } from "@/components/context/auth-context"; + +interface Props {} + +function NotifChecker(props: Props) { + const {} = props; + const [showPermissionDialog, setShowPermissionDialog] = React.useState(false); + + const {isLoggedIn} = useAuth(); + const { data: hasPushToken, isLoading, isError } = useHasPushToken({enabled: isLoggedIn}); + const { mutate: addPushToken } = useAddPushToken(); + const { notifPermission, expoPushToken } = useNotification(); + React.useEffect(() => { + if(isLoggedIn && !hasPushToken && notifPermission =='granted') { + addPushToken(expoPushToken!); + } + },[isLoggedIn, hasPushToken]) + + React.useEffect(() => { + if (notifPermission === "denied") { + setShowPermissionDialog(true); + } + }, [notifPermission]); + + return ( + <> + setShowPermissionDialog(false)} + > + + + Notification Permission Denied + + + It seems you have denied notification permissions. Please enable + them in your device settings. + + + setShowPermissionDialog(false)} + style={tw`flex-1`} + > + Cancel + + { + Linking.openSettings(); + }} + style={tw`flex-1`} + > + Settings + + + + + + ); +} + +export default NotifChecker; diff --git a/apps/admin-ui/services/notif-service/notif-context.tsx b/apps/admin-ui/services/notif-service/notif-context.tsx new file mode 100755 index 0000000..6998774 --- /dev/null +++ b/apps/admin-ui/services/notif-service/notif-context.tsx @@ -0,0 +1,111 @@ +import React, { + createContext, + useContext, + useState, + useEffect, + useRef, + ReactNode, +} from "react"; +import * as Notifications from "expo-notifications"; +import { registerForPushNotificationsAsync } from "./notif-register"; +import { useRouter } from "expo-router"; +import { NotificationToast } from "../toaster"; +import { NOTIF_PERMISSION_DENIED } from "common-ui/src/lib/const-strs"; + +interface NotificationContextType { + expoPushToken: string | null; + notification: Notifications.Notification | null; + error: Error | null; + notifPermission: 'pending' | 'granted' | 'denied' +} + +export const NotificationContext = createContext< + NotificationContextType | undefined +>(undefined); + +export const useNotification = () => { + const context = useContext(NotificationContext); + if (context === undefined) { + throw new Error( + "useNotification must be used within a NotificationProvider" + ); + } + return context; +}; + +interface NotificationProviderProps { + children: ReactNode; +} + +export const NotificationProvider: React.FC = ({ + children, +}) => { + const [expoPushToken, setExpoPushToken] = useState(null); + const [notification, setNotification] = + useState(null); + const [error, setError] = useState(null); + const [notifPermission, setNotifPermission] = React.useState("pending"); + + const notificationListener = useRef(null); + const responseListener = useRef(null); + const router = useRouter(); + + useEffect(() => { + registerForPushNotificationsAsync() + .then((token) => { + setExpoPushToken(token); + setNotifPermission("granted"); + }) + .catch((errorRaw) => { + + const err = String(errorRaw).slice(7); //remove the "Error: " string component in beginning + + if (err === NOTIF_PERMISSION_DENIED) { + setNotifPermission("denied"); + } + }); + + notificationListener.current = + Notifications.addNotificationReceivedListener((notification) => { + setNotification(notification); + // Show a visible toast when app is in foreground + const content = notification.request?.content; + if (content) { + NotificationToast( + content.title || "Notification", + content.body || "", + content.data || {} + ); + } + }); + + responseListener.current = + Notifications.addNotificationResponseReceivedListener((response) => { + const data = response.notification.request.content.data; + if (data && data.doctorId) { + router.push(`/(drawer)/dashboard`); + } else if (data && data.tokenId) { + router.push(`/(drawer)/dashboard`); + } + }); + + return () => { + if (notificationListener.current) { + Notifications.removeNotificationSubscription( + notificationListener.current + ); + } + if (responseListener.current) { + Notifications.removeNotificationSubscription(responseListener.current); + } + }; + }, []); + + return ( + + {children} + + ); +}; diff --git a/apps/admin-ui/services/notif-service/notif-register.ts b/apps/admin-ui/services/notif-service/notif-register.ts new file mode 100755 index 0000000..dc317f6 --- /dev/null +++ b/apps/admin-ui/services/notif-service/notif-register.ts @@ -0,0 +1,51 @@ +import * as Notifications from "expo-notifications"; +import * as Device from "expo-device"; +import Constants from "expo-constants"; +import { Platform } from "react-native"; +import { NOTIF_PERMISSION_DENIED } from "common-ui/src/lib/const-strs"; + +export async function registerForPushNotificationsAsync() { + if (Platform.OS === "android") { + await Notifications.setNotificationChannelAsync("default", { + name: "default", + importance: Notifications.AndroidImportance.MAX, + vibrationPattern: [0, 250, 250, 250], + lightColor: "#FF231F7C", + }); + } + + if (Device.isDevice) { + const { status: existingStatus } = + await Notifications.getPermissionsAsync(); + let finalStatus = existingStatus; + if (existingStatus !== "granted") { + const { status } = await Notifications.requestPermissionsAsync(); + finalStatus = status; + } + + if (finalStatus !== "granted") { + throw new Error( + NOTIF_PERMISSION_DENIED + ); + } + const projectId = + Constants?.expoConfig?.extra?.eas?.projectId ?? + Constants?.easConfig?.projectId; + if (!projectId) { + throw new Error("Project ID not found"); + } + try { + const pushTokenString = ( + await Notifications.getExpoPushTokenAsync({ + projectId, + }) + ).data; + console.log(pushTokenString); + return pushTokenString; + } catch (e: unknown) { + throw new Error(`${e}`); + } + } else { + throw new Error("Must use physical device for push notifications"); + } +} \ No newline at end of file diff --git a/apps/admin-ui/services/toaster.tsx b/apps/admin-ui/services/toaster.tsx new file mode 100755 index 0000000..55e6697 --- /dev/null +++ b/apps/admin-ui/services/toaster.tsx @@ -0,0 +1,57 @@ +import Toast from "react-native-toast-message"; +import React from "react"; +import { useRouter } from "expo-router"; + +export function InfoToast(message: string) { + Toast.show({ + type: "info", + text1: message, + position: "top", + visibilityTime: 10000, + onPress: () => { + Toast.hide(); + }, + }); +} + +export function ErrorToast(message: string) { + Toast.show({ + type: "error", + text1: message, + position: "top", + onPress: () => { + Toast.hide(); + }, + }); +} + +export function SuccessToast(message: string) { + Toast.show({ + type: "success", + text1: message, + position: "top", + onPress: () => { + Toast.hide(); + }, + }); +} + +export function NotificationToast(title: string, subtitle: string, data: any) { + const router = useRouter(); + Toast.show({ + type: "info", + text1: title, + text2: subtitle, + position: "top", + onPress: () => { + if (data && data.rideId) { + // router.push(`/(drawer)/dashboard/ride-details?id=${data.rideId}`); + } else if (data && data.carId) { + // router.push(`/(drawer)/my-cars/car-details?id=${data.carId}`); + } + Toast.hide(); + }, + }); +} + +export default Toast; diff --git a/apps/admin-ui/src/api-hooks/banner.api.ts b/apps/admin-ui/src/api-hooks/banner.api.ts new file mode 100644 index 0000000..70bddb3 --- /dev/null +++ b/apps/admin-ui/src/api-hooks/banner.api.ts @@ -0,0 +1,26 @@ +// Types +export interface Banner { + id: number; + name: string; + imageUrl: string; + description?: string; + productId?: number; + redirectUrl?: string; + serialNum: number; + isActive: boolean; + createdAt: string; + lastUpdated: string; +} + +export interface CreateBannerPayload { + name: string; + imageUrl: string; + description?: string; + productId?: number; + redirectUrl?: string; + serialNum: number; +} + +export interface UpdateBannerPayload extends Partial { + isActive?: boolean; +} \ No newline at end of file diff --git a/apps/admin-ui/src/api-hooks/product.api.ts b/apps/admin-ui/src/api-hooks/product.api.ts new file mode 100644 index 0000000..bdb42ed --- /dev/null +++ b/apps/admin-ui/src/api-hooks/product.api.ts @@ -0,0 +1,111 @@ +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import axios from '../../services/axios-admin-ui'; + +// Types +export interface CreateProductPayload { + name: string; + shortDescription?: string; + longDescription?: string; + unitId: number; + storeId: number; + price: number; + marketPrice?: number; + incrementStep?: number; + productQuantity?: number; + isOutOfStock?: boolean; + deals?: { + quantity: number; + price: number; + validTill: string; + }[]; +} + +export interface UpdateProductPayload { + name: string; + shortDescription?: string; + longDescription?: string; + unitId: number; + storeId: number; + price: number; + marketPrice?: number; + incrementStep?: number; + productQuantity?: number; + isOutOfStock?: boolean; + deals?: { + quantity: number; + price: number; + validTill: string; + }[]; +} + +export interface Product { + id: number; + name: string; + shortDescription?: string | null; + longDescription?: string; + unitId: number; + storeId: number; + price: number; + marketPrice?: number; + productQuantity?: number; + isOutOfStock?: boolean; + images?: string[]; + createdAt: string; + unit?: { + id: number; + shortNotation: string; + fullName: string; + }; + deals?: { + id: number; + quantity: string; + price: string; + validTill: string; + }[]; +} + +export interface CreateProductResponse { + product: Product; + deals?: any[]; + message: string; +} + +// API functions +const createProductApi = async (formData: FormData): Promise => { + const response = await axios.post('/av/products', formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data; +}; + +const updateProductApi = async ({ id, formData }: { id: number; formData: FormData }): Promise => { + const response = await axios.put(`/av/products/${id}`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data; +}; + +// Hooks +export const useCreateProduct = () => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: createProductApi, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['products'] }); + }, + }); +}; + +export const useUpdateProduct = () => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: updateProductApi, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['products'] }); + }, + }); +}; diff --git a/apps/admin-ui/src/api-hooks/tag.api.ts b/apps/admin-ui/src/api-hooks/tag.api.ts new file mode 100644 index 0000000..a0cea0b --- /dev/null +++ b/apps/admin-ui/src/api-hooks/tag.api.ts @@ -0,0 +1,116 @@ +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import axios from '../../services/axios-admin-ui'; + +// Types +export interface CreateTagPayload { + tagName: string; + tagDescription?: string; + imageUrl?: string; + isDashboardTag: boolean; +} + +export interface UpdateTagPayload { + tagName: string; + tagDescription?: string; + imageUrl?: string; + isDashboardTag: boolean; +} + +export interface Tag { + id: number; + tagName: string; + tagDescription: string | null; + imageUrl: string | null; + isDashboardTag: boolean; + createdAt?: string; +} + +export interface CreateTagResponse { + tag: Tag; + message: string; +} + +export interface GetTagsResponse { + tags: Tag[]; + message: string; +} + +// API functions +const createTagApi = async (formData: FormData): Promise => { + const response = await axios.post('/av/product-tags', formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data; +}; + +const updateTagApi = async ({ id, formData }: { id: number; formData: FormData }): Promise => { + const response = await axios.put(`/av/product-tags/${id}`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data; +}; + +const deleteTagApi = async (id: number): Promise<{ message: string }> => { + const response = await axios.delete(`/av/product-tags/${id}`); + return response.data; +}; + +const getTagsApi = async (): Promise => { + const response = await axios.get('/av/product-tags'); + return response.data; +}; + +const getTagApi = async (id: number): Promise<{ tag: Tag }> => { + const response = await axios.get(`/av/product-tags/${id}`); + return response.data; +}; + +// Hooks +export const useCreateTag = () => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: createTagApi, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['tags'] }); + }, + }); +}; + +export const useUpdateTag = () => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: updateTagApi, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['tags'] }); + }, + }); +}; + +export const useDeleteTag = () => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: deleteTagApi, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['tags'] }); + }, + }); +}; + +export const useGetTags = () => { + return useQuery({ + queryKey: ['tags'], + queryFn: getTagsApi, + }); +}; + +export const useGetTag = (id: number) => { + return useQuery({ + queryKey: ['tags', id], + queryFn: () => getTagApi(id), + enabled: !!id, + }); +}; \ No newline at end of file diff --git a/apps/admin-ui/src/components/CouponForm.tsx b/apps/admin-ui/src/components/CouponForm.tsx new file mode 100644 index 0000000..0568404 --- /dev/null +++ b/apps/admin-ui/src/components/CouponForm.tsx @@ -0,0 +1,385 @@ +import React, { useState, useEffect } from 'react'; +import { View, Text, TouchableOpacity, FlatList } from 'react-native'; +import { Formik } from 'formik'; +import * as Yup from 'yup'; +import { MyTextInput, MyButton, tw, AppContainer , DateTimePickerMod, Checkbox, BottomDialog, MyText } from 'common-ui'; +import { trpc } from '../trpc-client'; + +import { CreateCouponPayload } from 'common-ui/shared-types'; + +const USERS_PAGE_SIZE = 10; + +interface CouponFormProps { + onSubmit: (values: CreateCouponPayload & { isReservedCoupon?: boolean }) => void; + isLoading: boolean; + initialValues?: Partial; +} + +const couponValidationSchema = Yup.object().shape({ + isReservedCoupon: Yup.boolean().optional(), + couponCode: Yup.string() + .required('Coupon code is required') + .min(3, 'Coupon code must be at least 3 characters') + .max(50, 'Coupon code cannot exceed 50 characters') + .matches(/^[A-Z0-9_-]+$/, 'Coupon code can only contain uppercase letters, numbers, underscores, and hyphens'), + discountPercent: Yup.number() + .min(0, 'Must be positive') + .max(100, 'Cannot exceed 100%') + .optional(), + flatDiscount: Yup.number() + .min(0, 'Must be positive') + .optional(), + minOrder: Yup.number().min(0, 'Must be positive').optional(), + maxValue: Yup.number().min(0, 'Must be positive').optional(), + validTill: Yup.date().optional(), + maxLimitForUser: Yup.number().min(1, 'Must be at least 1').optional(), + exclusiveApply: Yup.boolean().optional(), + isUserBased: Yup.boolean(), + isApplyForAll: Yup.boolean(), + applicableUsers: Yup.array().of(Yup.number()).optional(), +}).test('discount-validation', 'Must provide exactly one discount type with valid value', function(value) { + const { discountPercent, flatDiscount } = value; + const hasPercent = discountPercent !== undefined && discountPercent > 0; + const hasFlat = flatDiscount !== undefined && flatDiscount > 0; + + if (hasPercent && hasFlat) { + return this.createError({ message: 'Cannot have both percentage and flat discount' }); + } + if (!hasPercent && !hasFlat) { + return this.createError({ message: 'Must provide either percentage or flat discount' }); + } + return true; +}); + +export default function CouponForm({ onSubmit, isLoading, initialValues }: CouponFormProps) { + + // User dropdown states + const [userSearchQuery, setUserSearchQuery] = useState(''); + const [userOffset, setUserOffset] = useState(0); + const [allUsers, setAllUsers] = useState<{ id: number; name: string; mobile: string | null }[]>([]); + const [hasMoreUsers, setHasMoreUsers] = useState(true); + const [usersDropdownOpen, setUsersDropdownOpen] = useState(false); + + const { data: usersData, isFetching: isFetchingUsers } = trpc.admin.coupon.getUsersMiniInfo.useQuery( + { search: userSearchQuery, limit: USERS_PAGE_SIZE, offset: userOffset }, + { enabled: usersDropdownOpen } + ); + + useEffect(() => { + if (usersData?.users) { + if (userOffset === 0) { + setAllUsers(usersData.users); + } else { + setAllUsers(prev => [...prev, ...usersData.users]); + } + setHasMoreUsers(usersData.users.length === USERS_PAGE_SIZE); + } + }, [usersData, userOffset]); + + useEffect(() => { + setUserOffset(0); + setHasMoreUsers(true); + }, [userSearchQuery]); + + useEffect(() => { + if (usersDropdownOpen) { + setUserOffset(0); + setAllUsers([]); + setHasMoreUsers(true); + setUserSearchQuery(''); + } + }, [usersDropdownOpen]); + + + + // User search functionality will be inside Formik + + const defaultValues: CreateCouponPayload & { isReservedCoupon?: boolean } = { + couponCode: '', + isUserBased: false, + isApplyForAll: false, + targetUsers: [], + discountPercent: undefined, + flatDiscount: undefined, + minOrder: undefined, + maxValue: undefined, + validTill: undefined, + maxLimitForUser: undefined, + productIds: undefined, + applicableUsers: [], + applicableProducts: [], + exclusiveApply: false, + isReservedCoupon: false, + }; + + return ( + + {({ values, errors, touched, setFieldValue, handleSubmit }) => { + + + const toggleUserSelection = (userId: number) => { + const current = values.applicableUsers || []; + const newSelection = current.includes(userId) + ? current.filter(id => id !== userId) + : [...current, userId]; + console.log('Toggling user:', userId, 'New selection:', newSelection); + setFieldValue('applicableUsers', newSelection); + }; + + const isReserved = (values as any).isReservedCoupon; + + return ( + + {/* Is Reserved Coupon Checkbox */} + + setFieldValue('isReservedCoupon', !(values as any).isReservedCoupon)} + /> + Is Reserved Coupon + + + {/* Coupon Code */} + + setFieldValue('couponCode', text.toUpperCase())} + keyboardType="default" + autoCapitalize="characters" + error={!!(touched.couponCode && errors.couponCode)} + /> + + + {/* Discount Type Selection */} + + Discount Type * + + + + { + setFieldValue('discountPercent', values.discountPercent || 0); + setFieldValue('flatDiscount', undefined); + }} + style={tw`flex-1 p-3 border rounded-lg mr-2 ${ + values.discountPercent !== undefined ? 'border-blue-500' : 'border-gray-300' + }`} + > + Percentage + + + { + setFieldValue('flatDiscount', values.flatDiscount || 0); + setFieldValue('discountPercent', undefined); + }} + style={tw`flex-1 p-3 border rounded-lg ${ + values.flatDiscount !== undefined ? 'border-blue-500' : 'border-gray-300' + }`} + > + Flat Amount + + + + {/* Discount Value */} + {values.discountPercent !== undefined && ( + + setFieldValue('discountPercent', parseFloat(text) || 0)} + keyboardType="numeric" + error={!!(touched.discountPercent && errors.discountPercent)} + /> + + )} + + {values.flatDiscount !== undefined && ( + + setFieldValue('flatDiscount', parseFloat(text) || 0)} + keyboardType="numeric" + error={!!(touched.flatDiscount && errors.flatDiscount)} + /> + + )} + + {/* Minimum Order */} + + setFieldValue('minOrder', parseFloat(text) || undefined)} + keyboardType="numeric" + error={!!(touched.minOrder && errors.minOrder)} + /> + + + {/* Maximum Discount Value */} + + setFieldValue('maxValue', parseFloat(text) || undefined)} + keyboardType="numeric" + error={!!(touched.maxValue && errors.maxValue)} + /> + + + {/* Validity Period */} + + Valid Till + { + + setFieldValue('validTill', date?.toISOString()) + }} + /> + + + {/* Usage Limit */} + + setFieldValue('maxLimitForUser', parseInt(text) || undefined)} + keyboardType="numeric" + error={!!(touched.maxLimitForUser && errors.maxLimitForUser)} + /> + + + {/* Exclusive Apply */} + + Exclusive Apply + setFieldValue('exclusiveApply', !values.exclusiveApply)} + style={tw`flex-row items-center`} + > + + {values.exclusiveApply && } + + Exclusive coupon (cannot be combined with other coupons) + + + + {/* Target Audience */} + + Target Audience {isReserved ? '(Disabled for Reserved Coupons)' : ''} + + + + { + setFieldValue('isApplyForAll', true); + setFieldValue('isUserBased', false); + setFieldValue('targetUsers', []); + }} + style={tw`flex-1 p-3 border rounded-lg mr-2 ${ + values.isApplyForAll ? 'border-blue-500' : 'border-gray-300' + } ${isReserved ? 'opacity-50' : ''}`} + > + All Users + + + { + setFieldValue('isUserBased', true); + setFieldValue('isApplyForAll', false); + }} + style={tw`flex-1 p-3 border rounded-lg ${ + values.isUserBased ? 'border-blue-500' : 'border-gray-300' + } ${isReserved ? 'opacity-50' : ''}`} + > + Specific User + + + + {/* Applicable User Selection */} + + Applicable Users (Optional) + setUsersDropdownOpen(true)} + style={tw`border border-gray-300 rounded p-3 bg-white ${isReserved ? 'opacity-50' : ''}`} + > + + {values.applicableUsers?.length ? `${values.applicableUsers.length} users selected` : 'Select users...'} + + + + + setUsersDropdownOpen(false)}> + + Select Applicable Users + + item.id.toString()} + renderItem={({ item }) => ( + toggleUserSelection(item.id)} + style={tw`flex-row items-center p-3 border-b border-gray-200`} + > + toggleUserSelection(item.id)} + /> + {item.mobile} - {item.name} + + )} + onEndReached={() => { + if (hasMoreUsers && !isFetchingUsers) { + setUserOffset(prev => prev + USERS_PAGE_SIZE); + } + }} + onEndReachedThreshold={0.5} + ListFooterComponent={isFetchingUsers ? Loading... : null} + style={tw`max-h-60`} + /> + setUsersDropdownOpen(false)} + style={tw`mt-4 bg-blue-500 p-3 rounded`} + > + Done + + + + + + + + + {/* Submit Button */} + handleSubmit()} + loading={isLoading} + disabled={isLoading} + > + Create Coupon + + + ); + }} + + ); +} \ No newline at end of file diff --git a/apps/admin-ui/src/components/ProductForm.tsx b/apps/admin-ui/src/components/ProductForm.tsx new file mode 100644 index 0000000..1502214 --- /dev/null +++ b/apps/admin-ui/src/components/ProductForm.tsx @@ -0,0 +1,374 @@ +import React, { useState, useEffect, useCallback, forwardRef, useImperativeHandle } from 'react'; +import { View, TouchableOpacity } from 'react-native'; +import { Image } from 'expo-image'; +import { Formik, FieldArray } from 'formik'; +import * as Yup from 'yup'; +import { MyTextInput, BottomDropdown, MyText, ImageUploader, ImageGalleryWithDelete, useTheme, DatePicker, tw, useFocusCallback, Checkbox } from 'common-ui'; +import usePickImage from 'common-ui/src/components/use-pick-image'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { trpc } from '../trpc-client'; +import { useGetTags } from '../api-hooks/tag.api'; + +interface ProductFormData { + name: string; + shortDescription: string; + longDescription: string; + unitId: number; + storeId: number; + price: string; + marketPrice: string; + isSuspended: boolean; + isFlashAvailable: boolean; + flashPrice: string; + deals: Deal[]; + tagIds: number[]; + productQuantity: number; +} + +interface Deal { + quantity: string; + price: string; + validTill: Date | null; +} + +export interface ProductFormRef { + clearImages: () => void; +} + +interface ProductFormProps { + mode: 'create' | 'edit'; + initialValues: ProductFormData; + onSubmit: (values: ProductFormData, images?: { uri?: string }[], imagesToDelete?: string[]) => void; + isLoading: boolean; + existingImages?: string[]; +} + +const unitOptions = [ + { label: 'Kg', value: 1 }, + { label: 'Litre', value: 2 }, + { label: 'Dozen', value: 3 }, + { label: 'Unit Piece', value: 4 }, +]; + + + +const ProductForm = forwardRef(({ + mode, + initialValues, + onSubmit, + isLoading, + existingImages = [] +}, ref) => { + const { theme } = useTheme(); + const [images, setImages] = useState<{ uri?: string }[]>([]); + const [existingImagesState, setExistingImagesState] = useState(existingImages); + + const { data: storesData } = trpc.common.getStoresSummary.useQuery(); + const storeOptions = storesData?.stores.map(store => ({ + label: store.name, + value: store.id, + })) || []; + + const { data: tagsData } = useGetTags(); + const tagOptions = tagsData?.tags.map(tag => ({ + label: tag.tagName, + value: tag.id.toString(), + })) || []; + + // Initialize existing images state when existingImages prop changes + useEffect(() => { + console.log('changing existing imaes statte') + + setExistingImagesState(existingImages); + }, [existingImages]); + + const pickImage = usePickImage({ + setFile: (files) => setImages(prev => [...prev, ...files]), + multiple: true, + }); + + // Calculate which existing images were deleted + const deletedImages = existingImages.filter(img => !existingImagesState.includes(img)); + + return ( + onSubmit(values, images, deletedImages)} + enableReinitialize + > + {({ handleChange, handleSubmit, values, setFieldValue, resetForm }) => { + // Clear form when screen comes into focus + const clearForm = useCallback(() => { + setImages([]); + setExistingImagesState([]); + resetForm(); + }, [resetForm]); + + useFocusCallback(clearForm); + + // Update ref with current clearForm function + useImperativeHandle(ref, () => ({ + clearImages: clearForm, + }), [clearForm]); + + const submit = () => handleSubmit(); + + return ( + + + + + + {mode === 'create' && ( + setImages(prev => prev.filter(img => img.uri !== uri))} + /> + )} + + {mode === 'edit' && existingImagesState.length > 0 && ( + + Current Images + + + )} + + {mode === 'edit' && ( + + Add New Images + setImages(prev => prev.filter(img => img.uri !== uri))} + /> + + )} + + handleChange('unitId')(value+'')} + onValueChange={(value) => setFieldValue('unitId', value)} + placeholder="Select unit" + style={{ marginBottom: 16 }} + /> + { + // if(text) + // setFieldValue('productQuantity', text); + // else + setFieldValue('productQuantity', text); + // if (text === '' || text === null || text === undefined) { + // setFieldValue('productQuantity', 1); + // } else { + // const num = parseFloat(text); + // setFieldValue('productQuantity', isNaN(num) ? 1 : num); + // } + }} + style={{ marginBottom: 16 }} + /> + setFieldValue('storeId', value)} + placeholder="Select store" + style={{ marginBottom: 16 }} + /> + id.toString())} + options={tagOptions} + onValueChange={(value) => setFieldValue('tagIds', (value as string[]).map(id => parseInt(id)))} + multiple={true} + placeholder="Select tags" + style={{ marginBottom: 16 }} + /> + + + + + + + setFieldValue('isSuspended', !values.isSuspended)} + style={tw`mr-3`} + /> + Suspend Product + + + + { + setFieldValue('isFlashAvailable', !values.isFlashAvailable); + if (values.isFlashAvailable) setFieldValue('flashPrice', ''); // Clear price when disabled + }} + style={tw`mr-3`} + /> + Flash Available + + + {values.isFlashAvailable && ( + + )} + + {/* + {({ push, remove, form }) => ( + + + + + Special Package Deals + + (Optional) + + {(form.values.deals || []).map((deal: any, index: number) => ( + + + + + + + + + + + + + form.setFieldValue(`deals.${index}.validTill`, date)} + showLabel={true} + placeholder="Valid Till" + /> + + + remove(index)} + style={tw`bg-red-500 p-3 rounded-lg shadow-md flex-row items-center justify-center`} + > + + Remove + + + + + + ))} + + {(form.values.deals || []).length === 0 && ( + + + + No package deals added yet + + + Add special pricing for bulk purchases + + + )} + + push({ quantity: '', price: '', validTill: null })} + style={tw`bg-green-500 px-4 py-2 rounded-lg shadow-lg flex-row items-center justify-center mt-4`} + > + + Add Package Deal + + + )} + */} + + + + {isLoading ? (mode === 'create' ? 'Creating...' : 'Updating...') : (mode === 'create' ? 'Create Product' : 'Update Product')} + + + + ); + }} + + ); +}); + +ProductForm.displayName = 'ProductForm'; + +export default ProductForm; \ No newline at end of file diff --git a/apps/admin-ui/src/components/TagForm.tsx b/apps/admin-ui/src/components/TagForm.tsx new file mode 100644 index 0000000..b35a9ad --- /dev/null +++ b/apps/admin-ui/src/components/TagForm.tsx @@ -0,0 +1,141 @@ +import React, { useState, useEffect, forwardRef, useCallback } from 'react'; +import { View, TouchableOpacity } from 'react-native'; +import { Image } from 'expo-image'; +import { Formik } from 'formik'; +import * as Yup from 'yup'; +import { MyTextInput, MyText, Checkbox, ImageUploader, tw, useFocusCallback } from 'common-ui'; +import usePickImage from 'common-ui/src/components/use-pick-image'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +interface TagFormData { + tagName: string; + tagDescription: string; + isDashboardTag: boolean; +} + +interface TagFormProps { + mode: 'create' | 'edit'; + initialValues: TagFormData; + existingImageUrl?: string; + onSubmit: (values: TagFormData, image?: { uri?: string }) => void; + isLoading: boolean; +} + +const TagForm = forwardRef(({ + mode, + initialValues, + existingImageUrl = '', + onSubmit, + isLoading, +}, ref) => { + const [image, setImage] = useState<{ uri?: string } | null>(null); + const [isDashboardTagChecked, setIsDashboardTagChecked] = useState(Boolean(initialValues.isDashboardTag)); + + // Update checkbox when initial values change + useEffect(() => { + setIsDashboardTagChecked(Boolean(initialValues.isDashboardTag)); + existingImageUrl && setImage({uri:existingImageUrl}) + }, [initialValues.isDashboardTag]); + + const pickImage = usePickImage({ + setFile: (files) => { + + setImage(files || null) + }, + multiple: false, + }); + + + const validationSchema = Yup.object().shape({ + tagName: Yup.string() + .required('Tag name is required') + .min(1, 'Tag name must be at least 1 character') + .max(100, 'Tag name must be less than 100 characters'), + tagDescription: Yup.string() + .max(500, 'Description must be less than 500 characters'), + }); + + return ( + onSubmit(values, image || undefined)} + enableReinitialize + > + {({ handleChange, handleSubmit, values, setFieldValue, errors, touched, setFieldValue: formikSetFieldValue, resetForm }) => { + // Clear form when screen comes into focus + const clearForm = useCallback(() => { + setImage(null); + + setIsDashboardTagChecked(false); + resetForm(); + }, [resetForm]); + + useFocusCallback(clearForm); + + return ( + + + + + + {/* Image Upload Section */} + + + Tag Image {mode === 'edit' ? '(Upload new to replace)' : '(Optional)'} + + + + setImage(null)} + /> + + + {/* Dashboard Tag Checkbox */} + + { + const newValue = !isDashboardTagChecked; + setIsDashboardTagChecked(newValue); + formikSetFieldValue('isDashboardTag', newValue); + }} + /> + Mark as Dashboard Tag + + + handleSubmit()} + disabled={isLoading} + style={tw`px-4 py-3 rounded-lg shadow-lg items-center ${isLoading ? 'bg-gray-400' : 'bg-blue-500'}`} + > + + {isLoading ? (mode === 'create' ? 'Creating...' : 'Updating...') : (mode === 'create' ? 'Create Tag' : 'Update Tag')} + + + + ); + }} + + ); +}); + +TagForm.displayName = 'TagForm'; + +export default TagForm; \ No newline at end of file diff --git a/apps/admin-ui/src/components/TagMenu.tsx b/apps/admin-ui/src/components/TagMenu.tsx new file mode 100644 index 0000000..197d917 --- /dev/null +++ b/apps/admin-ui/src/components/TagMenu.tsx @@ -0,0 +1,119 @@ +import React, { useState } from 'react'; +import { View, TouchableOpacity, Alert } from 'react-native'; +import { Entypo } from '@expo/vector-icons'; +import { MyText, tw, BottomDialog } from 'common-ui'; +import { useRouter } from 'expo-router'; +import { useDeleteTag } from '../api-hooks/tag.api'; + +export interface TagMenuProps { + tagId: number; + onDeleteSuccess?: () => void; + triggerStyle?: any; + iconSize?: number; + iconColor?: string; +} + +export const TagMenu: React.FC = ({ + tagId, + onDeleteSuccess, + triggerStyle = tw`p-2 rounded-full bg-gray-50`, + iconSize = 16, + iconColor = '#6B7280', +}) => { + const [isOpen, setIsOpen] = useState(false); + const router = useRouter(); + const { mutate: deleteTag, isPending: isDeleting } = useDeleteTag(); + + const handleOpenMenu = () => { + setIsOpen(true); + }; + + const handleCloseMenu = () => { + setIsOpen(false); + }; + + const handleEditTag = () => { + setIsOpen(false); + router.push(`/(drawer)/edit-tag?tagId=${tagId}`); + }; + + const handleDeleteTag = () => { + setIsOpen(false); + Alert.alert( + 'Delete Tag', + 'Are you sure you want to delete this tag? This action cannot be undone.', + [ + { text: 'Cancel', style: 'cancel' }, + { + text: 'Delete', + style: 'destructive', + onPress: () => performDelete(), + } + ] + ); + }; + + const performDelete = () => { + deleteTag(tagId, { + onSuccess: () => { + Alert.alert('Success', 'Tag deleted successfully'); + onDeleteSuccess?.(); + }, + onError: (error: any) => { + const errorMessage = error.message || 'Failed to delete tag'; + Alert.alert('Error', errorMessage); + }, + }); + }; + + const options = [ + { + title: 'Edit Tag', + icon: 'edit' as keyof typeof Entypo.glyphMap, + onPress: handleEditTag, + }, + { + title: 'Delete Tag', + icon: 'trash' as keyof typeof Entypo.glyphMap, + onPress: handleDeleteTag, + }, + ]; + + return ( + <> + {/* Menu Trigger */} + + + + + {/* Menu Dialog */} + + + + Tag Options + + + {options.map((option, index) => ( + + + + {option.title} + + + ))} + + + + ); +}; \ No newline at end of file diff --git a/apps/admin-ui/src/trpc-client.ts b/apps/admin-ui/src/trpc-client.ts new file mode 100644 index 0000000..de7535a --- /dev/null +++ b/apps/admin-ui/src/trpc-client.ts @@ -0,0 +1,37 @@ +import { createTRPCProxyClient, httpBatchLink, TRPCClientError } from '@trpc/client'; +import { createTRPCReact } from '@trpc/react-query'; +import {AppRouter} from '../../backend/src/trpc/router' +import { BASE_API_URL } from 'common-ui'; +import { getJWT } from '@/hooks/useJWT'; +import { FORCE_LOGOUT_EVENT } from 'common-ui/src/lib/const-strs'; +import { DeviceEventEmitter } from 'react-native'; + +// Create tRPC React hooks without strict typing for now +export const trpc = createTRPCReact(); + +// Create tRPC client for direct usage +export const trpcClient = createTRPCProxyClient({ + links: [ + httpBatchLink({ + url: BASE_API_URL+'/api/trpc', + headers: async () => { + const token = await getJWT(); + return token ? { Authorization: `Bearer ${token}` } : {}; + }, + fetch: async (url, options) => { + const response = await fetch(url, options); + if (response.status === 401) { + const data = await response.clone().json().catch(() => ({})); + let code = ''; + if(data[0]?.error || data?.error) { + code = data[0]?.error?.message || data?.error?.message + } + if (code === 'UNAUTHORIZED') { + DeviceEventEmitter.emit(FORCE_LOGOUT_EVENT); + } + } + return response; + }, + }), + ], +}); \ No newline at end of file diff --git a/apps/admin-ui/tsconfig.json b/apps/admin-ui/tsconfig.json new file mode 100755 index 0000000..95f05c9 --- /dev/null +++ b/apps/admin-ui/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "expo/tsconfig.base", + "compilerOptions": { + "strict": true, + "paths": { + "@/*": [ + "./*" + ], + "shared-types": ["../shared-types"], + "common-ui": ["../../packages/ui"], + "common-ui/*": ["../../packages/ui/*"] + }, + "moduleSuffixes": [".ios", ".android", ".native", ".web", ""] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ".expo/types/**/*.ts", + "expo-env.d.ts" + ] +} diff --git a/apps/admin-ui/utils/getCurrentUserId.ts b/apps/admin-ui/utils/getCurrentUserId.ts new file mode 100755 index 0000000..d2a8af4 --- /dev/null +++ b/apps/admin-ui/utils/getCurrentUserId.ts @@ -0,0 +1,14 @@ +import {jwtDecode} from 'jwt-decode'; +import { getJWT } from '@/hooks/useJWT'; + +export async function getCurrentUserId(): Promise { + const token = await getJWT(); + if (!token) return null; + try { + const decoded: any = jwtDecode(token); + // Adjust this if your JWT uses a different field for user id + return decoded.id || decoded.userId || null; + } catch { + return null; + } +} diff --git a/apps/admin-ui/utils/queryClient.ts b/apps/admin-ui/utils/queryClient.ts new file mode 100755 index 0000000..c725dcf --- /dev/null +++ b/apps/admin-ui/utils/queryClient.ts @@ -0,0 +1,10 @@ +import { QueryClient } from '@tanstack/react-query'; + +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + retry: 3, + } + } +}); +export default queryClient; diff --git a/apps/admin-ui/withPhonepe.js b/apps/admin-ui/withPhonepe.js new file mode 100755 index 0000000..a678b70 --- /dev/null +++ b/apps/admin-ui/withPhonepe.js @@ -0,0 +1,28 @@ +const { withProjectBuildGradle } = require("@expo/config-plugins"); + +const withPhonePeRepository = (config) => { + return withProjectBuildGradle(config, (mod) => { + // Check if the maven repository already exists to prevent duplicates + if ( + mod.modResults.contents.includes( + "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android" + ) + ) { + return mod; + } + + // Use a regular expression to find the allprojects repositories block + const allprojectsRegex = /allprojects\s*\{\s*repositories\s*\{/s; + + mod.modResults.contents = mod.modResults.contents.replace( + allprojectsRegex, + (match) => { + return `${match}\n maven { url "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android" }`; + } + ); + + return mod; + }); +}; + +module.exports = withPhonePeRepository; diff --git a/apps/backend/.dockerignore b/apps/backend/.dockerignore new file mode 100755 index 0000000..e61f512 --- /dev/null +++ b/apps/backend/.dockerignore @@ -0,0 +1,19 @@ +node_modules +npm-debug.log +.git +.gitignore +README.md +.env +.nyc_output +coverage +.nyc_output +.coverage +.vscode +.DS_Store +logs +*.log +dist +build +*.md +docker-compose.yml +docker-compose.yaml \ No newline at end of file diff --git a/apps/backend/.env b/apps/backend/.env new file mode 100755 index 0000000..c9f78c2 --- /dev/null +++ b/apps/backend/.env @@ -0,0 +1,31 @@ + +# DATABASE_URL=postgresql://postgres:postgres_shafi_password@57.128.212.174:6432/meatfarmer #technocracy +DATABASE_URL=postgres://postgres:postgres_shafi_password@5.223.55.14:6432/meatfarmer #hetzner +PHONE_PE_BASE_URL=https://api-preprod.phonepe.com/ +PHONE_PE_CLIENT_ID=TEST-M23F2IGP34ZAR_25090 +PHONE_PE_CLIENT_VERSION=1 +PHONE_PE_CLIENT_SECRET=MTU1MmIzOTgtM2Q0Mi00N2M5LTkyMWUtNzBiMjdmYzVmZWUy +PHONE_PE_MERCHANT_ID=M23F2IGP34ZAR + +# S3_REGION=ap-hyderabad-1 +# S3_REGION=sgp +# S3_ACCESS_KEY_ID=52932a33abce40b38b559dadccab640f +# S3_SECRET_ACCESS_KEY=d287998b696d4a1c912e727f6394e53b +# S3_URL=https://s3.sgp.io.cloud.ovh.net/ +# S3_BUCKET_NAME=theobjectstore +S3_REGION=apac +S3_ACCESS_KEY_ID=8fab47503efb9547b50e4fb317e35cc7 +S3_SECRET_ACCESS_KEY=47c2eb5636843cf568dda7ad0959a3e42071303f26dbdff94bd45a3c33dcd950 +S3_URL=https://da9b1aa7c1951c23e2c0c3246ba68a58.r2.cloudflarestorage.com +S3_BUCKET_NAME=meatfarmer +EXPO_ACCESS_TOKEN=Asvpy8cByRh6T4ksnWScO6PLcio2n35-BwES5zK- +JWT_SECRET=my_meatfarmer_jwt_secret_key +# REDIS_URL=redis://default:redis_shafi_password@57.128.212.174:6379 +REDIS_URL=redis://default:redis_shafi_password@5.223.55.14:6379 +APP_URL=http://localhost:4000 +RAZORPAY_KEY=rzp_test_RdCBBUJ56NLaJK +RAZORPAY_SECRET=namEwKBE1ypWxH0QDVg6fWOe +OTP_SENDER_AUTH_TOKEN=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJDLTM5OENEMkJDRTM0MjQ4OCIsImlhdCI6MTc0Nzg0MTEwMywiZXhwIjoxOTA1NTIxMTAzfQ.IV64ofVKjcwveIanxu_P2XlACtPeA9sJQ74uM53osDeyUXsFv0rwkCl6NNBIX93s_wnh4MKITLbcF_ClwmFQ0A + +MIN_ORDER_VALUE=300 +DELIVERY_CHARGE=20 \ No newline at end of file diff --git a/apps/backend/.env.example b/apps/backend/.env.example new file mode 100755 index 0000000..28aca25 --- /dev/null +++ b/apps/backend/.env.example @@ -0,0 +1,22 @@ +# Database +DATABASE_URL=postgres://postgres:h3alth_p3tal_db_p@ssw0rd@localhost:5432/health_petal + +# JWT +JWT_SECRET=your-super-secret-jwt-key + +# AWS S3 (for profile pictures and hospital images) +S3_ACCESS_KEY_ID=your-s3-access-key +S3_SECRET_ACCESS_KEY=your-s3-secret-key +S3_BUCKET_NAME=your-s3-bucket-name +S3_REGION=your-s3-region +S3_URL=your-s3-url + +# Expo (for push notifications) +EXPO_ACCESS_TOKEN=your-expo-access-token + +# PhonePe Payment Gateway +PHONE_PE_BASE_URL=https://api-preprod.phonepe.com/ +PHONE_PE_CLIENT_ID=your-phonepe-client-id +PHONE_PE_CLIENT_VERSION=1 +PHONE_PE_CLIENT_SECRET=your-phonepe-client-secret +PHONE_PE_MERCHANT_ID=your-phonepe-merchant-id \ No newline at end of file diff --git a/apps/backend/Dockerfile b/apps/backend/Dockerfile new file mode 100755 index 0000000..fce5fd9 --- /dev/null +++ b/apps/backend/Dockerfile @@ -0,0 +1,70 @@ +# Dockerfile for backend service + +# 1. ---- Base Node image +FROM node:20-slim AS base +WORKDIR /app + +# 2. ---- Pruner ---- +# This stage creates a pruned version of the monorepo that only contains +# the files and dependencies required to build the 'backend' and 'admin-ui' services. +FROM base AS pruner +WORKDIR /app +# Install turbo globally +RUN npm install -g turbo +# Copy all files from the context +COPY . . +# Prune the monorepo for the 'backend' and 'admin-ui' scopes +RUN turbo prune --scope=backend --scope=admin-ui --docker --scope=common-ui + +# 3. ---- Builder ---- +# This stage builds both the backend application and the admin-ui using the pruned files. +FROM base AS builder +WORKDIR /app + +# Copy the pruned source files, package.json files, and lockfile +# to create a stand-alone build environment. +COPY --from=pruner /app/out/full/ . +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/package-lock.json . +COPY --from=pruner /app/turbo.json . + +# Install all dependencies (including dev) to build the applications +RUN npm install + +# Build the backend application +RUN npx turbo build --filter=backend... + +# Build the admin-ui for web +WORKDIR /app/apps/admin-ui +RUN npx expo export --platform web --output-dir web-build +# Return to the root for the next stage +WORKDIR /app + +# 4. ---- Runner ---- +# This is the final, lean production image. +FROM base AS runner +WORKDIR /app + +# Set NODE_ENV to production +ENV NODE_ENV=production + +# Copy pruned package files and install only production dependencies +# The pruned output in /app/out/json contains the package.json files +# in their original directory structure. +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/package-lock.json ./package-lock.json +RUN npm ci --production + +# Copy the built application from the builder stage +# The builder stage contains the entire pruned monorepo with build artifacts. +# We only copy the necessary built files. +COPY --from=builder /app/apps/backend/dist ./apps/backend/dist + +# Copy the built admin-ui web files +COPY --from=builder /app/apps/admin-ui/web-build ./apps/backend/public/admin-ui-web + +# The application in apps/backend/index.ts listens on port 4000 +EXPOSE 4000 + +# The command to start the backend service +CMD ["node", "apps/backend/dist/index.js"] diff --git a/apps/backend/README.md b/apps/backend/README.md new file mode 100755 index 0000000..f032dc0 --- /dev/null +++ b/apps/backend/README.md @@ -0,0 +1,97 @@ +# Health Petal Database + +This project contains the database schema, seed data, and related tools for the Health Petal application. + +## Setup + +1. Make sure PostgreSQL is installed and running on your machine +2. Create a database named `health_petal` +3. Configure your `.env` file with the correct database credentials (or use the default ones) + +## Database Schema + +The database schema includes the following tables: +- profiles (users) +- role_info +- user_roles +- hospital +- specializations +- hospital_specializations +- hospital_employees +- doctor_info +- doctor_specializations +- doctor_secretaries +- doctor_availability +- token_info +- running_counter + +## Available Commands + +- `npm run migrate` - Generate SQL migration files +- `npm run db:push` - Push schema changes to the database +- `npm run db:seed` - Seed the database with mock data +- `npm run docker:build` - Build Docker image for the backend + +## Getting Started + +1. First, install dependencies: + ``` + npm install + ``` + +2. Set up the database: + ``` + # Create a PostgreSQL database + createdb health_petal + + # Generate and push the schema + npm run migrate + npm run db:push + + # Seed the database with test data + npm run db:seed + ``` + +3. Verify the data: + ```sql + -- Connect to the database + psql health_petal + + -- Check the tables + \dt + + -- Check users + SELECT * FROM profiles; + + -- Check doctors + SELECT p.name, p.email, d.qualifications, d.daily_token_count + FROM doctor_info d + JOIN profiles p ON d.user_id = p.id; + + -- Check doctor specializations + SELECT p.name, s.name as specialization + FROM doctor_specializations ds + JOIN doctor_info d ON ds.doctor_id = d.id + JOIN profiles p ON d.user_id = p.id + JOIN specializations s ON ds.specialization_id = s.id; + ``` + +## Docker + +This project includes Docker support for easy deployment: + +1. Build the Docker image: + ``` + npm run docker:build + ``` + +2. Run with Docker Compose (includes PostgreSQL database): + ``` + docker-compose up -d + ``` + +The Docker Compose setup includes: +- PostgreSQL database with the correct schema +- Backend application with all environment variables configured + +Note: For production deployment, make sure to update the environment variables in docker-compose.yml with your actual values. diff --git a/apps/backend/assets/demo.txt b/apps/backend/assets/demo.txt new file mode 100755 index 0000000..5d1cdef --- /dev/null +++ b/apps/backend/assets/demo.txt @@ -0,0 +1,6 @@ +I have a mobile app meant for online shopping. People can shop for meat, fruits and dry fruits. +my major colors are #F83758 and #fff0f6. I want just an info web site. I want the website +to tell people that we sell the trust of local and the convenience of online. I want to highlight +the process of selling. the steps are Find products, select a delivery slot, and get order delivered +I want the site to be a jolly and fun theme one baked primarily in the colors I've given. Make +it a node js app with pug and a statically rendered home page. \ No newline at end of file diff --git a/apps/backend/assets/farm2door-logo.png b/apps/backend/assets/farm2door-logo.png new file mode 100644 index 0000000..95f9b8b Binary files /dev/null and b/apps/backend/assets/farm2door-logo.png differ diff --git a/apps/backend/assets/signed-url-cache.json b/apps/backend/assets/signed-url-cache.json new file mode 100644 index 0000000..f7830f5 --- /dev/null +++ b/apps/backend/assets/signed-url-cache.json @@ -0,0 +1 @@ +{"originalToSigned":{},"signedToOriginal":{}} \ No newline at end of file diff --git a/apps/backend/docker-compose.yml b/apps/backend/docker-compose.yml new file mode 100755 index 0000000..c99e65e --- /dev/null +++ b/apps/backend/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3.8' + +services: + db: + image: postgres:15 + container_name: health_petal_db + restart: always + environment: + POSTGRES_DB: health_petal + POSTGRES_USER: postgres + POSTGRES_PASSWORD: h3alth_p3tal_db_p@ssw0rd + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + + backend: + build: + context: . + dockerfile: Dockerfile + container_name: health_petal_backend + restart: always + ports: + - "4000:4000" + environment: + - DATABASE_URL=postgres://postgres:h3alth_p3tal_db_p@ssw0rd@db:5432/health_petal + - JWT_SECRET=your-jwt-secret-here + - S3_ACCESS_KEY_ID=d94e2444086b740afa411a95a6d1abffe08dc69c + - S3_SECRET_ACCESS_KEY=VA5pi0NrnST7OG+zCqJIhSrhdRHwanFA+saJO5QoebQ= + - S3_BUCKET_NAME=health-petal + - S3_REGION=ap-hyderabad-1 + - S3_URL=https://axwzpqa4dwjl.compat.objectstorage.ap-hyderabad-1.oraclecloud.com/ + - EXPO_ACCESS_TOKEN=your-expo-access-token + - PHONE_PE_BASE_URL=https://api-preprod.phonepe.com/ + - PHONE_PE_CLIENT_ID=TEST-M23F2IGP34ZAR_25090 + - PHONE_PE_CLIENT_VERSION=1 + - PHONE_PE_CLIENT_SECRET=MTU1MmIzOTgtM2Q0Mi00N2M5LTkyMWUtNzBiMjdmYzVmZWUy + - PHONE_PE_MERCHANT_ID=M23F2IGP34ZAR + depends_on: + - db + volumes: + - ./logs:/app/logs + +volumes: + postgres_data: \ No newline at end of file diff --git a/apps/backend/drizzle.config.ts b/apps/backend/drizzle.config.ts new file mode 100755 index 0000000..0b5c1c9 --- /dev/null +++ b/apps/backend/drizzle.config.ts @@ -0,0 +1,11 @@ +import 'dotenv/config'; +import { defineConfig } from 'drizzle-kit'; + +export default defineConfig({ + out: './drizzle', + schema: './src/db/schema.ts', + dialect: 'postgresql', + dbCredentials: { + url: process.env.DATABASE_URL!, + }, +}); diff --git a/apps/backend/drizzle/0000_colorful_tinkerer.sql b/apps/backend/drizzle/0000_colorful_tinkerer.sql new file mode 100644 index 0000000..49fc610 --- /dev/null +++ b/apps/backend/drizzle/0000_colorful_tinkerer.sql @@ -0,0 +1,124 @@ +CREATE TYPE "public"."order_status" AS ENUM('pending', 'delivered', 'cancelled');--> statement-breakpoint +CREATE TABLE "mf"."addresses" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."addresses_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "address" varchar(500) NOT NULL, + "is_default" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."cart_items" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."cart_items_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "product_id" integer NOT NULL, + "quantity" numeric(10, 2) NOT NULL, + "added_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_user_product" UNIQUE("user_id","product_id") +); +--> statement-breakpoint +CREATE TABLE "mf"."delivery_slot_info" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."delivery_slot_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "deliveryTime" timestamp NOT NULL, + "freezeTime" timestamp NOT NULL, + "is_active" boolean DEFAULT true NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."notifications" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."notifications_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "title" varchar(255) NOT NULL, + "body" varchar(512) NOT NULL, + "type" varchar(50), + "is_read" boolean DEFAULT false NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."order_items" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."order_items_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "order_id" integer NOT NULL, + "product_id" integer NOT NULL, + "quantity" numeric(10, 2) NOT NULL, + "price" numeric(10, 2) NOT NULL, + "amount" numeric(10, 2) NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."orders" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."orders_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "address_id" integer NOT NULL, + "slot_id" integer NOT NULL, + "total_amount" numeric(10, 2) NOT NULL, + "status" "order_status" DEFAULT 'pending' NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."payments" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."payments_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "order_id" integer NOT NULL, + "status" varchar(50) NOT NULL, + "gateway" varchar(50) NOT NULL, + "gateway_order_id" varchar(255), + "amount" numeric(10, 2) NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."product_categories" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_categories_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "name" varchar(255) NOT NULL, + "description" varchar(500) +); +--> statement-breakpoint +CREATE TABLE "mf"."product_info" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "name" varchar(255) NOT NULL, + "short_description" varchar(500), + "long_description" varchar(1000), + "unit_id" integer NOT NULL, + "price" numeric(10, 2) NOT NULL, + "images" jsonb, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."product_slots" ( + "product_id" integer NOT NULL, + "slot_id" integer NOT NULL, + CONSTRAINT "product_slot_pk" UNIQUE("product_id","slot_id") +); +--> statement-breakpoint +CREATE TABLE "mf"."special_deals" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."special_deals_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "product_id" integer NOT NULL, + "quantity" numeric(10, 2) NOT NULL, + "price" numeric(10, 2) NOT NULL, + "valid_till" timestamp NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."units" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."units_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "short_notation" varchar(50) NOT NULL, + "full_name" varchar(100) NOT NULL, + CONSTRAINT "unique_short_notation" UNIQUE("short_notation") +); +--> statement-breakpoint +CREATE TABLE "mf"."users" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "name" varchar(255) NOT NULL, + "email" varchar(255), + "mobile" varchar(255), + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_email" UNIQUE("email") +); +--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD CONSTRAINT "addresses_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."cart_items" ADD CONSTRAINT "cart_items_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."cart_items" ADD CONSTRAINT "cart_items_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."notifications" ADD CONSTRAINT "notifications_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."order_items" ADD CONSTRAINT "order_items_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."order_items" ADD CONSTRAINT "order_items_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD CONSTRAINT "orders_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD CONSTRAINT "orders_address_id_addresses_id_fk" FOREIGN KEY ("address_id") REFERENCES "mf"."addresses"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD CONSTRAINT "orders_slot_id_delivery_slot_info_id_fk" FOREIGN KEY ("slot_id") REFERENCES "mf"."delivery_slot_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."payments" ADD CONSTRAINT "payments_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_info" ADD CONSTRAINT "product_info_unit_id_units_id_fk" FOREIGN KEY ("unit_id") REFERENCES "mf"."units"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_slots" ADD CONSTRAINT "product_slots_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_slots" ADD CONSTRAINT "product_slots_slot_id_delivery_slot_info_id_fk" FOREIGN KEY ("slot_id") REFERENCES "mf"."delivery_slot_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."special_deals" ADD CONSTRAINT "special_deals_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0001_busy_titania.sql b/apps/backend/drizzle/0001_busy_titania.sql new file mode 100644 index 0000000..6d2f646 --- /dev/null +++ b/apps/backend/drizzle/0001_busy_titania.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."delivery_slot_info" RENAME COLUMN "deliveryTime" TO "delivery_time";--> statement-breakpoint +ALTER TABLE "mf"."delivery_slot_info" RENAME COLUMN "freezeTime" TO "freeze_time"; \ No newline at end of file diff --git a/apps/backend/drizzle/0002_wandering_lifeguard.sql b/apps/backend/drizzle/0002_wandering_lifeguard.sql new file mode 100644 index 0000000..e5b41f7 --- /dev/null +++ b/apps/backend/drizzle/0002_wandering_lifeguard.sql @@ -0,0 +1,9 @@ +CREATE TABLE "mf"."user_creds" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."user_creds_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "user_password" varchar(255) NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_user_cred" UNIQUE("user_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."user_creds" ADD CONSTRAINT "user_creds_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0003_tricky_the_twelve.sql b/apps/backend/drizzle/0003_tricky_the_twelve.sql new file mode 100644 index 0000000..986274b --- /dev/null +++ b/apps/backend/drizzle/0003_tricky_the_twelve.sql @@ -0,0 +1,41 @@ +CREATE TABLE "mf"."order_status" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."order_status_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "order_time" timestamp DEFAULT now() NOT NULL, + "user_id" integer NOT NULL, + "order_id" integer NOT NULL, + "is_packaged" boolean DEFAULT false NOT NULL, + "is_delivered" boolean DEFAULT false NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."payment_info" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."payment_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "status" varchar(50) NOT NULL, + "gateway" varchar(50) NOT NULL, + "order_id" varchar(500), + "token" varchar(500), + "merchant_order_id" varchar(255) NOT NULL, + "payload" jsonb, + CONSTRAINT "payment_info_merchant_order_id_unique" UNIQUE("merchant_order_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."order_items" ALTER COLUMN "quantity" SET DATA TYPE varchar(50);--> statement-breakpoint +ALTER TABLE "mf"."orders" ALTER COLUMN "slot_id" DROP NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "name" varchar(255) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "phone" varchar(15) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "address_line1" varchar(255) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "address_line2" varchar(255);--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "city" varchar(100) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "state" varchar(100) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "pincode" varchar(10) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "latitude" real;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "longitude" real;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD COLUMN "is_cod" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD COLUMN "is_online_payment" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD COLUMN "payment_info_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD CONSTRAINT "order_status_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD CONSTRAINT "order_status_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD CONSTRAINT "orders_payment_info_id_payment_info_id_fk" FOREIGN KEY ("payment_info_id") REFERENCES "mf"."payment_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."addresses" DROP COLUMN "address";--> statement-breakpoint +ALTER TABLE "mf"."order_items" DROP COLUMN "amount";--> statement-breakpoint +ALTER TABLE "mf"."orders" DROP COLUMN "status";--> statement-breakpoint +DROP TYPE "public"."order_status"; \ No newline at end of file diff --git a/apps/backend/drizzle/0004_lively_diamondback.sql b/apps/backend/drizzle/0004_lively_diamondback.sql new file mode 100644 index 0000000..aeaf5c3 --- /dev/null +++ b/apps/backend/drizzle/0004_lively_diamondback.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."order_status" ADD COLUMN "is_cancelled" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0005_tricky_warhawk.sql b/apps/backend/drizzle/0005_tricky_warhawk.sql new file mode 100644 index 0000000..0ae296b --- /dev/null +++ b/apps/backend/drizzle/0005_tricky_warhawk.sql @@ -0,0 +1,13 @@ +CREATE TABLE "mf"."key_val_store" ( + "key" varchar(255) PRIMARY KEY NOT NULL, + "value" jsonb +); +--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD COLUMN "readable_id" integer NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."payments" ADD COLUMN "token" varchar(500);--> statement-breakpoint +ALTER TABLE "mf"."payments" ADD COLUMN "merchant_order_id" varchar(255) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."payments" ADD COLUMN "payload" jsonb;--> statement-breakpoint +ALTER TABLE "mf"."payments" DROP COLUMN "gateway_order_id";--> statement-breakpoint +ALTER TABLE "mf"."payments" DROP COLUMN "amount";--> statement-breakpoint +ALTER TABLE "mf"."payments" DROP COLUMN "created_at";--> statement-breakpoint +ALTER TABLE "mf"."payments" ADD CONSTRAINT "payments_merchant_order_id_unique" UNIQUE("merchant_order_id"); \ No newline at end of file diff --git a/apps/backend/drizzle/0006_outstanding_joystick.sql b/apps/backend/drizzle/0006_outstanding_joystick.sql new file mode 100644 index 0000000..9c764dc --- /dev/null +++ b/apps/backend/drizzle/0006_outstanding_joystick.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."order_status" ADD COLUMN "cancel_reason" varchar(255);--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD COLUMN "is_refund_done" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0007_yellow_charles_xavier.sql b/apps/backend/drizzle/0007_yellow_charles_xavier.sql new file mode 100644 index 0000000..4847280 --- /dev/null +++ b/apps/backend/drizzle/0007_yellow_charles_xavier.sql @@ -0,0 +1,11 @@ +CREATE TABLE "mf"."complaints" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."complaints_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "order_id" integer, + "complaint_body" varchar(1000) NOT NULL, + "is_resolved" boolean DEFAULT false NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."complaints" ADD CONSTRAINT "complaints_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."complaints" ADD CONSTRAINT "complaints_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0008_nasty_mathemanic.sql b/apps/backend/drizzle/0008_nasty_mathemanic.sql new file mode 100644 index 0000000..5bd2f03 --- /dev/null +++ b/apps/backend/drizzle/0008_nasty_mathemanic.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."product_info" ADD COLUMN "is_out_of_stock" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0009_peaceful_victor_mancha.sql b/apps/backend/drizzle/0009_peaceful_victor_mancha.sql new file mode 100644 index 0000000..c0cb3f4 --- /dev/null +++ b/apps/backend/drizzle/0009_peaceful_victor_mancha.sql @@ -0,0 +1,9 @@ +CREATE TABLE "mf"."staff_users" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."staff_users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "name" varchar(255) NOT NULL, + "password" varchar(255) NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."user_creds" DROP CONSTRAINT "unique_user_cred";--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "created_at" timestamp DEFAULT now() NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0010_flimsy_reavers.sql b/apps/backend/drizzle/0010_flimsy_reavers.sql new file mode 100644 index 0000000..dcef34c --- /dev/null +++ b/apps/backend/drizzle/0010_flimsy_reavers.sql @@ -0,0 +1,15 @@ +CREATE TABLE "mf"."coupons" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."coupons_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "is_user_based" boolean DEFAULT false NOT NULL, + "discount_percent" numeric(5, 2), + "flat_discount" numeric(10, 2), + "min_order" numeric(10, 2), + "target_user" integer, + "created_by" integer NOT NULL, + "max_value" numeric(10, 2), + "is_invalidated" boolean DEFAULT false NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."coupons" ADD CONSTRAINT "coupons_target_user_users_id_fk" FOREIGN KEY ("target_user") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupons" ADD CONSTRAINT "coupons_created_by_staff_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "mf"."staff_users"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0011_watery_lady_mastermind.sql b/apps/backend/drizzle/0011_watery_lady_mastermind.sql new file mode 100644 index 0000000..49f3b04 --- /dev/null +++ b/apps/backend/drizzle/0011_watery_lady_mastermind.sql @@ -0,0 +1,3 @@ +ALTER TABLE "mf"."coupons" ADD COLUMN "is_apply_for_all" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."coupons" ADD COLUMN "valid_till" timestamp;--> statement-breakpoint +ALTER TABLE "mf"."coupons" ADD COLUMN "max_limit_for_user" integer; \ No newline at end of file diff --git a/apps/backend/drizzle/0012_flawless_jubilee.sql b/apps/backend/drizzle/0012_flawless_jubilee.sql new file mode 100644 index 0000000..f4fb56d --- /dev/null +++ b/apps/backend/drizzle/0012_flawless_jubilee.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."coupons" ADD COLUMN "coupon_code" varchar(50) NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."coupons" ADD CONSTRAINT "unique_coupon_code" UNIQUE("coupon_code"); \ No newline at end of file diff --git a/apps/backend/drizzle/0013_married_celestials.sql b/apps/backend/drizzle/0013_married_celestials.sql new file mode 100644 index 0000000..0844f4f --- /dev/null +++ b/apps/backend/drizzle/0013_married_celestials.sql @@ -0,0 +1,9 @@ +CREATE TABLE "mf"."coupon_usage" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."coupon_usage_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "coupon_id" integer NOT NULL, + "used_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."coupon_usage" ADD CONSTRAINT "coupon_usage_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupon_usage" ADD CONSTRAINT "coupon_usage_coupon_id_coupons_id_fk" FOREIGN KEY ("coupon_id") REFERENCES "mf"."coupons"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0014_blushing_switch.sql b/apps/backend/drizzle/0014_blushing_switch.sql new file mode 100644 index 0000000..390e55b --- /dev/null +++ b/apps/backend/drizzle/0014_blushing_switch.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."delivery_slot_info" ADD COLUMN "delivery_sequence" jsonb; \ No newline at end of file diff --git a/apps/backend/drizzle/0015_sloppy_boomerang.sql b/apps/backend/drizzle/0015_sloppy_boomerang.sql new file mode 100644 index 0000000..5def26e --- /dev/null +++ b/apps/backend/drizzle/0015_sloppy_boomerang.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."complaints" ADD COLUMN "response" varchar(1000); \ No newline at end of file diff --git a/apps/backend/drizzle/0016_eminent_thunderbolt_ross.sql b/apps/backend/drizzle/0016_eminent_thunderbolt_ross.sql new file mode 100644 index 0000000..41056da --- /dev/null +++ b/apps/backend/drizzle/0016_eminent_thunderbolt_ross.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."coupons" ADD COLUMN "product_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."coupons" ADD CONSTRAINT "coupons_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0017_steady_moira_mactaggert.sql b/apps/backend/drizzle/0017_steady_moira_mactaggert.sql new file mode 100644 index 0000000..c4b644c --- /dev/null +++ b/apps/backend/drizzle/0017_steady_moira_mactaggert.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."coupons" RENAME COLUMN "product_id" TO "product_ids";--> statement-breakpoint +ALTER TABLE "mf"."coupons" DROP CONSTRAINT "coupons_product_id_product_info_id_fk"; diff --git a/apps/backend/drizzle/0018_simple_tomorrow_man.sql b/apps/backend/drizzle/0018_simple_tomorrow_man.sql new file mode 100644 index 0000000..47e5e68 --- /dev/null +++ b/apps/backend/drizzle/0018_simple_tomorrow_man.sql @@ -0,0 +1,13 @@ +CREATE TABLE "mf"."user_details" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."user_details_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "bio" varchar(500), + "date_of_birth" date, + "gender" varchar(20), + "occupation" varchar(100), + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "user_details_user_id_unique" UNIQUE("user_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."user_details" ADD CONSTRAINT "user_details_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0019_productive_mulholland_black.sql b/apps/backend/drizzle/0019_productive_mulholland_black.sql new file mode 100644 index 0000000..4b6b5ef --- /dev/null +++ b/apps/backend/drizzle/0019_productive_mulholland_black.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."user_details" ADD COLUMN "profile_image" varchar(500); \ No newline at end of file diff --git a/apps/backend/drizzle/0020_narrow_charles_xavier.sql b/apps/backend/drizzle/0020_narrow_charles_xavier.sql new file mode 100644 index 0000000..721e7bb --- /dev/null +++ b/apps/backend/drizzle/0020_narrow_charles_xavier.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."product_info" ADD COLUMN "market_price" numeric(10, 2); \ No newline at end of file diff --git a/apps/backend/drizzle/0021_little_spot.sql b/apps/backend/drizzle/0021_little_spot.sql new file mode 100644 index 0000000..7507a93 --- /dev/null +++ b/apps/backend/drizzle/0021_little_spot.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."orders" ADD COLUMN "cancellation_reviewed" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD COLUMN "admin_notes" text; \ No newline at end of file diff --git a/apps/backend/drizzle/0022_flippant_omega_sentinel.sql b/apps/backend/drizzle/0022_flippant_omega_sentinel.sql new file mode 100644 index 0000000..054c0fc --- /dev/null +++ b/apps/backend/drizzle/0022_flippant_omega_sentinel.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."orders" ADD COLUMN "is_refund_done" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0023_sparkling_starjammers.sql b/apps/backend/drizzle/0023_sparkling_starjammers.sql new file mode 100644 index 0000000..bdb19fb --- /dev/null +++ b/apps/backend/drizzle/0023_sparkling_starjammers.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."orders" ADD COLUMN "user_notes" text; \ No newline at end of file diff --git a/apps/backend/drizzle/0024_typical_the_twelve.sql b/apps/backend/drizzle/0024_typical_the_twelve.sql new file mode 100644 index 0000000..b266835 --- /dev/null +++ b/apps/backend/drizzle/0024_typical_the_twelve.sql @@ -0,0 +1,11 @@ +CREATE TABLE "mf"."vendor_snippets" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."vendor_snippets_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "snippet_code" varchar(255) NOT NULL, + "slot_id" integer NOT NULL, + "product_ids" integer[] NOT NULL, + "valid_till" timestamp, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "vendor_snippets_snippet_code_unique" UNIQUE("snippet_code") +); +--> statement-breakpoint +ALTER TABLE "mf"."vendor_snippets" ADD CONSTRAINT "vendor_snippets_slot_id_delivery_slot_info_id_fk" FOREIGN KEY ("slot_id") REFERENCES "mf"."delivery_slot_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0025_tricky_plazm.sql b/apps/backend/drizzle/0025_tricky_plazm.sql new file mode 100644 index 0000000..1d6a3be --- /dev/null +++ b/apps/backend/drizzle/0025_tricky_plazm.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."order_status" ADD COLUMN "is_payment_processed" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0026_flippant_spiral.sql b/apps/backend/drizzle/0026_flippant_spiral.sql new file mode 100644 index 0000000..96c1557 --- /dev/null +++ b/apps/backend/drizzle/0026_flippant_spiral.sql @@ -0,0 +1,2 @@ +CREATE TYPE "public"."payment_status" AS ENUM('pending', 'success', 'cod', 'failed');--> statement-breakpoint +ALTER TABLE "mf"."order_status" RENAME COLUMN "is_payment_processed" TO "payment_status"; \ No newline at end of file diff --git a/apps/backend/drizzle/0027_huge_iron_monger.sql b/apps/backend/drizzle/0027_huge_iron_monger.sql new file mode 100644 index 0000000..12219b2 --- /dev/null +++ b/apps/backend/drizzle/0027_huge_iron_monger.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."order_status" ADD COLUMN "payment_state" "payment_status" DEFAULT 'pending' NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."order_status" DROP COLUMN "payment_status"; \ No newline at end of file diff --git a/apps/backend/drizzle/0028_clever_anthem.sql b/apps/backend/drizzle/0028_clever_anthem.sql new file mode 100644 index 0000000..b9824cf --- /dev/null +++ b/apps/backend/drizzle/0028_clever_anthem.sql @@ -0,0 +1,10 @@ +CREATE TABLE "mf"."notif_creds" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."notif_creds_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "token" varchar(500) NOT NULL, + "added_at" timestamp DEFAULT now() NOT NULL, + "user_id" integer NOT NULL, + "last_verified" timestamp, + CONSTRAINT "notif_creds_token_unique" UNIQUE("token") +); +--> statement-breakpoint +ALTER TABLE "mf"."notif_creds" ADD CONSTRAINT "notif_creds_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0029_short_king_cobra.sql b/apps/backend/drizzle/0029_short_king_cobra.sql new file mode 100644 index 0000000..2c500d8 --- /dev/null +++ b/apps/backend/drizzle/0029_short_king_cobra.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."users" ALTER COLUMN "name" DROP NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0030_superb_exiles.sql b/apps/backend/drizzle/0030_superb_exiles.sql new file mode 100644 index 0000000..8403b55 --- /dev/null +++ b/apps/backend/drizzle/0030_superb_exiles.sql @@ -0,0 +1,11 @@ +CREATE TABLE "mf"."store_info" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."store_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "name" varchar(255) NOT NULL, + "description" varchar(500), + "created_at" timestamp DEFAULT now() NOT NULL, + "owner" integer NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."product_info" ADD COLUMN "store_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."store_info" ADD CONSTRAINT "store_info_owner_staff_users_id_fk" FOREIGN KEY ("owner") REFERENCES "mf"."staff_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_info" ADD CONSTRAINT "product_info_store_id_store_info_id_fk" FOREIGN KEY ("store_id") REFERENCES "mf"."store_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0031_clean_the_hunter.sql b/apps/backend/drizzle/0031_clean_the_hunter.sql new file mode 100644 index 0000000..30a5cd3 --- /dev/null +++ b/apps/backend/drizzle/0031_clean_the_hunter.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."product_info" ALTER COLUMN "store_id" SET NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0032_tricky_baron_zemo.sql b/apps/backend/drizzle/0032_tricky_baron_zemo.sql new file mode 100644 index 0000000..ea4b980 --- /dev/null +++ b/apps/backend/drizzle/0032_tricky_baron_zemo.sql @@ -0,0 +1,22 @@ +CREATE TABLE "mf"."order_cancellations" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."order_cancellations_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "order_id" integer NOT NULL, + "user_id" integer NOT NULL, + "reason" varchar(500), + "cancellation_user_notes" text, + "cancellation_admin_notes" text, + "cancellation_reviewed" boolean DEFAULT false NOT NULL, + "refund_amount" numeric(10, 2), + "refund_status" varchar(50) DEFAULT 'none', + "razorpay_refund_id" varchar(255), + "created_at" timestamp DEFAULT now() NOT NULL, + "reviewed_at" timestamp, + "refund_processed_at" timestamp, + CONSTRAINT "order_cancellations_order_id_unique" UNIQUE("order_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."order_cancellations" ADD CONSTRAINT "order_cancellations_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."order_cancellations" ADD CONSTRAINT "order_cancellations_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."order_status" DROP COLUMN "is_refund_done";--> statement-breakpoint +ALTER TABLE "mf"."orders" DROP COLUMN "cancellation_reviewed";--> statement-breakpoint +ALTER TABLE "mf"."orders" DROP COLUMN "is_refund_done"; \ No newline at end of file diff --git a/apps/backend/drizzle/0033_brainy_skullbuster.sql b/apps/backend/drizzle/0033_brainy_skullbuster.sql new file mode 100644 index 0000000..1bf156e --- /dev/null +++ b/apps/backend/drizzle/0033_brainy_skullbuster.sql @@ -0,0 +1,20 @@ +CREATE TABLE "mf"."product_tag_info" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_tag_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "tag_name" varchar(100) NOT NULL, + "tag_description" varchar(500), + "image_url" varchar(500), + "is_dashboard_tag" boolean DEFAULT false NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "product_tag_info_tag_name_unique" UNIQUE("tag_name") +); +--> statement-breakpoint +CREATE TABLE "mf"."product_tags" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_tags_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "product_id" integer NOT NULL, + "tag_id" integer NOT NULL, + "assigned_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_product_tag" UNIQUE("product_id","tag_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."product_tags" ADD CONSTRAINT "product_tags_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_tags" ADD CONSTRAINT "product_tags_tag_id_product_tag_info_id_fk" FOREIGN KEY ("tag_id") REFERENCES "mf"."product_tag_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0034_yummy_riptide.sql b/apps/backend/drizzle/0034_yummy_riptide.sql new file mode 100644 index 0000000..a9a87a8 --- /dev/null +++ b/apps/backend/drizzle/0034_yummy_riptide.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."coupon_usage" ADD COLUMN "order_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."coupon_usage" ADD CONSTRAINT "coupon_usage_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0035_lyrical_spencer_smythe.sql b/apps/backend/drizzle/0035_lyrical_spencer_smythe.sql new file mode 100644 index 0000000..4b96344 --- /dev/null +++ b/apps/backend/drizzle/0035_lyrical_spencer_smythe.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."coupons" ADD COLUMN "exclusive_apply" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0036_eager_naoko.sql b/apps/backend/drizzle/0036_eager_naoko.sql new file mode 100644 index 0000000..b3ef0e6 --- /dev/null +++ b/apps/backend/drizzle/0036_eager_naoko.sql @@ -0,0 +1,21 @@ +CREATE TABLE "mf"."coupon_applicable_products" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."coupon_applicable_products_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "coupon_id" integer NOT NULL, + "product_id" integer NOT NULL, + CONSTRAINT "unique_coupon_product" UNIQUE("coupon_id","product_id") +); +--> statement-breakpoint +CREATE TABLE "mf"."coupon_applicable_users" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."coupon_applicable_users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "coupon_id" integer NOT NULL, + "user_id" integer NOT NULL, + CONSTRAINT "unique_coupon_user" UNIQUE("coupon_id","user_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."coupon_usage" ADD COLUMN "order_item_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."order_items" ADD COLUMN "discounted_price" numeric(10, 2);--> statement-breakpoint +ALTER TABLE "mf"."coupon_applicable_products" ADD CONSTRAINT "coupon_applicable_products_coupon_id_coupons_id_fk" FOREIGN KEY ("coupon_id") REFERENCES "mf"."coupons"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupon_applicable_products" ADD CONSTRAINT "coupon_applicable_products_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupon_applicable_users" ADD CONSTRAINT "coupon_applicable_users_coupon_id_coupons_id_fk" FOREIGN KEY ("coupon_id") REFERENCES "mf"."coupons"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupon_applicable_users" ADD CONSTRAINT "coupon_applicable_users_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupon_usage" ADD CONSTRAINT "coupon_usage_order_item_id_order_items_id_fk" FOREIGN KEY ("order_item_id") REFERENCES "mf"."order_items"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0037_pale_outlaw_kid.sql b/apps/backend/drizzle/0037_pale_outlaw_kid.sql new file mode 100644 index 0000000..3e20dca --- /dev/null +++ b/apps/backend/drizzle/0037_pale_outlaw_kid.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."order_cancellations" RENAME COLUMN "razorpay_refund_id" TO "merchant_refund_id"; \ No newline at end of file diff --git a/apps/backend/drizzle/0038_volatile_jean_grey.sql b/apps/backend/drizzle/0038_volatile_jean_grey.sql new file mode 100644 index 0000000..7396d1f --- /dev/null +++ b/apps/backend/drizzle/0038_volatile_jean_grey.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."product_info" ADD COLUMN "is_suspended" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."user_details" ADD COLUMN "is_suspended" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0039_last_silver_samurai.sql b/apps/backend/drizzle/0039_last_silver_samurai.sql new file mode 100644 index 0000000..6a9292f --- /dev/null +++ b/apps/backend/drizzle/0039_last_silver_samurai.sql @@ -0,0 +1,15 @@ +CREATE TABLE "mf"."refunds" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."refunds_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "order_id" integer NOT NULL, + "refund_amount" numeric(10, 2), + "refund_status" varchar(50) DEFAULT 'none', + "merchant_refund_id" varchar(255), + "refund_processed_at" timestamp, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD COLUMN "cancellation_user_notes" text;--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD COLUMN "cancellation_admin_notes" text;--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD COLUMN "cancellation_reviewed" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD COLUMN "cancellation_reviewed_at" timestamp;--> statement-breakpoint +ALTER TABLE "mf"."refunds" ADD CONSTRAINT "refunds_order_id_orders_id_fk" FOREIGN KEY ("order_id") REFERENCES "mf"."orders"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0040_brief_albert_cleary.sql b/apps/backend/drizzle/0040_brief_albert_cleary.sql new file mode 100644 index 0000000..3f24ba5 --- /dev/null +++ b/apps/backend/drizzle/0040_brief_albert_cleary.sql @@ -0,0 +1 @@ +DROP TABLE "mf"."order_cancellations" CASCADE; \ No newline at end of file diff --git a/apps/backend/drizzle/0041_fine_kronos.sql b/apps/backend/drizzle/0041_fine_kronos.sql new file mode 100644 index 0000000..63e6b9c --- /dev/null +++ b/apps/backend/drizzle/0041_fine_kronos.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."order_status" ADD COLUMN "refund_coupon_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."order_status" ADD CONSTRAINT "order_status_refund_coupon_id_coupons_id_fk" FOREIGN KEY ("refund_coupon_id") REFERENCES "mf"."coupons"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0042_organic_phil_sheldon.sql b/apps/backend/drizzle/0042_organic_phil_sheldon.sql new file mode 100644 index 0000000..56b94be --- /dev/null +++ b/apps/backend/drizzle/0042_organic_phil_sheldon.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."complaints" ADD COLUMN "images" jsonb; \ No newline at end of file diff --git a/apps/backend/drizzle/0043_natural_joystick.sql b/apps/backend/drizzle/0043_natural_joystick.sql new file mode 100644 index 0000000..cee8424 --- /dev/null +++ b/apps/backend/drizzle/0043_natural_joystick.sql @@ -0,0 +1,23 @@ +CREATE TYPE "public"."upload_status" AS ENUM('pending', 'claimed');--> statement-breakpoint +CREATE TABLE "mf"."product_reviews" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_reviews_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "user_id" integer NOT NULL, + "product_id" integer NOT NULL, + "review_body" text NOT NULL, + "image_urls" jsonb, + "review_time" timestamp DEFAULT now() NOT NULL, + "ratings" real NOT NULL, + "admin_response" text, + "admin_response_images" jsonb, + CONSTRAINT "rating_check" CHECK ("mf"."product_reviews"."ratings" >= 1 AND "mf"."product_reviews"."ratings" <= 5) +); +--> statement-breakpoint +CREATE TABLE "mf"."upload_url_status" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."upload_url_status_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "created_at" timestamp DEFAULT now() NOT NULL, + "key" varchar(500) NOT NULL, + "status" "upload_status" DEFAULT 'pending' NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."product_reviews" ADD CONSTRAINT "product_reviews_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_reviews" ADD CONSTRAINT "product_reviews_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0044_rapid_meltdown.sql b/apps/backend/drizzle/0044_rapid_meltdown.sql new file mode 100644 index 0000000..d58638e --- /dev/null +++ b/apps/backend/drizzle/0044_rapid_meltdown.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."store_info" ADD COLUMN "image_url" varchar(500); \ No newline at end of file diff --git a/apps/backend/drizzle/0045_puzzling_leader.sql b/apps/backend/drizzle/0045_puzzling_leader.sql new file mode 100644 index 0000000..59cf3d2 --- /dev/null +++ b/apps/backend/drizzle/0045_puzzling_leader.sql @@ -0,0 +1,16 @@ +CREATE TABLE "mf"."address_areas" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."address_areas_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "place_name" varchar(255) NOT NULL, + "zone_id" integer, + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."address_zones" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."address_zones_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "zone_name" varchar(255) NOT NULL, + "added_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD COLUMN "zone_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."address_areas" ADD CONSTRAINT "address_areas_zone_id_address_zones_id_fk" FOREIGN KEY ("zone_id") REFERENCES "mf"."address_zones"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."addresses" ADD CONSTRAINT "addresses_zone_id_address_zones_id_fk" FOREIGN KEY ("zone_id") REFERENCES "mf"."address_zones"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0046_old_aaron_stack.sql b/apps/backend/drizzle/0046_old_aaron_stack.sql new file mode 100644 index 0000000..2341ca8 --- /dev/null +++ b/apps/backend/drizzle/0046_old_aaron_stack.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."orders" ADD COLUMN "delivery_charge" numeric(10, 2) DEFAULT '0' NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0047_dark_lester.sql b/apps/backend/drizzle/0047_dark_lester.sql new file mode 100644 index 0000000..58181e0 --- /dev/null +++ b/apps/backend/drizzle/0047_dark_lester.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."product_info" ADD COLUMN "increment_step" real DEFAULT 1 NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0048_talented_stature.sql b/apps/backend/drizzle/0048_talented_stature.sql new file mode 100644 index 0000000..f0fe03a --- /dev/null +++ b/apps/backend/drizzle/0048_talented_stature.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."product_info" ALTER COLUMN "store_id" DROP NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0049_lowly_silverclaw.sql b/apps/backend/drizzle/0049_lowly_silverclaw.sql new file mode 100644 index 0000000..202127f --- /dev/null +++ b/apps/backend/drizzle/0049_lowly_silverclaw.sql @@ -0,0 +1,16 @@ +CREATE TABLE "mf"."product_group_info" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."product_group_info_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "group_name" varchar(255) NOT NULL, + "description" varchar(500), + "created_at" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "mf"."product_group_membership" ( + "product_id" integer NOT NULL, + "group_id" integer NOT NULL, + "added_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "product_group_membership_pk" UNIQUE("product_id","group_id") +); +--> statement-breakpoint +ALTER TABLE "mf"."product_group_membership" ADD CONSTRAINT "product_group_membership_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."product_group_membership" ADD CONSTRAINT "product_group_membership_group_id_product_group_info_id_fk" FOREIGN KEY ("group_id") REFERENCES "mf"."product_group_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0050_fantastic_leopardon.sql b/apps/backend/drizzle/0050_fantastic_leopardon.sql new file mode 100644 index 0000000..37e1f71 --- /dev/null +++ b/apps/backend/drizzle/0050_fantastic_leopardon.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."order_items" ADD COLUMN "is_packaged" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."order_items" ADD COLUMN "is_package_verified" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0051_rapid_typhoid_mary.sql b/apps/backend/drizzle/0051_rapid_typhoid_mary.sql new file mode 100644 index 0000000..c63f8c2 --- /dev/null +++ b/apps/backend/drizzle/0051_rapid_typhoid_mary.sql @@ -0,0 +1,15 @@ +CREATE TABLE "mf"."home_banners" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."home_banners_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "name" varchar(255) NOT NULL, + "image_url" varchar(500) NOT NULL, + "description" varchar(500), + "product_id" integer, + "redirect_url" varchar(500), + "serial_num" integer NOT NULL, + "is_active" boolean DEFAULT false NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + "last_updated" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "home_banners_serial_num_unique" UNIQUE("serial_num") +); +--> statement-breakpoint +ALTER TABLE "mf"."home_banners" ADD CONSTRAINT "home_banners_product_id_product_info_id_fk" FOREIGN KEY ("product_id") REFERENCES "mf"."product_info"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0052_pretty_captain_britain.sql b/apps/backend/drizzle/0052_pretty_captain_britain.sql new file mode 100644 index 0000000..9cbaf8b --- /dev/null +++ b/apps/backend/drizzle/0052_pretty_captain_britain.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."home_banners" ALTER COLUMN "serial_num" DROP NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0053_volatile_salo.sql b/apps/backend/drizzle/0053_volatile_salo.sql new file mode 100644 index 0000000..5903c0a --- /dev/null +++ b/apps/backend/drizzle/0053_volatile_salo.sql @@ -0,0 +1,3 @@ +ALTER TABLE "mf"."home_banners" RENAME COLUMN "product_id" TO "product_ids";--> statement-breakpoint +ALTER TABLE "mf"."home_banners" DROP CONSTRAINT "home_banners_serial_num_unique";--> statement-breakpoint +ALTER TABLE "mf"."home_banners" DROP CONSTRAINT "home_banners_product_id_product_info_id_fk"; diff --git a/apps/backend/drizzle/0054_red_spyke.sql b/apps/backend/drizzle/0054_red_spyke.sql new file mode 100644 index 0000000..50916eb --- /dev/null +++ b/apps/backend/drizzle/0054_red_spyke.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."home_banners" DROP COLUMN "product_ids"; \ No newline at end of file diff --git a/apps/backend/drizzle/0055_petite_fallen_one.sql b/apps/backend/drizzle/0055_petite_fallen_one.sql new file mode 100644 index 0000000..0d33465 --- /dev/null +++ b/apps/backend/drizzle/0055_petite_fallen_one.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."home_banners" ADD COLUMN "product_ids" integer[]; \ No newline at end of file diff --git a/apps/backend/drizzle/0056_fancy_satana.sql b/apps/backend/drizzle/0056_fancy_satana.sql new file mode 100644 index 0000000..d4a7c46 --- /dev/null +++ b/apps/backend/drizzle/0056_fancy_satana.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."coupons" ADD COLUMN "applicable_users" jsonb; \ No newline at end of file diff --git a/apps/backend/drizzle/0057_safe_earthquake.sql b/apps/backend/drizzle/0057_safe_earthquake.sql new file mode 100644 index 0000000..2cc2635 --- /dev/null +++ b/apps/backend/drizzle/0057_safe_earthquake.sql @@ -0,0 +1,3 @@ +ALTER TABLE "mf"."coupons" DROP CONSTRAINT "coupons_target_user_users_id_fk"; +--> statement-breakpoint +ALTER TABLE "mf"."coupons" DROP COLUMN "target_user"; \ No newline at end of file diff --git a/apps/backend/drizzle/0058_motionless_next_avengers.sql b/apps/backend/drizzle/0058_motionless_next_avengers.sql new file mode 100644 index 0000000..97b49fd --- /dev/null +++ b/apps/backend/drizzle/0058_motionless_next_avengers.sql @@ -0,0 +1,2 @@ +ALTER TABLE "mf"."orders" ADD COLUMN "order_group_id" varchar(255);--> statement-breakpoint +ALTER TABLE "mf"."orders" ADD COLUMN "order_group_proportion" numeric(10, 4); \ No newline at end of file diff --git a/apps/backend/drizzle/0059_daily_spot.sql b/apps/backend/drizzle/0059_daily_spot.sql new file mode 100644 index 0000000..a765b60 --- /dev/null +++ b/apps/backend/drizzle/0059_daily_spot.sql @@ -0,0 +1,24 @@ +CREATE TABLE "mf"."reserved_coupons" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."reserved_coupons_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "secret_code" varchar(50) NOT NULL, + "coupon_code" varchar(50) NOT NULL, + "discount_percent" numeric(5, 2), + "flat_discount" numeric(10, 2), + "min_order" numeric(10, 2), + "product_ids" jsonb, + "max_value" numeric(10, 2), + "valid_till" timestamp, + "max_limit_for_user" integer, + "exclusive_apply" boolean DEFAULT false NOT NULL, + "is_redeemed" boolean DEFAULT false NOT NULL, + "redeemed_by" integer, + "redeemed_at" timestamp, + "created_by" integer NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "reserved_coupons_secret_code_unique" UNIQUE("secret_code"), + CONSTRAINT "unique_secret_code" UNIQUE("secret_code") +); +--> statement-breakpoint +ALTER TABLE "mf"."reserved_coupons" ADD CONSTRAINT "reserved_coupons_redeemed_by_users_id_fk" FOREIGN KEY ("redeemed_by") REFERENCES "mf"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."reserved_coupons" ADD CONSTRAINT "reserved_coupons_created_by_staff_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "mf"."staff_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."coupons" DROP COLUMN "applicable_users"; \ No newline at end of file diff --git a/apps/backend/drizzle/0060_numerous_terror.sql b/apps/backend/drizzle/0060_numerous_terror.sql new file mode 100644 index 0000000..9ab3740 --- /dev/null +++ b/apps/backend/drizzle/0060_numerous_terror.sql @@ -0,0 +1,28 @@ +CREATE TYPE "public"."staff_permission" AS ENUM('crud_product', 'make_coupon');--> statement-breakpoint +CREATE TYPE "public"."staff_role" AS ENUM('admin', 'marketer', 'delivery_staff');--> statement-breakpoint +CREATE TABLE "mf"."staff_permissions" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."staff_permissions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "permission_name" "staff_permission" NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_permission_name" UNIQUE("permission_name") +); +--> statement-breakpoint +CREATE TABLE "mf"."staff_role_permissions" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."staff_role_permissions_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "staff_role_id" integer NOT NULL, + "staff_permission_id" integer NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_role_permission" UNIQUE("staff_role_id","staff_permission_id") +); +--> statement-breakpoint +CREATE TABLE "mf"."staff_roles" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."staff_roles_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "role_name" "staff_role" NOT NULL, + "created_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "unique_role_name" UNIQUE("role_name") +); +--> statement-breakpoint +ALTER TABLE "mf"."staff_users" ADD COLUMN "staff_role_id" integer;--> statement-breakpoint +ALTER TABLE "mf"."staff_role_permissions" ADD CONSTRAINT "staff_role_permissions_staff_role_id_staff_roles_id_fk" FOREIGN KEY ("staff_role_id") REFERENCES "mf"."staff_roles"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."staff_role_permissions" ADD CONSTRAINT "staff_role_permissions_staff_permission_id_staff_permissions_id_fk" FOREIGN KEY ("staff_permission_id") REFERENCES "mf"."staff_permissions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mf"."staff_users" ADD CONSTRAINT "staff_users_staff_role_id_staff_roles_id_fk" FOREIGN KEY ("staff_role_id") REFERENCES "mf"."staff_roles"("id") ON DELETE no action ON UPDATE no action; \ No newline at end of file diff --git a/apps/backend/drizzle/0061_calm_sir_ram.sql b/apps/backend/drizzle/0061_calm_sir_ram.sql new file mode 100644 index 0000000..a7380ef --- /dev/null +++ b/apps/backend/drizzle/0061_calm_sir_ram.sql @@ -0,0 +1,2 @@ +ALTER TYPE "public"."staff_permission" ADD VALUE 'crud_staff_users';--> statement-breakpoint +ALTER TYPE "public"."staff_role" ADD VALUE 'super_admin' BEFORE 'admin'; \ No newline at end of file diff --git a/apps/backend/drizzle/0062_sloppy_sinister_six.sql b/apps/backend/drizzle/0062_sloppy_sinister_six.sql new file mode 100644 index 0000000..7e24050 --- /dev/null +++ b/apps/backend/drizzle/0062_sloppy_sinister_six.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."coupons" ALTER COLUMN "created_by" DROP NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0063_friendly_mandarin.sql b/apps/backend/drizzle/0063_friendly_mandarin.sql new file mode 100644 index 0000000..d4945a8 --- /dev/null +++ b/apps/backend/drizzle/0063_friendly_mandarin.sql @@ -0,0 +1,3 @@ +ALTER TABLE "mf"."delivery_slot_info" ADD COLUMN "is_flash" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."product_info" ADD COLUMN "is_flash_available" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "mf"."product_info" ADD COLUMN "flash_price" numeric(10, 2); \ No newline at end of file diff --git a/apps/backend/drizzle/0064_milky_revanche.sql b/apps/backend/drizzle/0064_milky_revanche.sql new file mode 100644 index 0000000..be63270 --- /dev/null +++ b/apps/backend/drizzle/0064_milky_revanche.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."orders" ADD COLUMN "is_flash_delivery" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0065_whole_spencer_smythe.sql b/apps/backend/drizzle/0065_whole_spencer_smythe.sql new file mode 100644 index 0000000..4cf5c80 --- /dev/null +++ b/apps/backend/drizzle/0065_whole_spencer_smythe.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."product_info" ADD COLUMN "product_quantity" real DEFAULT 1 NOT NULL; \ No newline at end of file diff --git a/apps/backend/drizzle/0066_gorgeous_karnak.sql b/apps/backend/drizzle/0066_gorgeous_karnak.sql new file mode 100644 index 0000000..801b44f --- /dev/null +++ b/apps/backend/drizzle/0066_gorgeous_karnak.sql @@ -0,0 +1 @@ +ALTER TABLE "mf"."order_status" ADD COLUMN "is_cancelled_by_admin" boolean; \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0000_snapshot.json b/apps/backend/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..272396a --- /dev/null +++ b/apps/backend/drizzle/meta/0000_snapshot.json @@ -0,0 +1,976 @@ +{ + "id": "fad820d3-856d-4d25-8a79-841c6c0a5eb5", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "deliveryTime": { + "name": "deliveryTime", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freezeTime": { + "name": "freezeTime", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "order_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway_order_id": { + "name": "gateway_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.order_status": { + "name": "order_status", + "schema": "public", + "values": [ + "pending", + "delivered", + "cancelled" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0001_snapshot.json b/apps/backend/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..9daa79e --- /dev/null +++ b/apps/backend/drizzle/meta/0001_snapshot.json @@ -0,0 +1,976 @@ +{ + "id": "f702bb39-6b79-4352-979d-537ecbaafd02", + "prevId": "fad820d3-856d-4d25-8a79-841c6c0a5eb5", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "order_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway_order_id": { + "name": "gateway_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.order_status": { + "name": "order_status", + "schema": "public", + "values": [ + "pending", + "delivered", + "cancelled" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0002_snapshot.json b/apps/backend/drizzle/meta/0002_snapshot.json new file mode 100644 index 0000000..0897a31 --- /dev/null +++ b/apps/backend/drizzle/meta/0002_snapshot.json @@ -0,0 +1,1048 @@ +{ + "id": "c10e79e3-3bd3-46dc-8f6c-3b85f05e6119", + "prevId": "f702bb39-6b79-4352-979d-537ecbaafd02", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "order_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway_order_id": { + "name": "gateway_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.order_status": { + "name": "order_status", + "schema": "public", + "values": [ + "pending", + "delivered", + "cancelled" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0003_snapshot.json b/apps/backend/drizzle/meta/0003_snapshot.json new file mode 100644 index 0000000..11a7c38 --- /dev/null +++ b/apps/backend/drizzle/meta/0003_snapshot.json @@ -0,0 +1,1272 @@ +{ + "id": "ad09956c-2a68-4891-9a5e-8700ff8872f1", + "prevId": "c10e79e3-3bd3-46dc-8f6c-3b85f05e6119", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway_order_id": { + "name": "gateway_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0004_snapshot.json b/apps/backend/drizzle/meta/0004_snapshot.json new file mode 100644 index 0000000..5c130b9 --- /dev/null +++ b/apps/backend/drizzle/meta/0004_snapshot.json @@ -0,0 +1,1279 @@ +{ + "id": "fe3e10cd-df59-49d1-a87c-56cd0b2f9734", + "prevId": "ad09956c-2a68-4891-9a5e-8700ff8872f1", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway_order_id": { + "name": "gateway_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "amount": { + "name": "amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0005_snapshot.json b/apps/backend/drizzle/meta/0005_snapshot.json new file mode 100644 index 0000000..79fd286 --- /dev/null +++ b/apps/backend/drizzle/meta/0005_snapshot.json @@ -0,0 +1,1317 @@ +{ + "id": "ab751651-7276-48d1-9d5f-abdd1bf05947", + "prevId": "fe3e10cd-df59-49d1-a87c-56cd0b2f9734", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0006_snapshot.json b/apps/backend/drizzle/meta/0006_snapshot.json new file mode 100644 index 0000000..2d7c1d0 --- /dev/null +++ b/apps/backend/drizzle/meta/0006_snapshot.json @@ -0,0 +1,1330 @@ +{ + "id": "e16dde20-f38b-481d-a3ce-f14a266baef5", + "prevId": "ab751651-7276-48d1-9d5f-abdd1bf05947", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0007_snapshot.json b/apps/backend/drizzle/meta/0007_snapshot.json new file mode 100644 index 0000000..90b1e24 --- /dev/null +++ b/apps/backend/drizzle/meta/0007_snapshot.json @@ -0,0 +1,1421 @@ +{ + "id": "8e76cfb1-684c-4eef-849a-96300c6fa492", + "prevId": "e16dde20-f38b-481d-a3ce-f14a266baef5", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0008_snapshot.json b/apps/backend/drizzle/meta/0008_snapshot.json new file mode 100644 index 0000000..3dcf5b6 --- /dev/null +++ b/apps/backend/drizzle/meta/0008_snapshot.json @@ -0,0 +1,1428 @@ +{ + "id": "8391e6b3-8066-456c-9312-c18fa5103a38", + "prevId": "8e76cfb1-684c-4eef-849a-96300c6fa492", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_cred": { + "name": "unique_user_cred", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0009_snapshot.json b/apps/backend/drizzle/meta/0009_snapshot.json new file mode 100644 index 0000000..4310e8f --- /dev/null +++ b/apps/backend/drizzle/meta/0009_snapshot.json @@ -0,0 +1,1476 @@ +{ + "id": "bc817f61-cf55-4711-80fe-c1487d764d4f", + "prevId": "8391e6b3-8066-456c-9312-c18fa5103a38", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0010_snapshot.json b/apps/backend/drizzle/meta/0010_snapshot.json new file mode 100644 index 0000000..e20c3ba --- /dev/null +++ b/apps/backend/drizzle/meta/0010_snapshot.json @@ -0,0 +1,1592 @@ +{ + "id": "85a7d7e5-d586-4a0b-a4a5-3d71cca6768a", + "prevId": "bc817f61-cf55-4711-80fe-c1487d764d4f", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0011_snapshot.json b/apps/backend/drizzle/meta/0011_snapshot.json new file mode 100644 index 0000000..12de0b2 --- /dev/null +++ b/apps/backend/drizzle/meta/0011_snapshot.json @@ -0,0 +1,1611 @@ +{ + "id": "79d54b35-e076-4351-963e-e2a0b83d77be", + "prevId": "85a7d7e5-d586-4a0b-a4a5-3d71cca6768a", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0012_snapshot.json b/apps/backend/drizzle/meta/0012_snapshot.json new file mode 100644 index 0000000..abce803 --- /dev/null +++ b/apps/backend/drizzle/meta/0012_snapshot.json @@ -0,0 +1,1625 @@ +{ + "id": "206aba7c-b2d4-4cdc-9019-950ddeb1bcd5", + "prevId": "79d54b35-e076-4351-963e-e2a0b83d77be", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0013_snapshot.json b/apps/backend/drizzle/meta/0013_snapshot.json new file mode 100644 index 0000000..bfbe62f --- /dev/null +++ b/apps/backend/drizzle/meta/0013_snapshot.json @@ -0,0 +1,1703 @@ +{ + "id": "05c591ea-9654-4079-9d4e-44b78e4115e6", + "prevId": "206aba7c-b2d4-4cdc-9019-950ddeb1bcd5", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0014_snapshot.json b/apps/backend/drizzle/meta/0014_snapshot.json new file mode 100644 index 0000000..04c1239 --- /dev/null +++ b/apps/backend/drizzle/meta/0014_snapshot.json @@ -0,0 +1,1709 @@ +{ + "id": "59dd96ee-8bed-44a2-82ec-e4a87b6caae8", + "prevId": "05c591ea-9654-4079-9d4e-44b78e4115e6", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0015_snapshot.json b/apps/backend/drizzle/meta/0015_snapshot.json new file mode 100644 index 0000000..170c4ee --- /dev/null +++ b/apps/backend/drizzle/meta/0015_snapshot.json @@ -0,0 +1,1715 @@ +{ + "id": "1cf1a931-ca28-490e-9c25-532b858ac97c", + "prevId": "59dd96ee-8bed-44a2-82ec-e4a87b6caae8", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0016_snapshot.json b/apps/backend/drizzle/meta/0016_snapshot.json new file mode 100644 index 0000000..6a4e997 --- /dev/null +++ b/apps/backend/drizzle/meta/0016_snapshot.json @@ -0,0 +1,1735 @@ +{ + "id": "fd9624a0-46e0-402e-b89c-b4cbc612a01a", + "prevId": "1cf1a931-ca28-490e-9c25-532b858ac97c", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_product_id_product_info_id_fk": { + "name": "coupons_product_id_product_info_id_fk", + "tableFrom": "coupons", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0017_snapshot.json b/apps/backend/drizzle/meta/0017_snapshot.json new file mode 100644 index 0000000..b82026d --- /dev/null +++ b/apps/backend/drizzle/meta/0017_snapshot.json @@ -0,0 +1,1721 @@ +{ + "id": "439b48c6-32f6-46c1-8320-7276c17a3692", + "prevId": "fd9624a0-46e0-402e-b89c-b4cbc612a01a", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0018_snapshot.json b/apps/backend/drizzle/meta/0018_snapshot.json new file mode 100644 index 0000000..9111837 --- /dev/null +++ b/apps/backend/drizzle/meta/0018_snapshot.json @@ -0,0 +1,1818 @@ +{ + "id": "954545a7-4846-4e3e-8711-3acefdd93417", + "prevId": "439b48c6-32f6-46c1-8320-7276c17a3692", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0019_snapshot.json b/apps/backend/drizzle/meta/0019_snapshot.json new file mode 100644 index 0000000..59fa671 --- /dev/null +++ b/apps/backend/drizzle/meta/0019_snapshot.json @@ -0,0 +1,1824 @@ +{ + "id": "2325ff4f-4880-47ec-a396-ce8acdd09850", + "prevId": "954545a7-4846-4e3e-8711-3acefdd93417", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0020_snapshot.json b/apps/backend/drizzle/meta/0020_snapshot.json new file mode 100644 index 0000000..c5aea28 --- /dev/null +++ b/apps/backend/drizzle/meta/0020_snapshot.json @@ -0,0 +1,1830 @@ +{ + "id": "691946b7-158f-4f9e-addb-a8be5cb41597", + "prevId": "2325ff4f-4880-47ec-a396-ce8acdd09850", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0021_snapshot.json b/apps/backend/drizzle/meta/0021_snapshot.json new file mode 100644 index 0000000..95a86ec --- /dev/null +++ b/apps/backend/drizzle/meta/0021_snapshot.json @@ -0,0 +1,1843 @@ +{ + "id": "d9b7ac5b-af0d-4aac-a352-887cfeed5a2f", + "prevId": "691946b7-158f-4f9e-addb-a8be5cb41597", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0022_snapshot.json b/apps/backend/drizzle/meta/0022_snapshot.json new file mode 100644 index 0000000..dd9b619 --- /dev/null +++ b/apps/backend/drizzle/meta/0022_snapshot.json @@ -0,0 +1,1850 @@ +{ + "id": "115942e4-9714-4df3-a48b-23211f65cb6b", + "prevId": "d9b7ac5b-af0d-4aac-a352-887cfeed5a2f", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0023_snapshot.json b/apps/backend/drizzle/meta/0023_snapshot.json new file mode 100644 index 0000000..f8056fe --- /dev/null +++ b/apps/backend/drizzle/meta/0023_snapshot.json @@ -0,0 +1,1856 @@ +{ + "id": "cf922142-eeff-4a81-b99d-a5bd5a2464e5", + "prevId": "115942e4-9714-4df3-a48b-23211f65cb6b", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0024_snapshot.json b/apps/backend/drizzle/meta/0024_snapshot.json new file mode 100644 index 0000000..779931f --- /dev/null +++ b/apps/backend/drizzle/meta/0024_snapshot.json @@ -0,0 +1,1940 @@ +{ + "id": "f902f415-826a-4332-b64a-b01e05e4c566", + "prevId": "cf922142-eeff-4a81-b99d-a5bd5a2464e5", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0025_snapshot.json b/apps/backend/drizzle/meta/0025_snapshot.json new file mode 100644 index 0000000..54583d5 --- /dev/null +++ b/apps/backend/drizzle/meta/0025_snapshot.json @@ -0,0 +1,1947 @@ +{ + "id": "d54aef8a-8ce7-4164-8615-3b819d644700", + "prevId": "f902f415-826a-4332-b64a-b01e05e4c566", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_payment_processed": { + "name": "is_payment_processed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0026_snapshot.json b/apps/backend/drizzle/meta/0026_snapshot.json new file mode 100644 index 0000000..b9b15b9 --- /dev/null +++ b/apps/backend/drizzle/meta/0026_snapshot.json @@ -0,0 +1,1959 @@ +{ + "id": "4301f24d-4472-44fa-bff8-c12f162531c7", + "prevId": "d54aef8a-8ce7-4164-8615-3b819d644700", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_status": { + "name": "payment_status", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0027_snapshot.json b/apps/backend/drizzle/meta/0027_snapshot.json new file mode 100644 index 0000000..e543464 --- /dev/null +++ b/apps/backend/drizzle/meta/0027_snapshot.json @@ -0,0 +1,1959 @@ +{ + "id": "20dc84e5-7223-4852-8239-f9f1f567b535", + "prevId": "4301f24d-4472-44fa-bff8-c12f162531c7", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0028_snapshot.json b/apps/backend/drizzle/meta/0028_snapshot.json new file mode 100644 index 0000000..9a93c8a --- /dev/null +++ b/apps/backend/drizzle/meta/0028_snapshot.json @@ -0,0 +1,2037 @@ +{ + "id": "0c377907-554d-41d9-ad3c-0add9c5edcd7", + "prevId": "20dc84e5-7223-4852-8239-f9f1f567b535", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0029_snapshot.json b/apps/backend/drizzle/meta/0029_snapshot.json new file mode 100644 index 0000000..7c51a75 --- /dev/null +++ b/apps/backend/drizzle/meta/0029_snapshot.json @@ -0,0 +1,2037 @@ +{ + "id": "a2910b44-5bd0-4f5f-ae7e-2b81c0aa8610", + "prevId": "0c377907-554d-41d9-ad3c-0add9c5edcd7", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0030_snapshot.json b/apps/backend/drizzle/meta/0030_snapshot.json new file mode 100644 index 0000000..364b7ef --- /dev/null +++ b/apps/backend/drizzle/meta/0030_snapshot.json @@ -0,0 +1,2127 @@ +{ + "id": "1d2b26d7-2a89-446e-93ce-16d068986e09", + "prevId": "a2910b44-5bd0-4f5f-ae7e-2b81c0aa8610", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0031_snapshot.json b/apps/backend/drizzle/meta/0031_snapshot.json new file mode 100644 index 0000000..2e1c678 --- /dev/null +++ b/apps/backend/drizzle/meta/0031_snapshot.json @@ -0,0 +1,2127 @@ +{ + "id": "c74c19b3-5a26-4180-84a5-0af70c776ea6", + "prevId": "1d2b26d7-2a89-446e-93ce-16d068986e09", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_refund_done": { + "name": "is_refund_done", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0032_snapshot.json b/apps/backend/drizzle/meta/0032_snapshot.json new file mode 100644 index 0000000..5cda79b --- /dev/null +++ b/apps/backend/drizzle/meta/0032_snapshot.json @@ -0,0 +1,2248 @@ +{ + "id": "efcf7b28-c4d0-4f1a-bcdb-aae980775fd3", + "prevId": "c74c19b3-5a26-4180-84a5-0af70c776ea6", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "razorpay_refund_id": { + "name": "razorpay_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0033_snapshot.json b/apps/backend/drizzle/meta/0033_snapshot.json new file mode 100644 index 0000000..7f9730b --- /dev/null +++ b/apps/backend/drizzle/meta/0033_snapshot.json @@ -0,0 +1,2405 @@ +{ + "id": "c8c49b84-48e5-47d8-9db3-3346180df341", + "prevId": "efcf7b28-c4d0-4f1a-bcdb-aae980775fd3", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "razorpay_refund_id": { + "name": "razorpay_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0034_snapshot.json b/apps/backend/drizzle/meta/0034_snapshot.json new file mode 100644 index 0000000..9dc5b50 --- /dev/null +++ b/apps/backend/drizzle/meta/0034_snapshot.json @@ -0,0 +1,2425 @@ +{ + "id": "a1bc796c-fb93-453e-acc0-95efe2264b2a", + "prevId": "c8c49b84-48e5-47d8-9db3-3346180df341", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "razorpay_refund_id": { + "name": "razorpay_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0035_snapshot.json b/apps/backend/drizzle/meta/0035_snapshot.json new file mode 100644 index 0000000..1ed4401 --- /dev/null +++ b/apps/backend/drizzle/meta/0035_snapshot.json @@ -0,0 +1,2432 @@ +{ + "id": "a1aafd4d-ca42-4635-bd1b-1d0c1d6171cd", + "prevId": "a1bc796c-fb93-453e-acc0-95efe2264b2a", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "razorpay_refund_id": { + "name": "razorpay_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0036_snapshot.json b/apps/backend/drizzle/meta/0036_snapshot.json new file mode 100644 index 0000000..4061f92 --- /dev/null +++ b/apps/backend/drizzle/meta/0036_snapshot.json @@ -0,0 +1,2618 @@ +{ + "id": "91401115-16a6-41ed-b308-cd7fa2a4301f", + "prevId": "a1aafd4d-ca42-4635-bd1b-1d0c1d6171cd", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "razorpay_refund_id": { + "name": "razorpay_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0037_snapshot.json b/apps/backend/drizzle/meta/0037_snapshot.json new file mode 100644 index 0000000..330fefe --- /dev/null +++ b/apps/backend/drizzle/meta/0037_snapshot.json @@ -0,0 +1,2618 @@ +{ + "id": "4cb82e78-6b8b-434b-8d73-824c457c8590", + "prevId": "91401115-16a6-41ed-b308-cd7fa2a4301f", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0038_snapshot.json b/apps/backend/drizzle/meta/0038_snapshot.json new file mode 100644 index 0000000..1552918 --- /dev/null +++ b/apps/backend/drizzle/meta/0038_snapshot.json @@ -0,0 +1,2632 @@ +{ + "id": "4c5e229e-3a5e-4900-8d76-80a0f560a7fc", + "prevId": "4cb82e78-6b8b-434b-8d73-824c457c8590", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0039_snapshot.json b/apps/backend/drizzle/meta/0039_snapshot.json new file mode 100644 index 0000000..2c22a2e --- /dev/null +++ b/apps/backend/drizzle/meta/0039_snapshot.json @@ -0,0 +1,2740 @@ +{ + "id": "09444a3a-5b4c-4963-9e47-dabe794c7824", + "prevId": "4c5e229e-3a5e-4900-8d76-80a0f560a7fc", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_cancellations": { + "name": "order_cancellations", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_cancellations_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_cancellations_order_id_orders_id_fk": { + "name": "order_cancellations_order_id_orders_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_cancellations_user_id_users_id_fk": { + "name": "order_cancellations_user_id_users_id_fk", + "tableFrom": "order_cancellations", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "order_cancellations_order_id_unique": { + "name": "order_cancellations_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0040_snapshot.json b/apps/backend/drizzle/meta/0040_snapshot.json new file mode 100644 index 0000000..5d1b499 --- /dev/null +++ b/apps/backend/drizzle/meta/0040_snapshot.json @@ -0,0 +1,2598 @@ +{ + "id": "4e01fc72-d510-4213-bf24-6fa49b0bef22", + "prevId": "09444a3a-5b4c-4963-9e47-dabe794c7824", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0041_snapshot.json b/apps/backend/drizzle/meta/0041_snapshot.json new file mode 100644 index 0000000..2473612 --- /dev/null +++ b/apps/backend/drizzle/meta/0041_snapshot.json @@ -0,0 +1,2618 @@ +{ + "id": "c86db5c8-3679-4f55-b04e-accd3e06c122", + "prevId": "4e01fc72-d510-4213-bf24-6fa49b0bef22", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0042_snapshot.json b/apps/backend/drizzle/meta/0042_snapshot.json new file mode 100644 index 0000000..d507d90 --- /dev/null +++ b/apps/backend/drizzle/meta/0042_snapshot.json @@ -0,0 +1,2624 @@ +{ + "id": "8f58d3bd-8388-4b61-a005-988a8b738efa", + "prevId": "c86db5c8-3679-4f55-b04e-accd3e06c122", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0043_snapshot.json b/apps/backend/drizzle/meta/0043_snapshot.json new file mode 100644 index 0000000..76061d8 --- /dev/null +++ b/apps/backend/drizzle/meta/0043_snapshot.json @@ -0,0 +1,2796 @@ +{ + "id": "5831be0c-4e34-497c-8cd4-498f6a694cb4", + "prevId": "8f58d3bd-8388-4b61-a005-988a8b738efa", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0044_snapshot.json b/apps/backend/drizzle/meta/0044_snapshot.json new file mode 100644 index 0000000..d454b81 --- /dev/null +++ b/apps/backend/drizzle/meta/0044_snapshot.json @@ -0,0 +1,2802 @@ +{ + "id": "e1e88d4a-26a4-41bc-9ceb-7b3f53aec59e", + "prevId": "5831be0c-4e34-497c-8cd4-498f6a694cb4", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0045_snapshot.json b/apps/backend/drizzle/meta/0045_snapshot.json new file mode 100644 index 0000000..67f6827 --- /dev/null +++ b/apps/backend/drizzle/meta/0045_snapshot.json @@ -0,0 +1,2929 @@ +{ + "id": "ec3bf6b5-a0c1-458f-bf8c-5abb19a1e0c0", + "prevId": "e1e88d4a-26a4-41bc-9ceb-7b3f53aec59e", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0046_snapshot.json b/apps/backend/drizzle/meta/0046_snapshot.json new file mode 100644 index 0000000..8fb3db1 --- /dev/null +++ b/apps/backend/drizzle/meta/0046_snapshot.json @@ -0,0 +1,2936 @@ +{ + "id": "49d740b1-1a3e-4f7a-889f-de0b21ee6cc8", + "prevId": "ec3bf6b5-a0c1-458f-bf8c-5abb19a1e0c0", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0047_snapshot.json b/apps/backend/drizzle/meta/0047_snapshot.json new file mode 100644 index 0000000..071ae13 --- /dev/null +++ b/apps/backend/drizzle/meta/0047_snapshot.json @@ -0,0 +1,2943 @@ +{ + "id": "6fa28025-ef21-438b-987f-78a0e50142e5", + "prevId": "49d740b1-1a3e-4f7a-889f-de0b21ee6cc8", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0048_snapshot.json b/apps/backend/drizzle/meta/0048_snapshot.json new file mode 100644 index 0000000..cdff944 --- /dev/null +++ b/apps/backend/drizzle/meta/0048_snapshot.json @@ -0,0 +1,2943 @@ +{ + "id": "212a5b02-47e1-4336-8993-5ca2c762d339", + "prevId": "6fa28025-ef21-438b-987f-78a0e50142e5", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0049_snapshot.json b/apps/backend/drizzle/meta/0049_snapshot.json new file mode 100644 index 0000000..20199c7 --- /dev/null +++ b/apps/backend/drizzle/meta/0049_snapshot.json @@ -0,0 +1,3062 @@ +{ + "id": "37e3e95d-e108-4a4c-8589-af8c3b3f8e72", + "prevId": "212a5b02-47e1-4336-8993-5ca2c762d339", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0050_snapshot.json b/apps/backend/drizzle/meta/0050_snapshot.json new file mode 100644 index 0000000..f2854c0 --- /dev/null +++ b/apps/backend/drizzle/meta/0050_snapshot.json @@ -0,0 +1,3076 @@ +{ + "id": "8d23ff8c-67de-466f-80a5-1637c4e19ac6", + "prevId": "37e3e95d-e108-4a4c-8589-af8c3b3f8e72", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0051_snapshot.json b/apps/backend/drizzle/meta/0051_snapshot.json new file mode 100644 index 0000000..e48c75b --- /dev/null +++ b/apps/backend/drizzle/meta/0051_snapshot.json @@ -0,0 +1,3186 @@ +{ + "id": "08aad159-d8ec-449a-b2d2-bc9f798f236e", + "prevId": "8d23ff8c-67de-466f-80a5-1637c4e19ac6", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "home_banners_product_id_product_info_id_fk": { + "name": "home_banners_product_id_product_info_id_fk", + "tableFrom": "home_banners", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "home_banners_serial_num_unique": { + "name": "home_banners_serial_num_unique", + "nullsNotDistinct": false, + "columns": [ + "serial_num" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0052_snapshot.json b/apps/backend/drizzle/meta/0052_snapshot.json new file mode 100644 index 0000000..93cf2a7 --- /dev/null +++ b/apps/backend/drizzle/meta/0052_snapshot.json @@ -0,0 +1,3186 @@ +{ + "id": "d7557b6f-c95b-4cf5-bc58-b74e319f1ba3", + "prevId": "08aad159-d8ec-449a-b2d2-bc9f798f236e", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "home_banners_product_id_product_info_id_fk": { + "name": "home_banners_product_id_product_info_id_fk", + "tableFrom": "home_banners", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "home_banners_serial_num_unique": { + "name": "home_banners_serial_num_unique", + "nullsNotDistinct": false, + "columns": [ + "serial_num" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0053_snapshot.json b/apps/backend/drizzle/meta/0053_snapshot.json new file mode 100644 index 0000000..d86c845 --- /dev/null +++ b/apps/backend/drizzle/meta/0053_snapshot.json @@ -0,0 +1,3163 @@ +{ + "id": "5c480a1c-046b-46d4-a228-3953a5ef628e", + "prevId": "d7557b6f-c95b-4cf5-bc58-b74e319f1ba3", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0054_snapshot.json b/apps/backend/drizzle/meta/0054_snapshot.json new file mode 100644 index 0000000..5e5fce3 --- /dev/null +++ b/apps/backend/drizzle/meta/0054_snapshot.json @@ -0,0 +1,3157 @@ +{ + "id": "9fa36e99-9716-4ab3-a0d1-89e8ad7d7869", + "prevId": "5c480a1c-046b-46d4-a228-3953a5ef628e", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0055_snapshot.json b/apps/backend/drizzle/meta/0055_snapshot.json new file mode 100644 index 0000000..92fa7cd --- /dev/null +++ b/apps/backend/drizzle/meta/0055_snapshot.json @@ -0,0 +1,3163 @@ +{ + "id": "eccbd1d7-e39e-46dd-8740-bd33822d474c", + "prevId": "9fa36e99-9716-4ab3-a0d1-89e8ad7d7869", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0056_snapshot.json b/apps/backend/drizzle/meta/0056_snapshot.json new file mode 100644 index 0000000..671492d --- /dev/null +++ b/apps/backend/drizzle/meta/0056_snapshot.json @@ -0,0 +1,3169 @@ +{ + "id": "ad069c95-33d2-4658-aba0-26296197f466", + "prevId": "eccbd1d7-e39e-46dd-8740-bd33822d474c", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "target_user": { + "name": "target_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "applicable_users": { + "name": "applicable_users", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_target_user_users_id_fk": { + "name": "coupons_target_user_users_id_fk", + "tableFrom": "coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "target_user" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0057_snapshot.json b/apps/backend/drizzle/meta/0057_snapshot.json new file mode 100644 index 0000000..1597d96 --- /dev/null +++ b/apps/backend/drizzle/meta/0057_snapshot.json @@ -0,0 +1,3149 @@ +{ + "id": "13c13452-4cb3-44a1-8146-1eef954ab69f", + "prevId": "ad069c95-33d2-4658-aba0-26296197f466", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "applicable_users": { + "name": "applicable_users", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0058_snapshot.json b/apps/backend/drizzle/meta/0058_snapshot.json new file mode 100644 index 0000000..c2f4153 --- /dev/null +++ b/apps/backend/drizzle/meta/0058_snapshot.json @@ -0,0 +1,3161 @@ +{ + "id": "eeb3ef97-16ed-4f66-91f1-2ac66fa1abb7", + "prevId": "13c13452-4cb3-44a1-8146-1eef954ab69f", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "applicable_users": { + "name": "applicable_users", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0059_snapshot.json b/apps/backend/drizzle/meta/0059_snapshot.json new file mode 100644 index 0000000..82b7445 --- /dev/null +++ b/apps/backend/drizzle/meta/0059_snapshot.json @@ -0,0 +1,3322 @@ +{ + "id": "463513fe-d8c7-4357-a5d9-15a9c46a2346", + "prevId": "eeb3ef97-16ed-4f66-91f1-2ac66fa1abb7", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0060_snapshot.json b/apps/backend/drizzle/meta/0060_snapshot.json new file mode 100644 index 0000000..bf00379 --- /dev/null +++ b/apps/backend/drizzle/meta/0060_snapshot.json @@ -0,0 +1,3551 @@ +{ + "id": "270fae24-9b4f-4b74-ba93-89def9ca7a25", + "prevId": "463513fe-d8c7-4357-a5d9-15a9c46a2346", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0061_snapshot.json b/apps/backend/drizzle/meta/0061_snapshot.json new file mode 100644 index 0000000..a4d9566 --- /dev/null +++ b/apps/backend/drizzle/meta/0061_snapshot.json @@ -0,0 +1,3553 @@ +{ + "id": "eeb83ecd-6c96-46c9-8ddc-d9e406182c75", + "prevId": "270fae24-9b4f-4b74-ba93-89def9ca7a25", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon", + "crud_staff_users" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "super_admin", + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0062_snapshot.json b/apps/backend/drizzle/meta/0062_snapshot.json new file mode 100644 index 0000000..cbfb1bf --- /dev/null +++ b/apps/backend/drizzle/meta/0062_snapshot.json @@ -0,0 +1,3553 @@ +{ + "id": "d7ef9e64-f6c0-4817-94ad-32c6b3cb31ce", + "prevId": "eeb83ecd-6c96-46c9-8ddc-d9e406182c75", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon", + "crud_staff_users" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "super_admin", + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0063_snapshot.json b/apps/backend/drizzle/meta/0063_snapshot.json new file mode 100644 index 0000000..c901b9e --- /dev/null +++ b/apps/backend/drizzle/meta/0063_snapshot.json @@ -0,0 +1,3573 @@ +{ + "id": "f5076fcd-12d5-44ba-a1a7-85d431285ab5", + "prevId": "d7ef9e64-f6c0-4817-94ad-32c6b3cb31ce", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_flash": { + "name": "is_flash", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_flash_available": { + "name": "is_flash_available", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "flash_price": { + "name": "flash_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon", + "crud_staff_users" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "super_admin", + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0064_snapshot.json b/apps/backend/drizzle/meta/0064_snapshot.json new file mode 100644 index 0000000..6a3d2c8 --- /dev/null +++ b/apps/backend/drizzle/meta/0064_snapshot.json @@ -0,0 +1,3580 @@ +{ + "id": "37e45f91-69d0-4b4e-b679-b03ed83c2fd7", + "prevId": "f5076fcd-12d5-44ba-a1a7-85d431285ab5", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_flash": { + "name": "is_flash", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_flash_delivery": { + "name": "is_flash_delivery", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_flash_available": { + "name": "is_flash_available", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "flash_price": { + "name": "flash_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon", + "crud_staff_users" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "super_admin", + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0065_snapshot.json b/apps/backend/drizzle/meta/0065_snapshot.json new file mode 100644 index 0000000..b03b2c2 --- /dev/null +++ b/apps/backend/drizzle/meta/0065_snapshot.json @@ -0,0 +1,3587 @@ +{ + "id": "ef1b71bc-2303-4273-8941-56ec011575fd", + "prevId": "37e45f91-69d0-4b4e-b679-b03ed83c2fd7", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_flash": { + "name": "is_flash", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_flash_delivery": { + "name": "is_flash_delivery", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_flash_available": { + "name": "is_flash_available", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "flash_price": { + "name": "flash_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "product_quantity": { + "name": "product_quantity", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon", + "crud_staff_users" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "super_admin", + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/0066_snapshot.json b/apps/backend/drizzle/meta/0066_snapshot.json new file mode 100644 index 0000000..468009c --- /dev/null +++ b/apps/backend/drizzle/meta/0066_snapshot.json @@ -0,0 +1,3593 @@ +{ + "id": "f105c79e-a657-457d-a49a-314b998b4ed3", + "prevId": "ef1b71bc-2303-4273-8941-56ec011575fd", + "version": "7", + "dialect": "postgresql", + "tables": { + "mf.address_areas": { + "name": "address_areas", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_areas_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "place_name": { + "name": "place_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "address_areas_zone_id_address_zones_id_fk": { + "name": "address_areas_zone_id_address_zones_id_fk", + "tableFrom": "address_areas", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.address_zones": { + "name": "address_zones", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "address_zones_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "zone_name": { + "name": "zone_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.addresses": { + "name": "addresses", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "addresses_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "varchar(15)", + "primaryKey": false, + "notNull": true + }, + "address_line1": { + "name": "address_line1", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "address_line2": { + "name": "address_line2", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "city": { + "name": "city", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "pincode": { + "name": "pincode", + "type": "varchar(10)", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "latitude": { + "name": "latitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "zone_id": { + "name": "zone_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "addresses_user_id_users_id_fk": { + "name": "addresses_user_id_users_id_fk", + "tableFrom": "addresses", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "addresses_zone_id_address_zones_id_fk": { + "name": "addresses_zone_id_address_zones_id_fk", + "tableFrom": "addresses", + "tableTo": "address_zones", + "schemaTo": "mf", + "columnsFrom": [ + "zone_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.cart_items": { + "name": "cart_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "cart_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cart_items_user_id_users_id_fk": { + "name": "cart_items_user_id_users_id_fk", + "tableFrom": "cart_items", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cart_items_product_id_product_info_id_fk": { + "name": "cart_items_product_id_product_info_id_fk", + "tableFrom": "cart_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_user_product": { + "name": "unique_user_product", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.complaints": { + "name": "complaints", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "complaints_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "complaint_body": { + "name": "complaint_body", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": true + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "response": { + "name": "response", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "is_resolved": { + "name": "is_resolved", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "complaints_user_id_users_id_fk": { + "name": "complaints_user_id_users_id_fk", + "tableFrom": "complaints", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "complaints_order_id_orders_id_fk": { + "name": "complaints_order_id_orders_id_fk", + "tableFrom": "complaints", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_products": { + "name": "coupon_applicable_products", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_products_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_products_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_products_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_products_product_id_product_info_id_fk": { + "name": "coupon_applicable_products_product_id_product_info_id_fk", + "tableFrom": "coupon_applicable_products", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_product": { + "name": "unique_coupon_product", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "product_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_applicable_users": { + "name": "coupon_applicable_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_applicable_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_applicable_users_coupon_id_coupons_id_fk": { + "name": "coupon_applicable_users_coupon_id_coupons_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_applicable_users_user_id_users_id_fk": { + "name": "coupon_applicable_users_user_id_users_id_fk", + "tableFrom": "coupon_applicable_users", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_user": { + "name": "unique_coupon_user", + "nullsNotDistinct": false, + "columns": [ + "coupon_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupon_usage": { + "name": "coupon_usage", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupon_usage_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "coupon_id": { + "name": "coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "order_item_id": { + "name": "order_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupon_usage_user_id_users_id_fk": { + "name": "coupon_usage_user_id_users_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_coupon_id_coupons_id_fk": { + "name": "coupon_usage_coupon_id_coupons_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_id_orders_id_fk": { + "name": "coupon_usage_order_id_orders_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "coupon_usage_order_item_id_order_items_id_fk": { + "name": "coupon_usage_order_item_id_order_items_id_fk", + "tableFrom": "coupon_usage", + "tableTo": "order_items", + "schemaTo": "mf", + "columnsFrom": [ + "order_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.coupons": { + "name": "coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "is_user_based": { + "name": "is_user_based", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_apply_for_all": { + "name": "is_apply_for_all", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_invalidated": { + "name": "is_invalidated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "coupons_created_by_staff_users_id_fk": { + "name": "coupons_created_by_staff_users_id_fk", + "tableFrom": "coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_coupon_code": { + "name": "unique_coupon_code", + "nullsNotDistinct": false, + "columns": [ + "coupon_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.delivery_slot_info": { + "name": "delivery_slot_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "delivery_slot_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "delivery_time": { + "name": "delivery_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "freeze_time": { + "name": "freeze_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_flash": { + "name": "is_flash", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "delivery_sequence": { + "name": "delivery_sequence", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.home_banners": { + "name": "home_banners", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "home_banners_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": false + }, + "redirect_url": { + "name": "redirect_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "serial_num": { + "name": "serial_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.key_val_store": { + "name": "key_val_store", + "schema": "mf", + "columns": { + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notif_creds": { + "name": "notif_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notif_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_verified": { + "name": "last_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "notif_creds_user_id_users_id_fk": { + "name": "notif_creds_user_id_users_id_fk", + "tableFrom": "notif_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notif_creds_token_unique": { + "name": "notif_creds_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.notifications": { + "name": "notifications", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "notifications_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "varchar(512)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "is_read": { + "name": "is_read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_items": { + "name": "order_items", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_items_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "discounted_price": { + "name": "discounted_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_package_verified": { + "name": "is_package_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_items_order_id_orders_id_fk": { + "name": "order_items_order_id_orders_id_fk", + "tableFrom": "order_items", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_items_product_id_product_info_id_fk": { + "name": "order_items_product_id_product_info_id_fk", + "tableFrom": "order_items", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.order_status": { + "name": "order_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "order_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_time": { + "name": "order_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "is_packaged": { + "name": "is_packaged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_delivered": { + "name": "is_delivered", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_cancelled": { + "name": "is_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancel_reason": { + "name": "cancel_reason", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "is_cancelled_by_admin": { + "name": "is_cancelled_by_admin", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "payment_state": { + "name": "payment_state", + "type": "payment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cancellation_user_notes": { + "name": "cancellation_user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_admin_notes": { + "name": "cancellation_admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reviewed": { + "name": "cancellation_reviewed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cancellation_reviewed_at": { + "name": "cancellation_reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refund_coupon_id": { + "name": "refund_coupon_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "order_status_user_id_users_id_fk": { + "name": "order_status_user_id_users_id_fk", + "tableFrom": "order_status", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_order_id_orders_id_fk": { + "name": "order_status_order_id_orders_id_fk", + "tableFrom": "order_status", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "order_status_refund_coupon_id_coupons_id_fk": { + "name": "order_status_refund_coupon_id_coupons_id_fk", + "tableFrom": "order_status", + "tableTo": "coupons", + "schemaTo": "mf", + "columnsFrom": [ + "refund_coupon_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.orders": { + "name": "orders", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "orders_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "address_id": { + "name": "address_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_cod": { + "name": "is_cod", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_online_payment": { + "name": "is_online_payment", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "payment_info_id": { + "name": "payment_info_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "total_amount": { + "name": "total_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "delivery_charge": { + "name": "delivery_charge", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "readable_id": { + "name": "readable_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "admin_notes": { + "name": "admin_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_notes": { + "name": "user_notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order_group_id": { + "name": "order_group_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "order_group_proportion": { + "name": "order_group_proportion", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "is_flash_delivery": { + "name": "is_flash_delivery", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "orders_user_id_users_id_fk": { + "name": "orders_user_id_users_id_fk", + "tableFrom": "orders", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_address_id_addresses_id_fk": { + "name": "orders_address_id_addresses_id_fk", + "tableFrom": "orders", + "tableTo": "addresses", + "schemaTo": "mf", + "columnsFrom": [ + "address_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_slot_id_delivery_slot_info_id_fk": { + "name": "orders_slot_id_delivery_slot_info_id_fk", + "tableFrom": "orders", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "orders_payment_info_id_payment_info_id_fk": { + "name": "orders_payment_info_id_payment_info_id_fk", + "tableFrom": "orders", + "tableTo": "payment_info", + "schemaTo": "mf", + "columnsFrom": [ + "payment_info_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payment_info": { + "name": "payment_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payment_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payment_info_merchant_order_id_unique": { + "name": "payment_info_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.payments": { + "name": "payments", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "payments_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "gateway": { + "name": "gateway", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "merchant_order_id": { + "name": "merchant_order_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "payments_order_id_orders_id_fk": { + "name": "payments_order_id_orders_id_fk", + "tableFrom": "payments", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "payments_merchant_order_id_unique": { + "name": "payments_merchant_order_id_unique", + "nullsNotDistinct": false, + "columns": [ + "merchant_order_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_categories": { + "name": "product_categories", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_categories_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_info": { + "name": "product_group_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_group_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "group_name": { + "name": "group_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_group_membership": { + "name": "product_group_membership", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_group_membership_product_id_product_info_id_fk": { + "name": "product_group_membership_product_id_product_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_group_membership_group_id_product_group_info_id_fk": { + "name": "product_group_membership_group_id_product_group_info_id_fk", + "tableFrom": "product_group_membership", + "tableTo": "product_group_info", + "schemaTo": "mf", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_group_membership_pk": { + "name": "product_group_membership_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "group_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_info": { + "name": "product_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "short_description": { + "name": "short_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "long_description": { + "name": "long_description", + "type": "varchar(1000)", + "primaryKey": false, + "notNull": false + }, + "unit_id": { + "name": "unit_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "market_price": { + "name": "market_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "images": { + "name": "images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "is_out_of_stock": { + "name": "is_out_of_stock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_flash_available": { + "name": "is_flash_available", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "flash_price": { + "name": "flash_price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "increment_step": { + "name": "increment_step", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "product_quantity": { + "name": "product_quantity", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "store_id": { + "name": "store_id", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_info_unit_id_units_id_fk": { + "name": "product_info_unit_id_units_id_fk", + "tableFrom": "product_info", + "tableTo": "units", + "schemaTo": "mf", + "columnsFrom": [ + "unit_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_info_store_id_store_info_id_fk": { + "name": "product_info_store_id_store_info_id_fk", + "tableFrom": "product_info", + "tableTo": "store_info", + "schemaTo": "mf", + "columnsFrom": [ + "store_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_reviews": { + "name": "product_reviews", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_reviews_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_body": { + "name": "review_body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "image_urls": { + "name": "image_urls", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "review_time": { + "name": "review_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ratings": { + "name": "ratings", + "type": "real", + "primaryKey": false, + "notNull": true + }, + "admin_response": { + "name": "admin_response", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "admin_response_images": { + "name": "admin_response_images", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_reviews_user_id_users_id_fk": { + "name": "product_reviews_user_id_users_id_fk", + "tableFrom": "product_reviews", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_reviews_product_id_product_info_id_fk": { + "name": "product_reviews_product_id_product_info_id_fk", + "tableFrom": "product_reviews", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "rating_check": { + "name": "rating_check", + "value": "\"mf\".\"product_reviews\".\"ratings\" >= 1 AND \"mf\".\"product_reviews\".\"ratings\" <= 5" + } + }, + "isRLSEnabled": false + }, + "mf.product_slots": { + "name": "product_slots", + "schema": "mf", + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "product_slots_product_id_product_info_id_fk": { + "name": "product_slots_product_id_product_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_slots_slot_id_delivery_slot_info_id_fk": { + "name": "product_slots_slot_id_delivery_slot_info_id_fk", + "tableFrom": "product_slots", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_slot_pk": { + "name": "product_slot_pk", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "slot_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tag_info": { + "name": "product_tag_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tag_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "tag_name": { + "name": "tag_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "tag_description": { + "name": "tag_description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_dashboard_tag": { + "name": "is_dashboard_tag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "product_tag_info_tag_name_unique": { + "name": "product_tag_info_tag_name_unique", + "nullsNotDistinct": false, + "columns": [ + "tag_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.product_tags": { + "name": "product_tags", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "product_tags_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag_id": { + "name": "tag_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "product_tags_product_id_product_info_id_fk": { + "name": "product_tags_product_id_product_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_tags_tag_id_product_tag_info_id_fk": { + "name": "product_tags_tag_id_product_tag_info_id_fk", + "tableFrom": "product_tags", + "tableTo": "product_tag_info", + "schemaTo": "mf", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_product_tag": { + "name": "unique_product_tag", + "nullsNotDistinct": false, + "columns": [ + "product_id", + "tag_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.refunds": { + "name": "refunds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "refunds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "order_id": { + "name": "order_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refund_amount": { + "name": "refund_amount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "refund_status": { + "name": "refund_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'none'" + }, + "merchant_refund_id": { + "name": "merchant_refund_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "refund_processed_at": { + "name": "refund_processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "refunds_order_id_orders_id_fk": { + "name": "refunds_order_id_orders_id_fk", + "tableFrom": "refunds", + "tableTo": "orders", + "schemaTo": "mf", + "columnsFrom": [ + "order_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.reserved_coupons": { + "name": "reserved_coupons", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "reserved_coupons_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "secret_code": { + "name": "secret_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "coupon_code": { + "name": "coupon_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "discount_percent": { + "name": "discount_percent", + "type": "numeric(5, 2)", + "primaryKey": false, + "notNull": false + }, + "flat_discount": { + "name": "flat_discount", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "min_order": { + "name": "min_order", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "product_ids": { + "name": "product_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_value": { + "name": "max_value", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": false + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "max_limit_for_user": { + "name": "max_limit_for_user", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "exclusive_apply": { + "name": "exclusive_apply", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_redeemed": { + "name": "is_redeemed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "redeemed_by": { + "name": "redeemed_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "redeemed_at": { + "name": "redeemed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reserved_coupons_redeemed_by_users_id_fk": { + "name": "reserved_coupons_redeemed_by_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "redeemed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reserved_coupons_created_by_staff_users_id_fk": { + "name": "reserved_coupons_created_by_staff_users_id_fk", + "tableFrom": "reserved_coupons", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reserved_coupons_secret_code_unique": { + "name": "reserved_coupons_secret_code_unique", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + }, + "unique_secret_code": { + "name": "unique_secret_code", + "nullsNotDistinct": false, + "columns": [ + "secret_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.special_deals": { + "name": "special_deals", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "special_deals_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "special_deals_product_id_product_info_id_fk": { + "name": "special_deals_product_id_product_info_id_fk", + "tableFrom": "special_deals", + "tableTo": "product_info", + "schemaTo": "mf", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_permissions": { + "name": "staff_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "permission_name": { + "name": "permission_name", + "type": "staff_permission", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_permission_name": { + "name": "unique_permission_name", + "nullsNotDistinct": false, + "columns": [ + "permission_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_role_permissions": { + "name": "staff_role_permissions", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_role_permissions_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "staff_permission_id": { + "name": "staff_permission_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_role_permissions_staff_role_id_staff_roles_id_fk": { + "name": "staff_role_permissions_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "staff_role_permissions_staff_permission_id_staff_permissions_id_fk": { + "name": "staff_role_permissions_staff_permission_id_staff_permissions_id_fk", + "tableFrom": "staff_role_permissions", + "tableTo": "staff_permissions", + "schemaTo": "mf", + "columnsFrom": [ + "staff_permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_permission": { + "name": "unique_role_permission", + "nullsNotDistinct": false, + "columns": [ + "staff_role_id", + "staff_permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_roles": { + "name": "staff_roles", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_roles_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "role_name": { + "name": "role_name", + "type": "staff_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_role_name": { + "name": "unique_role_name", + "nullsNotDistinct": false, + "columns": [ + "role_name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.staff_users": { + "name": "staff_users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "staff_users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "staff_role_id": { + "name": "staff_role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "staff_users_staff_role_id_staff_roles_id_fk": { + "name": "staff_users_staff_role_id_staff_roles_id_fk", + "tableFrom": "staff_users", + "tableTo": "staff_roles", + "schemaTo": "mf", + "columnsFrom": [ + "staff_role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.store_info": { + "name": "store_info", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "store_info_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "owner": { + "name": "owner", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "store_info_owner_staff_users_id_fk": { + "name": "store_info_owner_staff_users_id_fk", + "tableFrom": "store_info", + "tableTo": "staff_users", + "schemaTo": "mf", + "columnsFrom": [ + "owner" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.units": { + "name": "units", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "units_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "short_notation": { + "name": "short_notation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_name": { + "name": "full_name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_short_notation": { + "name": "unique_short_notation", + "nullsNotDistinct": false, + "columns": [ + "short_notation" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.upload_url_status": { + "name": "upload_url_status", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "upload_url_status_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "upload_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_creds": { + "name": "user_creds", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_creds_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_password": { + "name": "user_password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_creds_user_id_users_id_fk": { + "name": "user_creds_user_id_users_id_fk", + "tableFrom": "user_creds", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.user_details": { + "name": "user_details", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "user_details_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "bio": { + "name": "bio", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "date_of_birth": { + "name": "date_of_birth", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "gender": { + "name": "gender", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "occupation": { + "name": "occupation", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "profile_image": { + "name": "profile_image", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "is_suspended": { + "name": "is_suspended", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_details_user_id_users_id_fk": { + "name": "user_details_user_id_users_id_fk", + "tableFrom": "user_details", + "tableTo": "users", + "schemaTo": "mf", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_details_user_id_unique": { + "name": "user_details_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.users": { + "name": "users", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "mobile": { + "name": "mobile", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_email": { + "name": "unique_email", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "mf.vendor_snippets": { + "name": "vendor_snippets", + "schema": "mf", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "vendor_snippets_id_seq", + "schema": "mf", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "snippet_code": { + "name": "snippet_code", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slot_id": { + "name": "slot_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_ids": { + "name": "product_ids", + "type": "integer[]", + "primaryKey": false, + "notNull": true + }, + "valid_till": { + "name": "valid_till", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "vendor_snippets_slot_id_delivery_slot_info_id_fk": { + "name": "vendor_snippets_slot_id_delivery_slot_info_id_fk", + "tableFrom": "vendor_snippets", + "tableTo": "delivery_slot_info", + "schemaTo": "mf", + "columnsFrom": [ + "slot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "vendor_snippets_snippet_code_unique": { + "name": "vendor_snippets_snippet_code_unique", + "nullsNotDistinct": false, + "columns": [ + "snippet_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.payment_status": { + "name": "payment_status", + "schema": "public", + "values": [ + "pending", + "success", + "cod", + "failed" + ] + }, + "public.staff_permission": { + "name": "staff_permission", + "schema": "public", + "values": [ + "crud_product", + "make_coupon", + "crud_staff_users" + ] + }, + "public.staff_role": { + "name": "staff_role", + "schema": "public", + "values": [ + "super_admin", + "admin", + "marketer", + "delivery_staff" + ] + }, + "public.upload_status": { + "name": "upload_status", + "schema": "public", + "values": [ + "pending", + "claimed" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/backend/drizzle/meta/_journal.json b/apps/backend/drizzle/meta/_journal.json new file mode 100644 index 0000000..8cbaba1 --- /dev/null +++ b/apps/backend/drizzle/meta/_journal.json @@ -0,0 +1,475 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1760786001791, + "tag": "0000_colorful_tinkerer", + "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1760786267753, + "tag": "0001_busy_titania", + "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1760876962326, + "tag": "0002_wandering_lifeguard", + "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1760945207890, + "tag": "0003_tricky_the_twelve", + "breakpoints": true + }, + { + "idx": 4, + "version": "7", + "when": 1760947179526, + "tag": "0004_lively_diamondback", + "breakpoints": true + }, + { + "idx": 5, + "version": "7", + "when": 1760950341110, + "tag": "0005_tricky_warhawk", + "breakpoints": true + }, + { + "idx": 6, + "version": "7", + "when": 1761023107917, + "tag": "0006_outstanding_joystick", + "breakpoints": true + }, + { + "idx": 7, + "version": "7", + "when": 1761034327944, + "tag": "0007_yellow_charles_xavier", + "breakpoints": true + }, + { + "idx": 8, + "version": "7", + "when": 1761034912967, + "tag": "0008_nasty_mathemanic", + "breakpoints": true + }, + { + "idx": 9, + "version": "7", + "when": 1761044394994, + "tag": "0009_peaceful_victor_mancha", + "breakpoints": true + }, + { + "idx": 10, + "version": "7", + "when": 1761046587669, + "tag": "0010_flimsy_reavers", + "breakpoints": true + }, + { + "idx": 11, + "version": "7", + "when": 1761046972821, + "tag": "0011_watery_lady_mastermind", + "breakpoints": true + }, + { + "idx": 12, + "version": "7", + "when": 1761052893579, + "tag": "0012_flawless_jubilee", + "breakpoints": true + }, + { + "idx": 13, + "version": "7", + "when": 1761053583551, + "tag": "0013_married_celestials", + "breakpoints": true + }, + { + "idx": 14, + "version": "7", + "when": 1761140705850, + "tag": "0014_blushing_switch", + "breakpoints": true + }, + { + "idx": 15, + "version": "7", + "when": 1761417716685, + "tag": "0015_sloppy_boomerang", + "breakpoints": true + }, + { + "idx": 16, + "version": "7", + "when": 1761420500681, + "tag": "0016_eminent_thunderbolt_ross", + "breakpoints": true + }, + { + "idx": 17, + "version": "7", + "when": 1761422687927, + "tag": "0017_steady_moira_mactaggert", + "breakpoints": true + }, + { + "idx": 18, + "version": "7", + "when": 1761765314589, + "tag": "0018_simple_tomorrow_man", + "breakpoints": true + }, + { + "idx": 19, + "version": "7", + "when": 1761766904923, + "tag": "0019_productive_mulholland_black", + "breakpoints": true + }, + { + "idx": 20, + "version": "7", + "when": 1761929874782, + "tag": "0020_narrow_charles_xavier", + "breakpoints": true + }, + { + "idx": 21, + "version": "7", + "when": 1761935119476, + "tag": "0021_little_spot", + "breakpoints": true + }, + { + "idx": 22, + "version": "7", + "when": 1761936019322, + "tag": "0022_flippant_omega_sentinel", + "breakpoints": true + }, + { + "idx": 23, + "version": "7", + "when": 1761990924450, + "tag": "0023_sparkling_starjammers", + "breakpoints": true + }, + { + "idx": 24, + "version": "7", + "when": 1761990966682, + "tag": "0024_typical_the_twelve", + "breakpoints": true + }, + { + "idx": 25, + "version": "7", + "when": 1762598863704, + "tag": "0025_tricky_plazm", + "breakpoints": true + }, + { + "idx": 26, + "version": "7", + "when": 1762599227157, + "tag": "0026_flippant_spiral", + "breakpoints": true + }, + { + "idx": 27, + "version": "7", + "when": 1762600106583, + "tag": "0027_huge_iron_monger", + "breakpoints": true + }, + { + "idx": 28, + "version": "7", + "when": 1762624949568, + "tag": "0028_clever_anthem", + "breakpoints": true + }, + { + "idx": 29, + "version": "7", + "when": 1762958926686, + "tag": "0029_short_king_cobra", + "breakpoints": true + }, + { + "idx": 30, + "version": "7", + "when": 1763058797153, + "tag": "0030_superb_exiles", + "breakpoints": true + }, + { + "idx": 31, + "version": "7", + "when": 1763060107438, + "tag": "0031_clean_the_hunter", + "breakpoints": true + }, + { + "idx": 32, + "version": "7", + "when": 1763281196495, + "tag": "0032_tricky_baron_zemo", + "breakpoints": true + }, + { + "idx": 33, + "version": "7", + "when": 1763794531144, + "tag": "0033_brainy_skullbuster", + "breakpoints": true + }, + { + "idx": 34, + "version": "7", + "when": 1764325098973, + "tag": "0034_yummy_riptide", + "breakpoints": true + }, + { + "idx": 35, + "version": "7", + "when": 1764328719715, + "tag": "0035_lyrical_spencer_smythe", + "breakpoints": true + }, + { + "idx": 36, + "version": "7", + "when": 1764331069699, + "tag": "0036_eager_naoko", + "breakpoints": true + }, + { + "idx": 37, + "version": "7", + "when": 1764356000382, + "tag": "0037_pale_outlaw_kid", + "breakpoints": true + }, + { + "idx": 38, + "version": "7", + "when": 1764360189368, + "tag": "0038_volatile_jean_grey", + "breakpoints": true + }, + { + "idx": 39, + "version": "7", + "when": 1764387227083, + "tag": "0039_last_silver_samurai", + "breakpoints": true + }, + { + "idx": 40, + "version": "7", + "when": 1764387505378, + "tag": "0040_brief_albert_cleary", + "breakpoints": true + }, + { + "idx": 41, + "version": "7", + "when": 1764435551419, + "tag": "0041_fine_kronos", + "breakpoints": true + }, + { + "idx": 42, + "version": "7", + "when": 1764478346852, + "tag": "0042_organic_phil_sheldon", + "breakpoints": true + }, + { + "idx": 43, + "version": "7", + "when": 1765085944941, + "tag": "0043_natural_joystick", + "breakpoints": true + }, + { + "idx": 44, + "version": "7", + "when": 1765214759961, + "tag": "0044_rapid_meltdown", + "breakpoints": true + }, + { + "idx": 45, + "version": "7", + "when": 1765393363992, + "tag": "0045_puzzling_leader", + "breakpoints": true + }, + { + "idx": 46, + "version": "7", + "when": 1765890940636, + "tag": "0046_old_aaron_stack", + "breakpoints": true + }, + { + "idx": 47, + "version": "7", + "when": 1765907188857, + "tag": "0047_dark_lester", + "breakpoints": true + }, + { + "idx": 48, + "version": "7", + "when": 1766289001009, + "tag": "0048_talented_stature", + "breakpoints": true + }, + { + "idx": 49, + "version": "7", + "when": 1766889876535, + "tag": "0049_lowly_silverclaw", + "breakpoints": true + }, + { + "idx": 50, + "version": "7", + "when": 1766926392171, + "tag": "0050_fantastic_leopardon", + "breakpoints": true + }, + { + "idx": 51, + "version": "7", + "when": 1767163284231, + "tag": "0051_rapid_typhoid_mary", + "breakpoints": true + }, + { + "idx": 52, + "version": "7", + "when": 1767173986002, + "tag": "0052_pretty_captain_britain", + "breakpoints": true + }, + { + "idx": 53, + "version": "7", + "when": 1767177522196, + "tag": "0053_volatile_salo", + "breakpoints": true + }, + { + "idx": 54, + "version": "7", + "when": 1767181630135, + "tag": "0054_red_spyke", + "breakpoints": true + }, + { + "idx": 55, + "version": "7", + "when": 1767181648828, + "tag": "0055_petite_fallen_one", + "breakpoints": true + }, + { + "idx": 56, + "version": "7", + "when": 1767260845188, + "tag": "0056_fancy_satana", + "breakpoints": true + }, + { + "idx": 57, + "version": "7", + "when": 1767261885187, + "tag": "0057_safe_earthquake", + "breakpoints": true + }, + { + "idx": 58, + "version": "7", + "when": 1767637551901, + "tag": "0058_motionless_next_avengers", + "breakpoints": true + }, + { + "idx": 59, + "version": "7", + "when": 1767791583921, + "tag": "0059_daily_spot", + "breakpoints": true + }, + { + "idx": 60, + "version": "7", + "when": 1768228615788, + "tag": "0060_numerous_terror", + "breakpoints": true + }, + { + "idx": 61, + "version": "7", + "when": 1768239828469, + "tag": "0061_calm_sir_ram", + "breakpoints": true + }, + { + "idx": 62, + "version": "7", + "when": 1768242419782, + "tag": "0062_sloppy_sinister_six", + "breakpoints": true + }, + { + "idx": 63, + "version": "7", + "when": 1768245308174, + "tag": "0063_friendly_mandarin", + "breakpoints": true + }, + { + "idx": 64, + "version": "7", + "when": 1768280501802, + "tag": "0064_milky_revanche", + "breakpoints": true + }, + { + "idx": 65, + "version": "7", + "when": 1768400243774, + "tag": "0065_whole_spencer_smythe", + "breakpoints": true + }, + { + "idx": 66, + "version": "7", + "when": 1768710657343, + "tag": "0066_gorgeous_karnak", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/apps/backend/index.ts b/apps/backend/index.ts new file mode 100755 index 0000000..6a37b28 --- /dev/null +++ b/apps/backend/index.ts @@ -0,0 +1,175 @@ +import 'dotenv/config'; +import express, { NextFunction, Request, Response } from "express"; +import cors from "cors"; +// import bodyParser from "body-parser"; +import multer from "multer"; +import path from "path"; +import fs from "fs"; +import { db } from './src/db/db_index'; +import { staffUsers, userDetails } from './src/db/schema'; +import { eq } from 'drizzle-orm'; +import mainRouter from './src/main-router'; +import initFunc from './src/lib/init'; +import { createExpressMiddleware } from '@trpc/server/adapters/express'; +import { appRouter } from './src/trpc/router'; +import { TRPCError } from '@trpc/server'; +import jwt from 'jsonwebtoken' +import signedUrlCache from 'src/lib/signed-url-cache'; +import { seed } from 'src/db/seed'; +import './src/jobs/jobs-index'; + + +seed() +initFunc() + +const app = express(); + +app.use(cors({ + origin: 'http://localhost:5174' +})); + + +signedUrlCache.loadFromDisk(); + +app.use(express.json()); +app.use(express.urlencoded({ extended: true })); + +// Middleware to log all request URLs +app.use((req, res, next) => { + const timestamp = new Date().toISOString(); + console.log(`[${timestamp}] ${req.method} ${req.url}`); + next(); +}); + +//cors middleware +export function corsMiddleware(req: Request, res: Response, next: NextFunction) { + // Allow requests from any origin (for production, replace * with your domain) + res.header('Access-Control-Allow-Origin', '*'); + + // Allow specific headers clients can send + res.header( + 'Access-Control-Allow-Headers', + 'Origin, X-Requested-With, Content-Type, Accept, Authorization' + ); + + // Allow specific HTTP methods + res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS'); + + // Allow credentials if needed (optional) + // res.header('Access-Control-Allow-Credentials', 'true'); + + // Handle preflight (OPTIONS) requests quickly + if (req.method === 'OPTIONS') { + return res.sendStatus(204); + } + + next(); +} + + +app.use('/api/trpc', createExpressMiddleware({ + router: appRouter, + createContext: async ({ req, res }) => { + let user = null; + let staffUser = null; + const authHeader = req.headers.authorization; + + if (authHeader?.startsWith('Bearer ')) { + const token = authHeader.substring(7); + try { + const decoded = jwt.verify(token, process.env.JWT_SECRET || 'your-secret-key') as any; + + // Check if this is a staff token (has staffId) + if (decoded.staffId) { + // This is a staff token, verify staff exists + const staff = await db.query.staffUsers.findFirst({ + where: eq(staffUsers.id, decoded.staffId), + }); + + if (staff) { + user=staffUser + staffUser = { + id: staff.id, + name: staff.name, + }; + } + } else { + + // This is a regular user token + user = decoded; + + // Check if user is suspended + const details = await db.query.userDetails.findFirst({ + where: eq(userDetails.userId, user.userId), + }); + + if (details?.isSuspended) { + throw new TRPCError({ + code: 'FORBIDDEN', + message: 'Account suspended', + }); + } + } + } catch (err) { + // Invalid token, both user and staffUser remain null + } + } + return { req, res, user, staffUser }; + }, + onError({ error, path, type, ctx }) { + console.error('🚨 tRPC Error :', { + path, + type, + code: error.code, + message: error.message, + userId: ctx?.user?.userId, + stack: error.stack, + }); +}, +})); + +app.use('/api', mainRouter) + +const fallbackUiDirCandidates = [ + path.resolve(__dirname, '../fallback-ui/dist'), + path.resolve(__dirname, '../../fallback-ui/dist'), + path.resolve(process.cwd(), '../fallback-ui/dist'), + path.resolve(process.cwd(), './apps/fallback-ui/dist') +] + +const fallbackUiDir = + fallbackUiDirCandidates.find((candidate) => fs.existsSync(candidate)) ?? + fallbackUiDirCandidates[0] + + +const fallbackUiIndex = path.join(fallbackUiDir, 'index.html') +// const fallbackUiMountPath = '/admin-web' +const fallbackUiMountPath = '/'; + +if (fs.existsSync(fallbackUiIndex)) { + app.use(fallbackUiMountPath, express.static(fallbackUiDir)) + app.use('/mf'+fallbackUiMountPath, express.static(fallbackUiDir)) + const fallbackUiRegex = new RegExp( + `^${fallbackUiMountPath.replace(/\//g, '\\/')}(?:\\/.*)?$` + ) + app.get([fallbackUiMountPath, fallbackUiRegex], (req, res) => { + res.sendFile(fallbackUiIndex) + }) + app.get(/.*/, (req,res) => { + res.sendFile(fallbackUiIndex) + }) +} else { + console.warn(`Fallback UI build not found at ${fallbackUiIndex}`) +} + +// Global error handler +app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => { + console.error(err); + const status = err.statusCode || err.status || 500; + const message = err.message || 'Internal Server Error'; + res.status(status).json({ message }); +}); + +app.listen(4000, () => { + console.log("Server is running on http://localhost:4000/api/mobile/"); +}); diff --git a/apps/backend/package.json b/apps/backend/package.json new file mode 100755 index 0000000..d785ad2 --- /dev/null +++ b/apps/backend/package.json @@ -0,0 +1,59 @@ +{ + "name": "backend", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "migrate": "drizzle-kit generate:pg", + "build": "rimraf ./dist && tsc --project tsconfig.json", + "build2": "rimraf ./dist && tsc", + "db:push": "drizzle-kit push:pg", + "db:seed": "tsx src/db/seed.ts", + "dev2": "tsx watch index.ts", + "dev_node": "tsx watch index.ts", + "dev": "bun --watch index.ts", + "docker:build": "cd .. && docker buildx build --platform linux/amd64 -t mohdshafiuddin54/health_petal:latest --progress=plain -f backend/Dockerfile .", + "docker:push": "docker push mohdshafiuddin54/health_petal:latest" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "@aws-sdk/client-s3": "^3.888.0", + "@aws-sdk/s3-request-presigner": "^3.888.0", + "@trpc/server": "^11.6.0", + "@turf/turf": "^7.2.0", + "@types/bcryptjs": "^2.4.6", + "@types/cors": "^2.8.19", + "@types/jsonwebtoken": "^9.0.10", + "@types/multer": "^2.0.0", + "axios": "^1.11.0", + "bcryptjs": "^3.0.2", + "bullmq": "^5.63.0", + "cors": "^2.8.5", + "dayjs": "^1.11.18", + "dotenv": "^17.2.1", + "drizzle-orm": "^0.44.5", + "expo-server-sdk": "^4.0.0", + "express": "^5.1.0", + "jsonwebtoken": "^9.0.2", + "multer": "^2.0.2", + "node-cron": "^4.2.1", + "pg": "^8.16.3", + "pg-sdk-node": "https://phonepe.mycloudrepo.io/public/repositories/phonepe-pg-sdk-node/releases/v2/phonepe-pg-sdk-node.tgz", + "razorpay": "^2.9.6", + "redis": "^5.9.0", + "zod": "^4.1.12" + }, + "devDependencies": { + "@types/express": "^5.0.3", + "@types/node": "^24.5.2", + "@types/pg": "^8.15.5", + "drizzle-kit": "^0.31.4", + "rimraf": "^6.1.2", + "ts-node-dev": "^2.0.0", + "tsx": "^4.20.5", + "typescript": "^5.9.2" + } +} \ No newline at end of file diff --git a/apps/backend/src/admin-apis/av-router.ts b/apps/backend/src/admin-apis/av-router.ts new file mode 100755 index 0000000..b98e354 --- /dev/null +++ b/apps/backend/src/admin-apis/av-router.ts @@ -0,0 +1,19 @@ +import { Router } from "express"; +import { authenticateStaff } from "../middleware/staff-auth"; +import productRouter from "./product.router"; +import tagRouter from "./tag.router"; + +const router = Router(); + +// Apply staff authentication to all admin routes +router.use(authenticateStaff); + +// Product routes +router.use("/products", productRouter); + +// Tag routes +router.use("/product-tags", tagRouter); + +const avRouter = router; + +export default avRouter; \ No newline at end of file diff --git a/apps/backend/src/admin-apis/product-tags.controller.ts b/apps/backend/src/admin-apis/product-tags.controller.ts new file mode 100644 index 0000000..dfc24ad --- /dev/null +++ b/apps/backend/src/admin-apis/product-tags.controller.ts @@ -0,0 +1,186 @@ +import { Request, Response } from "express"; +import { db } from "../db/db_index"; +import { productTagInfo } from "../db/schema"; +import { eq } from "drizzle-orm"; +import { ApiError } from "../lib/api-error"; +import { imageUploadS3, generateSignedUrlFromS3Url } from "../lib/s3-client"; +import { deleteS3Image } from "../lib/delete-image"; + +/** + * Create a new product tag + */ +export const createTag = async (req: Request, res: Response) => { + const { tagName, tagDescription, isDashboardTag } = req.body; + + if (!tagName) { + throw new ApiError("Tag name is required", 400); + } + + // Check for duplicate tag name + const existingTag = await db.query.productTagInfo.findFirst({ + where: eq(productTagInfo.tagName, tagName.trim()), + }); + + if (existingTag) { + throw new ApiError("A tag with this name already exists", 400); + } + + let imageUrl: string | null = null; + + // Handle image upload if file is provided + if (req.file) { + const key = `tags/${Date.now()}-${req.file.originalname}`; + imageUrl = await imageUploadS3(req.file.buffer, req.file.mimetype, key); + } + + const [newTag] = await db + .insert(productTagInfo) + .values({ + tagName: tagName.trim(), + tagDescription, + imageUrl, + isDashboardTag: isDashboardTag || false, + }) + .returning(); + + return res.status(201).json({ + tag: newTag, + message: "Tag created successfully", + }); +}; + +/** + * Get all product tags + */ +export const getAllTags = async (req: Request, res: Response) => { + const tags = await db + .select() + .from(productTagInfo) + .orderBy(productTagInfo.tagName); + + // Generate signed URLs for tag images + const tagsWithSignedUrls = await Promise.all( + tags.map(async (tag) => ({ + ...tag, + imageUrl: tag.imageUrl ? await generateSignedUrlFromS3Url(tag.imageUrl) : null, + })) + ); + + return res.status(200).json({ + tags: tagsWithSignedUrls, + message: "Tags retrieved successfully", + }); +}; + +/** + * Get a single product tag by ID + */ +export const getTagById = async (req: Request, res: Response) => { + const { id } = req.params; + + const tag = await db.query.productTagInfo.findFirst({ + where: eq(productTagInfo.id, parseInt(id)), + }); + + if (!tag) { + throw new ApiError("Tag not found", 404); + } + + // Generate signed URL for tag image + const tagWithSignedUrl = { + ...tag, + imageUrl: tag.imageUrl ? await generateSignedUrlFromS3Url(tag.imageUrl) : null, + }; + + return res.status(200).json({ + tag: tagWithSignedUrl, + message: "Tag retrieved successfully", + }); +}; + +/** + * Update a product tag + */ +export const updateTag = async (req: Request, res: Response) => { + const { id } = req.params; + const { tagName, tagDescription, isDashboardTag } = req.body; + + // Get the current tag to check for existing image + const currentTag = await db.query.productTagInfo.findFirst({ + where: eq(productTagInfo.id, parseInt(id)), + }); + + if (!currentTag) { + throw new ApiError("Tag not found", 404); + } + + let imageUrl = currentTag.imageUrl; + + // Handle image upload if new file is provided + if (req.file) { + // Delete old image if it exists + if (currentTag.imageUrl) { + try { + await deleteS3Image(currentTag.imageUrl); + } catch (error) { + console.error("Failed to delete old image:", error); + // Continue with update even if delete fails + } + } + + + // Upload new image + const key = `tags/${Date.now()}-${req.file.originalname}`; + console.log('file', key) + imageUrl = await imageUploadS3(req.file.buffer, req.file.mimetype, key); + } + + const [updatedTag] = await db + .update(productTagInfo) + .set({ + tagName: tagName?.trim(), + tagDescription, + imageUrl, + isDashboardTag, + }) + .where(eq(productTagInfo.id, parseInt(id))) + .returning(); + + return res.status(200).json({ + tag: updatedTag, + message: "Tag updated successfully", + }); +}; + +/** + * Delete a product tag + */ +export const deleteTag = async (req: Request, res: Response) => { + const { id } = req.params; + + // Check if tag exists + const tag = await db.query.productTagInfo.findFirst({ + where: eq(productTagInfo.id, parseInt(id)), + }); + + if (!tag) { + throw new ApiError("Tag not found", 404); + } + + // Delete image from S3 if it exists + if (tag.imageUrl) { + try { + await deleteS3Image(tag.imageUrl); + } catch (error) { + console.error("Failed to delete image from S3:", error); + // Continue with deletion even if image delete fails + } + } + + // Note: This will fail if tag is still assigned to products due to foreign key constraint + await db.delete(productTagInfo).where(eq(productTagInfo.id, parseInt(id))); + + return res.status(200).json({ + message: "Tag deleted successfully", + }); +}; \ No newline at end of file diff --git a/apps/backend/src/admin-apis/product.controller.ts b/apps/backend/src/admin-apis/product.controller.ts new file mode 100644 index 0000000..14650fc --- /dev/null +++ b/apps/backend/src/admin-apis/product.controller.ts @@ -0,0 +1,297 @@ +import { Request, Response } from "express"; +import { db } from "../db/db_index"; +import { productInfo, units, specialDeals, productTags } from "../db/schema"; +import { eq, inArray } from "drizzle-orm"; +import { ApiError } from "../lib/api-error"; +import { imageUploadS3, getOriginalUrlFromSignedUrl } from "../lib/s3-client"; +import { deleteS3Image } from "../lib/delete-image"; +import type { SpecialDeal } from "../db/types"; + +type CreateDeal = { + quantity: number; + price: number; + validTill: string; +}; + +/** + * Create a new product + */ +export const createProduct = async (req: Request, res: Response) => { + const { name, shortDescription, longDescription, unitId, storeId, price, marketPrice, incrementStep, productQuantity, isSuspended, isFlashAvailable, flashPrice, deals, tagIds } = req.body; + + // Validate required fields + if (!name || !unitId || !storeId || !price) { + throw new ApiError("Name, unitId, storeId, and price are required", 400); + } + + // Check for duplicate name + const existingProduct = await db.query.productInfo.findFirst({ + where: eq(productInfo.name, name.trim()), + }); + + if (existingProduct) { + throw new ApiError("A product with this name already exists", 400); + } + + // Check if unit exists + const unit = await db.query.units.findFirst({ + where: eq(units.id, unitId), + }); + + if (!unit) { + throw new ApiError("Invalid unit ID", 400); + } + + // Extract images from req.files + const images = (req.files as Express.Multer.File[])?.filter(item => item.fieldname === 'images'); + let uploadedImageUrls: string[] = []; + + if (images && Array.isArray(images)) { + const imageUploadPromises = images.map((file, index) => { + const key = `product-images/${Date.now()}-${index}`; + return imageUploadS3(file.buffer, file.mimetype, key); + }); + + uploadedImageUrls = await Promise.all(imageUploadPromises); + } + + // Create product + const productData: any = { + name, + shortDescription, + longDescription, + unitId, + storeId, + price, + marketPrice, + incrementStep: incrementStep || 1, + productQuantity: productQuantity || 1, + isSuspended: isSuspended || false, + isFlashAvailable: isFlashAvailable || false, + images: uploadedImageUrls, + }; + + if (flashPrice) { + productData.flashPrice = parseFloat(flashPrice); + } + + const [newProduct] = await db + .insert(productInfo) + .values(productData) + .returning(); + + // Handle deals if provided + let createdDeals: SpecialDeal[] = []; + if (deals && Array.isArray(deals)) { + const dealInserts = deals.map((deal: CreateDeal) => ({ + productId: newProduct.id, + quantity: deal.quantity.toString(), + price: deal.price.toString(), + validTill: new Date(deal.validTill), + })); + + createdDeals = await db + .insert(specialDeals) + .values(dealInserts) + .returning(); + } + + // Handle tag assignments if provided + if (tagIds && Array.isArray(tagIds)) { + const tagAssociations = tagIds.map((tagId: number) => ({ + productId: newProduct.id, + tagId, + })); + + await db.insert(productTags).values(tagAssociations); + } + + return res.status(201).json({ + product: newProduct, + deals: createdDeals, + message: "Product created successfully", + }); +}; + +/** + * Update a product + */ +export const updateProduct = async (req: Request, res: Response) => { + const { id } = req.params; + const { name, shortDescription, longDescription, unitId, storeId, price, marketPrice, incrementStep, productQuantity, isSuspended, isFlashAvailable, flashPrice, deals:dealsRaw, imagesToDelete:imagesToDeleteRaw, tagIds } = req.body; + + console.log({productQuantity}) + + const deals = dealsRaw ? JSON.parse(dealsRaw) : null; + const imagesToDelete = imagesToDeleteRaw ? JSON.parse(imagesToDeleteRaw) : []; + + if (!name || !unitId || !storeId || !price) { + throw new ApiError("Name, unitId, storeId, and price are required", 400); + } + + // Check if unit exists + const unit = await db.query.units.findFirst({ + where: eq(units.id, unitId), + }); + + if (!unit) { + throw new ApiError("Invalid unit ID", 400); + } + + // Get current product to handle image updates + const currentProduct = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, parseInt(id)), + }); + + if (!currentProduct) { + throw new ApiError("Product not found", 404); + } + + // Handle image deletions + let currentImages = (currentProduct.images as string[]) || []; + if (imagesToDelete && imagesToDelete.length > 0) { + // Convert signed URLs to original S3 URLs for comparison + const originalUrlsToDelete = imagesToDelete + .map((signedUrl: string) => getOriginalUrlFromSignedUrl(signedUrl)) + .filter(Boolean); // Remove nulls + + // Find which stored images match the ones to delete + const imagesToRemoveFromDb = currentImages.filter(storedUrl => + originalUrlsToDelete.includes(storedUrl) + ); + + // Delete the matching images from S3 + const deletePromises = imagesToRemoveFromDb.map(imageUrl => deleteS3Image(imageUrl)); + await Promise.all(deletePromises); + + // Remove deleted images from current images array + currentImages = currentImages.filter(img => !imagesToRemoveFromDb.includes(img)); + } + + // Extract new images from req.files + const images = (req.files as Express.Multer.File[])?.filter(item => item.fieldname === 'images'); + let uploadedImageUrls: string[] = []; + + if (images && Array.isArray(images)) { + const imageUploadPromises = images.map((file, index) => { + const key = `product-images/${Date.now()}-${index}`; + return imageUploadS3(file.buffer, file.mimetype, key); + }); + + uploadedImageUrls = await Promise.all(imageUploadPromises); + } + + // Combine remaining current images with new uploaded images + const finalImages = [...currentImages, ...uploadedImageUrls]; + + const updateData: any = { + name, + shortDescription, + longDescription, + unitId, + storeId, + price, + marketPrice, + incrementStep: incrementStep || 1, + productQuantity: productQuantity || 1, + isSuspended: isSuspended || false, + images: finalImages.length > 0 ? finalImages : undefined, + }; + + if (isFlashAvailable !== undefined) { + updateData.isFlashAvailable = isFlashAvailable; + } + + if (flashPrice !== undefined) { + updateData.flashPrice = flashPrice ? parseFloat(flashPrice) : null; + } + + const [updatedProduct] = await db + .update(productInfo) + .set(updateData) + .where(eq(productInfo.id, parseInt(id))) + .returning(); + + if (!updatedProduct) { + throw new ApiError("Product not found", 404); + } + + // Handle deals if provided + if (deals && Array.isArray(deals)) { + // Get existing deals + const existingDeals = await db.query.specialDeals.findMany({ + where: eq(specialDeals.productId, parseInt(id)), + }); + + // Create maps for comparison + const existingDealsMap = new Map(existingDeals.map(deal => [`${deal.quantity}-${deal.price}`, deal])); + const newDealsMap = new Map(deals.map((deal: CreateDeal) => [`${deal.quantity}-${deal.price}`, deal])); + + // Find deals to add, update, and remove + const dealsToAdd = deals.filter((deal: CreateDeal) => { + const key = `${deal.quantity}-${deal.price}`; + return !existingDealsMap.has(key); + }); + + const dealsToRemove = existingDeals.filter(deal => { + const key = `${deal.quantity}-${deal.price}`; + return !newDealsMap.has(key); + }); + + const dealsToUpdate = deals.filter((deal: CreateDeal) => { + const key = `${deal.quantity}-${deal.price}`; + const existing = existingDealsMap.get(key); + return existing && existing.validTill.toISOString().split('T')[0] !== deal.validTill; + }); + + // Remove old deals + if (dealsToRemove.length > 0) { + await db.delete(specialDeals).where( + inArray(specialDeals.id, dealsToRemove.map(deal => deal.id)) + ); + } + + // Add new deals + if (dealsToAdd.length > 0) { + const dealInserts = dealsToAdd.map((deal: CreateDeal) => ({ + productId: parseInt(id), + quantity: deal.quantity.toString(), + price: deal.price.toString(), + validTill: new Date(deal.validTill), + })); + await db.insert(specialDeals).values(dealInserts); + } + + // Update existing deals + for (const deal of dealsToUpdate) { + const key = `${deal.quantity}-${deal.price}`; + const existingDeal = existingDealsMap.get(key); + if (existingDeal) { + await db.update(specialDeals) + .set({ validTill: new Date(deal.validTill) }) + .where(eq(specialDeals.id, existingDeal.id)); + } + } + } + + // Handle tag assignments if provided + // if (tagIds && Array.isArray(tagIds)) { + if (tagIds && Boolean(tagIds)) { + // Remove existing tags + await db.delete(productTags).where(eq(productTags.productId, parseInt(id))); + + const tagIdsArray = Array.isArray(tagIds) ? tagIds : [+tagIds] + // Add new tags + const tagAssociations = tagIdsArray.map((tagId: number) => ({ + productId: parseInt(id), + tagId, + })); + + await db.insert(productTags).values(tagAssociations); + } + + return res.status(200).json({ + product: updatedProduct, + message: "Product updated successfully", + }); +}; \ No newline at end of file diff --git a/apps/backend/src/admin-apis/product.router.ts b/apps/backend/src/admin-apis/product.router.ts new file mode 100644 index 0000000..faabd52 --- /dev/null +++ b/apps/backend/src/admin-apis/product.router.ts @@ -0,0 +1,11 @@ +import { Router } from "express"; +import { createProduct, updateProduct } from "./product.controller"; +import uploadHandler from '../lib/upload-handler'; + +const router = Router(); + +// Product routes +router.post("/", uploadHandler.array('images'), createProduct); +router.put("/:id", uploadHandler.array('images'), updateProduct); + +export default router; \ No newline at end of file diff --git a/apps/backend/src/admin-apis/tag.router.ts b/apps/backend/src/admin-apis/tag.router.ts new file mode 100644 index 0000000..171ce7f --- /dev/null +++ b/apps/backend/src/admin-apis/tag.router.ts @@ -0,0 +1,14 @@ +import { Router } from "express"; +import { createTag, getAllTags, getTagById, updateTag, deleteTag } from "./product-tags.controller"; +import uploadHandler from '../lib/upload-handler'; + +const router = Router(); + +// Tag routes +router.post("/", uploadHandler.single('image'), createTag); +router.get("/", getAllTags); +router.get("/:id", getTagById); +router.put("/:id", uploadHandler.single('image'), updateTag); +router.delete("/:id", deleteTag); + +export default router; \ No newline at end of file diff --git a/apps/backend/src/common-apis/common-product.controller.ts b/apps/backend/src/common-apis/common-product.controller.ts new file mode 100644 index 0000000..00161f8 --- /dev/null +++ b/apps/backend/src/common-apis/common-product.controller.ts @@ -0,0 +1,105 @@ +import { eq, gt, and, sql, inArray } from "drizzle-orm"; +import { Request, Response } from "express"; +import { db } from "../db/db_index"; +import { productInfo, units, productSlots, deliverySlotInfo, productTags } from "../db/schema"; +import { generateSignedUrlsFromS3Urls } from "../lib/s3-client"; + +/** + * Get next delivery date for a product + */ +const getNextDeliveryDate = async (productId: number): Promise => { + const result = await db + .select({ deliveryTime: deliverySlotInfo.deliveryTime }) + .from(productSlots) + .innerJoin(deliverySlotInfo, eq(productSlots.slotId, deliverySlotInfo.id)) + .where( + and( + eq(productSlots.productId, productId), + eq(deliverySlotInfo.isActive, true), + gt(deliverySlotInfo.deliveryTime, sql`NOW()`) + ) + ) + .orderBy(deliverySlotInfo.deliveryTime) + .limit(1); + + + return result[0]?.deliveryTime || null; +}; + +/** + * Get all products summary for dropdown + */ +export const getAllProductsSummary = async (req: Request, res: Response) => { + try { + const { tagId } = req.query; + const tagIdNum = tagId ? parseInt(tagId as string) : null; + + let productIds: number[] | null = null; + + // If tagId is provided, get products that have this tag + if (tagIdNum) { + const taggedProducts = await db + .select({ productId: productTags.productId }) + .from(productTags) + .where(eq(productTags.tagId, tagIdNum)); + + productIds = taggedProducts.map(tp => tp.productId); + } + + let whereCondition = undefined; + + // Filter by product IDs if tag filtering is applied + if (productIds && productIds.length > 0) { + whereCondition = inArray(productInfo.id, productIds); + } else if (tagIdNum) { + // If tagId was provided but no products found, return empty array + return res.status(200).json({ + products: [], + count: 0, + }); + } + + const productsWithUnits = await db + .select({ + id: productInfo.id, + name: productInfo.name, + shortDescription: productInfo.shortDescription, + price: productInfo.price, + marketPrice: productInfo.marketPrice, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + unitShortNotation: units.shortNotation, + productQuantity: productInfo.productQuantity, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)) + .where(whereCondition); + + // Generate signed URLs for product images + const formattedProducts = await Promise.all( + productsWithUnits.map(async (product) => { + const nextDeliveryDate = await getNextDeliveryDate(product.id); + return { + id: product.id, + name: product.name, + shortDescription: product.shortDescription, + price: product.price, + marketPrice: product.marketPrice, + unit: product.unitShortNotation, + productQuantity: product.productQuantity, + isOutOfStock: product.isOutOfStock, + nextDeliveryDate: nextDeliveryDate ? nextDeliveryDate.toISOString() : null, + images: await generateSignedUrlsFromS3Urls((product.images as string[]) || []), + }; + }) + ); + + return res.status(200).json({ + products: formattedProducts, + count: formattedProducts.length, + }); + } catch (error) { + console.error("Get products summary error:", error); + return res.status(500).json({ error: "Failed to fetch products summary" }); + } +}; diff --git a/apps/backend/src/common-apis/common-product.router.ts b/apps/backend/src/common-apis/common-product.router.ts new file mode 100644 index 0000000..5d5b60c --- /dev/null +++ b/apps/backend/src/common-apis/common-product.router.ts @@ -0,0 +1,10 @@ +import { Router } from "express"; +import { getAllProductsSummary } from "./common-product.controller"; + +const router = Router(); + +router.get("/summary", getAllProductsSummary); + + +const commonProductsRouter= router; +export default commonProductsRouter; \ No newline at end of file diff --git a/apps/backend/src/common-apis/common.router.ts b/apps/backend/src/common-apis/common.router.ts new file mode 100644 index 0000000..7f5a9a9 --- /dev/null +++ b/apps/backend/src/common-apis/common.router.ts @@ -0,0 +1,10 @@ +import { Router } from "express"; +import commonProductsRouter from "./common-product.router"; + +const router = Router(); + +router.use('/products', commonProductsRouter) + +const commonRouter = router; + +export default commonRouter; \ No newline at end of file diff --git a/apps/backend/src/db/db_index.ts b/apps/backend/src/db/db_index.ts new file mode 100755 index 0000000..92cbfbb --- /dev/null +++ b/apps/backend/src/db/db_index.ts @@ -0,0 +1,8 @@ +import { drizzle } from "drizzle-orm/node-postgres" +import { migrate } from "drizzle-orm/node-postgres/migrator" +import path from "path" +import * as schema from "./schema" + +const db = drizzle({ connection: process.env.DATABASE_URL!, casing: "snake_case", schema: schema }) +// const db = drizzle('postgresql://postgres:postgres@localhost:2345/pooler'); +export { db } diff --git a/apps/backend/src/db/porter.ts b/apps/backend/src/db/porter.ts new file mode 100644 index 0000000..49165ea --- /dev/null +++ b/apps/backend/src/db/porter.ts @@ -0,0 +1,125 @@ +/* +* This was a one time script to change the composition of the signed urls +*/ + +import { db } from './db_index'; +import { + userDetails, + productInfo, + productTagInfo, + complaints +} from './schema'; +import { eq, not, isNull } from 'drizzle-orm'; + +const S3_DOMAIN = 'https://s3.sgp.io.cloud.ovh.net'; + +const cleanImageUrl = (url: string): string => { + if (url.startsWith(S3_DOMAIN)) { + return url.replace(S3_DOMAIN + '/', ''); + } + return url; +}; + +const cleanImageUrls = (urls: string[]): string[] => { + return urls.map(cleanImageUrl); +}; + +async function migrateUserDetails() { + console.log('Migrating userDetails...'); + const users = await db.select().from(userDetails).where(not(isNull(userDetails.profileImage))); + + console.log(`Found ${users.length} user records with profile images`); + + for (const user of users) { + if (user.profileImage) { + const cleanedUrl = cleanImageUrl(user.profileImage); + await db.update(userDetails) + .set({ profileImage: cleanedUrl }) + .where(eq(userDetails.id, user.id)); + } + } + + console.log('userDetails migration completed'); +} + +async function migrateProductInfo() { + console.log('Migrating productInfo...'); + const products = await db.select().from(productInfo).where(not(isNull(productInfo.images))); + + console.log(`Found ${products.length} product records with images`); + + for (const product of products) { + if (product.images && Array.isArray(product.images)) { + const cleanedUrls = cleanImageUrls(product.images); + await db.update(productInfo) + .set({ images: cleanedUrls }) + .where(eq(productInfo.id, product.id)); + } + } + + console.log('productInfo migration completed'); +} + +async function migrateProductTagInfo() { + console.log('Migrating productTagInfo...'); + const tags = await db.select().from(productTagInfo).where(not(isNull(productTagInfo.imageUrl))); + + console.log(`Found ${tags.length} tag records with images`); + + for (const tag of tags) { + if (tag.imageUrl) { + const cleanedUrl = cleanImageUrl(tag.imageUrl); + await db.update(productTagInfo) + .set({ imageUrl: cleanedUrl }) + .where(eq(productTagInfo.id, tag.id)); + } + } + + console.log('productTagInfo migration completed'); +} + +async function migrateComplaints() { + console.log('Migrating complaints...'); + const complaintRecords = await db.select().from(complaints).where(not(isNull(complaints.images))); + + console.log(`Found ${complaintRecords.length} complaint records with images`); + + for (const complaint of complaintRecords) { + if (complaint.images && Array.isArray(complaint.images)) { + const cleanedUrls = cleanImageUrls(complaint.images); + await db.update(complaints) + .set({ images: cleanedUrls }) + .where(eq(complaints.id, complaint.id)); + } + } + + console.log('complaints migration completed'); +} + +async function runMigration() { + console.log('Starting image URL migration...'); + console.log(`Removing S3 domain: ${S3_DOMAIN}`); + + try { + await migrateUserDetails(); + await migrateProductInfo(); + await migrateProductTagInfo(); + await migrateComplaints(); + + console.log('Migration completed successfully!'); + } catch (error) { + console.error('Migration failed:', error); + throw error; + } +} + +// Run the migration +runMigration() + .then(() => { + console.log('Process completed successfully'); + process.exit(0); + }) + .catch((error) => { + console.error('Process failed:', error); + process.exit(1); + }); \ No newline at end of file diff --git a/apps/backend/src/db/schema.ts b/apps/backend/src/db/schema.ts new file mode 100755 index 0000000..2516f11 --- /dev/null +++ b/apps/backend/src/db/schema.ts @@ -0,0 +1,644 @@ +import { pgTable, pgSchema, integer, varchar, date, boolean, timestamp, numeric, jsonb, pgEnum, unique, real, text, check, decimal } from "drizzle-orm/pg-core"; +import { relations, sql } from "drizzle-orm"; + +const mf = pgSchema('mf'); + + + +export const users = mf.table('users', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + name: varchar({ length: 255 }), + email: varchar({ length: 255 }), + mobile: varchar({ length: 255 }), + createdAt: timestamp('created_at').notNull().defaultNow(), +}, (t) => ({ + unq_email: unique('unique_email').on(t.email), +})); + +export const userDetails = mf.table('user_details', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id).unique(), + bio: varchar('bio', { length: 500 }), + dateOfBirth: date('date_of_birth'), + gender: varchar('gender', { length: 20 }), + occupation: varchar('occupation', { length: 100 }), + profileImage: varchar('profile_image', { length: 500 }), + isSuspended: boolean('is_suspended').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), + updatedAt: timestamp('updated_at').notNull().defaultNow(), +}); + +export const userCreds = mf.table('user_creds', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + userPassword: varchar('user_password', { length: 255 }).notNull(), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const addresses = mf.table('addresses', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + name: varchar('name', { length: 255 }).notNull(), + phone: varchar('phone', { length: 15 }).notNull(), + addressLine1: varchar('address_line1', { length: 255 }).notNull(), + addressLine2: varchar('address_line2', { length: 255 }), + city: varchar('city', { length: 100 }).notNull(), + state: varchar('state', { length: 100 }).notNull(), + pincode: varchar('pincode', { length: 10 }).notNull(), + isDefault: boolean('is_default').notNull().default(false), + latitude: real('latitude'), + longitude: real('longitude'), + zoneId: integer('zone_id').references(() => addressZones.id), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const addressZones = mf.table('address_zones', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + zoneName: varchar('zone_name', { length: 255 }).notNull(), + addedAt: timestamp('added_at').notNull().defaultNow(), +}); + +export const addressAreas = mf.table('address_areas', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + placeName: varchar('place_name', { length: 255 }).notNull(), + zoneId: integer('zone_id').references(() => addressZones.id), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const staffUsers = mf.table('staff_users', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + name: varchar({ length: 255 }).notNull(), + password: varchar({ length: 255 }).notNull(), + staffRoleId: integer('staff_role_id').references(() => staffRoles.id), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const storeInfo = mf.table('store_info', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + name: varchar({ length: 255 }).notNull(), + description: varchar({ length: 500 }), + imageUrl: varchar('image_url', { length: 500 }), + createdAt: timestamp('created_at').notNull().defaultNow(), + owner: integer('owner').notNull().references(() => staffUsers.id), +}); + +export const units = mf.table('units', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + shortNotation: varchar('short_notation', { length: 50 }).notNull(), + fullName: varchar('full_name', { length: 100 }).notNull(), +}, (t) => ({ + unq_short_notation: unique('unique_short_notation').on(t.shortNotation), +})); + +export const productInfo = mf.table('product_info', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + name: varchar({ length: 255 }).notNull(), + shortDescription: varchar('short_description', { length: 500 }), + longDescription: varchar('long_description', { length: 1000 }), + unitId: integer('unit_id').notNull().references(() => units.id), + price: numeric({ precision: 10, scale: 2 }).notNull(), + marketPrice: numeric('market_price', { precision: 10, scale: 2 }), + images: jsonb('images'), + isOutOfStock: boolean('is_out_of_stock').notNull().default(false), + isSuspended: boolean('is_suspended').notNull().default(false), + isFlashAvailable: boolean('is_flash_available').notNull().default(false), + flashPrice: numeric('flash_price', { precision: 10, scale: 2 }), + createdAt: timestamp('created_at').notNull().defaultNow(), + incrementStep: real('increment_step').notNull().default(1), + productQuantity: real('product_quantity').notNull().default(1), + storeId: integer('store_id').references(() => storeInfo.id), +}); + +export const productGroupInfo = mf.table('product_group_info', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + groupName: varchar('group_name', { length: 255 }).notNull(), + description: varchar({ length: 500 }), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const productGroupMembership = mf.table('product_group_membership', { + productId: integer('product_id').notNull().references(() => productInfo.id), + groupId: integer('group_id').notNull().references(() => productGroupInfo.id), + addedAt: timestamp('added_at').notNull().defaultNow(), +}, (t) => ({ + pk: unique('product_group_membership_pk').on(t.productId, t.groupId), +})); + +export const homeBanners = mf.table('home_banners', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + name: varchar('name', { length: 255 }).notNull(), + imageUrl: varchar('image_url', { length: 500 }).notNull(), + description: varchar('description', { length: 500 }), + productIds: integer('product_ids').array(), + redirectUrl: varchar('redirect_url', { length: 500 }), + serialNum: integer('serial_num'), + isActive: boolean('is_active').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), + lastUpdated: timestamp('last_updated').notNull().defaultNow(), +}); + +export const productReviews = mf.table('product_reviews', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + productId: integer('product_id').notNull().references(() => productInfo.id), + reviewBody: text('review_body').notNull(), + imageUrls: jsonb('image_urls').$defaultFn(() => []), + reviewTime: timestamp('review_time').notNull().defaultNow(), + ratings: real('ratings').notNull(), + adminResponse: text('admin_response'), + adminResponseImages: jsonb('admin_response_images').$defaultFn(() => []), +}, (t) => ({ + ratingCheck: check('rating_check', sql`${t.ratings} >= 1 AND ${t.ratings} <= 5`), +})); + +export const uploadStatusEnum = pgEnum('upload_status', ['pending', 'claimed']); + +export const staffRoleEnum = pgEnum('staff_role', ['super_admin', 'admin', 'marketer', 'delivery_staff']); + +export const staffPermissionEnum = pgEnum('staff_permission', ['crud_product', 'make_coupon', 'crud_staff_users']); + +export const uploadUrlStatus = mf.table('upload_url_status', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + createdAt: timestamp('created_at').notNull().defaultNow(), + key: varchar('key', { length: 500 }).notNull(), + status: uploadStatusEnum('status').notNull().default('pending'), +}); + +export const productTagInfo = mf.table('product_tag_info', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + tagName: varchar('tag_name', { length: 100 }).notNull().unique(), + tagDescription: varchar('tag_description', { length: 500 }), + imageUrl: varchar('image_url', { length: 500 }), + isDashboardTag: boolean('is_dashboard_tag').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const productTags = mf.table('product_tags', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + productId: integer('product_id').notNull().references(() => productInfo.id), + tagId: integer('tag_id').notNull().references(() => productTagInfo.id), + assignedAt: timestamp('assigned_at').notNull().defaultNow(), +}, (t) => ({ + unq_product_tag: unique('unique_product_tag').on(t.productId, t.tagId), +})); + +export const deliverySlotInfo = mf.table('delivery_slot_info', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + deliveryTime: timestamp('delivery_time').notNull(), + freezeTime: timestamp('freeze_time').notNull(), + isActive: boolean('is_active').notNull().default(true), + isFlash: boolean('is_flash').notNull().default(false), + deliverySequence: jsonb('delivery_sequence').$defaultFn(() => {}), +}); + +export const vendorSnippets = mf.table('vendor_snippets', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + snippetCode: varchar('snippet_code', { length: 255 }).notNull().unique(), + slotId: integer('slot_id').notNull().references(() => deliverySlotInfo.id), + productIds: integer('product_ids').array().notNull(), + validTill: timestamp('valid_till'), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const vendorSnippetsRelations = relations(vendorSnippets, ({ one }) => ({ + slot: one(deliverySlotInfo, { fields: [vendorSnippets.slotId], references: [deliverySlotInfo.id] }), +})); + +export const productSlots = mf.table('product_slots', { + productId: integer('product_id').notNull().references(() => productInfo.id), + slotId: integer('slot_id').notNull().references(() => deliverySlotInfo.id), +}, (t) => ({ + pk: unique('product_slot_pk').on(t.productId, t.slotId), +})); + +export const specialDeals = mf.table('special_deals', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + productId: integer('product_id').notNull().references(() => productInfo.id), + quantity: numeric({ precision: 10, scale: 2 }).notNull(), + price: numeric({ precision: 10, scale: 2 }).notNull(), + validTill: timestamp('valid_till').notNull(), +}); + +export const orders = mf.table('orders', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + addressId: integer('address_id').notNull().references(() => addresses.id), + slotId: integer('slot_id').references(() => deliverySlotInfo.id), + isCod: boolean('is_cod').notNull().default(false), + isOnlinePayment: boolean('is_online_payment').notNull().default(false), + paymentInfoId: integer('payment_info_id').references(() => paymentInfoTable.id), + totalAmount: numeric('total_amount', { precision: 10, scale: 2 }).notNull(), + deliveryCharge: numeric('delivery_charge', { precision: 10, scale: 2 }).notNull().default('0'), + readableId: integer('readable_id').notNull(), + adminNotes: text('admin_notes'), + userNotes: text('user_notes'), + orderGroupId: varchar('order_group_id', { length: 255 }), + orderGroupProportion: decimal('order_group_proportion', { precision: 10, scale: 4 }), + isFlashDelivery: boolean('is_flash_delivery').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const orderItems = mf.table('order_items', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + orderId: integer('order_id').notNull().references(() => orders.id), + productId: integer('product_id').notNull().references(() => productInfo.id), + quantity: varchar('quantity', { length: 50 }).notNull(), + price: numeric({ precision: 10, scale: 2 }).notNull(), + discountedPrice: numeric('discounted_price', { precision: 10, scale: 2 }), + is_packaged: boolean('is_packaged').notNull().default(false), + is_package_verified: boolean('is_package_verified').notNull().default(false), +}); + +export const paymentStatusEnum = pgEnum('payment_status', ['pending', 'success', 'cod', 'failed']); + +export const orderStatus = mf.table('order_status', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + orderTime: timestamp('order_time').notNull().defaultNow(), + userId: integer('user_id').notNull().references(() => users.id), + orderId: integer('order_id').notNull().references(() => orders.id), + isPackaged: boolean('is_packaged').notNull().default(false), + isDelivered: boolean('is_delivered').notNull().default(false), + isCancelled: boolean('is_cancelled').notNull().default(false), + cancelReason: varchar('cancel_reason', { length: 255 }), + isCancelledByAdmin: boolean('is_cancelled_by_admin'), + paymentStatus: paymentStatusEnum('payment_state').notNull().default('pending'), + cancellationUserNotes: text('cancellation_user_notes'), + cancellationAdminNotes: text('cancellation_admin_notes'), + cancellationReviewed: boolean('cancellation_reviewed').notNull().default(false), + cancellationReviewedAt: timestamp('cancellation_reviewed_at'), + refundCouponId: integer('refund_coupon_id').references(() => coupons.id), +}); + +export const paymentInfoTable = mf.table('payment_info', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + status: varchar({ length: 50 }).notNull(), + gateway: varchar({ length: 50 }).notNull(), + orderId: varchar('order_id', { length: 500 }), + token: varchar({ length: 500 }), + merchantOrderId: varchar('merchant_order_id', { length: 255 }).notNull().unique(), + payload: jsonb('payload'), +}); + +export const payments = mf.table('payments', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + status: varchar({ length: 50 }).notNull(), + gateway: varchar({ length: 50 }).notNull(), + orderId: integer('order_id').notNull().references(() => orders.id), + token: varchar({ length: 500 }), + merchantOrderId: varchar('merchant_order_id', { length: 255 }).notNull().unique(), + payload: jsonb('payload'), +}); + +export const refunds = mf.table('refunds', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + orderId: integer('order_id').notNull().references(() => orders.id), + refundAmount: numeric('refund_amount', { precision: 10, scale: 2 }), + refundStatus: varchar('refund_status', { length: 50 }).default('none'), + merchantRefundId: varchar('merchant_refund_id', { length: 255 }), + refundProcessedAt: timestamp('refund_processed_at'), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const keyValStore = mf.table('key_val_store', { + key: varchar('key', { length: 255 }).primaryKey(), + value: jsonb('value'), +}); + +export const notifications = mf.table('notifications', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + title: varchar({ length: 255 }).notNull(), + body: varchar({ length: 512 }).notNull(), + type: varchar({ length: 50 }), + isRead: boolean('is_read').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const productCategories = mf.table('product_categories', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + name: varchar({ length: 255 }).notNull(), + description: varchar({ length: 500 }), +}); + +export const cartItems = mf.table('cart_items', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + productId: integer('product_id').notNull().references(() => productInfo.id), + quantity: numeric({ precision: 10, scale: 2 }).notNull(), + addedAt: timestamp('added_at').notNull().defaultNow(), +}, (t) => ({ + unq_user_product: unique('unique_user_product').on(t.userId, t.productId), +})); + +export const complaints = mf.table('complaints', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + orderId: integer('order_id').references(() => orders.id), + complaintBody: varchar('complaint_body', { length: 1000 }).notNull(), + images: jsonb('images'), + response: varchar('response', { length: 1000 }), + isResolved: boolean('is_resolved').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const coupons = mf.table('coupons', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + couponCode: varchar('coupon_code', { length: 50 }).notNull().unique('unique_coupon_code'), + isUserBased: boolean('is_user_based').notNull().default(false), + discountPercent: numeric('discount_percent', { precision: 5, scale: 2 }), + flatDiscount: numeric('flat_discount', { precision: 10, scale: 2 }), + minOrder: numeric('min_order', { precision: 10, scale: 2 }), + productIds: jsonb('product_ids'), + createdBy: integer('created_by').references(() => staffUsers.id), + maxValue: numeric('max_value', { precision: 10, scale: 2 }), + isApplyForAll: boolean('is_apply_for_all').notNull().default(false), + validTill: timestamp('valid_till'), + maxLimitForUser: integer('max_limit_for_user'), + isInvalidated: boolean('is_invalidated').notNull().default(false), + exclusiveApply: boolean('exclusive_apply').notNull().default(false), + createdAt: timestamp('created_at').notNull().defaultNow(), +}); + +export const couponUsage = mf.table('coupon_usage', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + userId: integer('user_id').notNull().references(() => users.id), + couponId: integer('coupon_id').notNull().references(() => coupons.id), + orderId: integer('order_id').references(() => orders.id), + orderItemId: integer('order_item_id').references(() => orderItems.id), + usedAt: timestamp('used_at').notNull().defaultNow(), +}); + +export const couponApplicableUsers = mf.table('coupon_applicable_users', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + couponId: integer('coupon_id').notNull().references(() => coupons.id), + userId: integer('user_id').notNull().references(() => users.id), +}, (t) => ({ + unq_coupon_user: unique('unique_coupon_user').on(t.couponId, t.userId), +})); + +export const couponApplicableProducts = mf.table('coupon_applicable_products', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + couponId: integer('coupon_id').notNull().references(() => coupons.id), + productId: integer('product_id').notNull().references(() => productInfo.id), +}, (t) => ({ + unq_coupon_product: unique('unique_coupon_product').on(t.couponId, t.productId), +})); + +export const reservedCoupons = mf.table('reserved_coupons', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + secretCode: varchar('secret_code', { length: 50 }).notNull().unique(), + couponCode: varchar('coupon_code', { length: 50 }).notNull(), + discountPercent: numeric('discount_percent', { precision: 5, scale: 2 }), + flatDiscount: numeric('flat_discount', { precision: 10, scale: 2 }), + minOrder: numeric('min_order', { precision: 10, scale: 2 }), + productIds: jsonb('product_ids'), + maxValue: numeric('max_value', { precision: 10, scale: 2 }), + validTill: timestamp('valid_till'), + maxLimitForUser: integer('max_limit_for_user'), + exclusiveApply: boolean('exclusive_apply').notNull().default(false), + isRedeemed: boolean('is_redeemed').notNull().default(false), + redeemedBy: integer('redeemed_by').references(() => users.id), + redeemedAt: timestamp('redeemed_at'), + createdBy: integer('created_by').notNull().references(() => staffUsers.id), + createdAt: timestamp('created_at').notNull().defaultNow(), +}, (t) => ({ + unq_secret_code: unique('unique_secret_code').on(t.secretCode), +})); + +export const notifCreds = mf.table('notif_creds', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + token: varchar({ length: 500 }).notNull().unique(), + addedAt: timestamp('added_at').notNull().defaultNow(), + userId: integer('user_id').notNull().references(() => users.id), + lastVerified: timestamp('last_verified'), +}); + +export const staffRoles = mf.table('staff_roles', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + roleName: staffRoleEnum('role_name').notNull(), + createdAt: timestamp('created_at').notNull().defaultNow(), +}, (t) => ({ + unq_role_name: unique('unique_role_name').on(t.roleName), +})); + +export const staffPermissions = mf.table('staff_permissions', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + permissionName: staffPermissionEnum('permission_name').notNull(), + createdAt: timestamp('created_at').notNull().defaultNow(), +}, (t) => ({ + unq_permission_name: unique('unique_permission_name').on(t.permissionName), +})); + +export const staffRolePermissions = mf.table('staff_role_permissions', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + staffRoleId: integer('staff_role_id').notNull().references(() => staffRoles.id), + staffPermissionId: integer('staff_permission_id').notNull().references(() => staffPermissions.id), + createdAt: timestamp('created_at').notNull().defaultNow(), +}, (t) => ({ + unq_role_permission: unique('unique_role_permission').on(t.staffRoleId, t.staffPermissionId), +})); + +// Relations +export const usersRelations = relations(users, ({ many, one }) => ({ + addresses: many(addresses), + orders: many(orders), + notifications: many(notifications), + cartItems: many(cartItems), + userCreds: one(userCreds), + coupons: many(coupons), + couponUsages: many(couponUsage), + applicableCoupons: many(couponApplicableUsers), + userDetails: one(userDetails), + notifCreds: many(notifCreds), +})); + +export const userCredsRelations = relations(userCreds, ({ one }) => ({ + user: one(users, { fields: [userCreds.userId], references: [users.id] }), +})); + +export const staffUsersRelations = relations(staffUsers, ({ one, many }) => ({ + role: one(staffRoles, { fields: [staffUsers.staffRoleId], references: [staffRoles.id] }), + coupons: many(coupons), + stores: many(storeInfo), +})); + +export const addressesRelations = relations(addresses, ({ one, many }) => ({ + user: one(users, { fields: [addresses.userId], references: [users.id] }), + orders: many(orders), + zone: one(addressZones, { fields: [addresses.zoneId], references: [addressZones.id] }), +})); + +export const unitsRelations = relations(units, ({ many }) => ({ + products: many(productInfo), +})); + +export const productInfoRelations = relations(productInfo, ({ one, many }) => ({ + unit: one(units, { fields: [productInfo.unitId], references: [units.id] }), + store: one(storeInfo, { fields: [productInfo.storeId], references: [storeInfo.id] }), + productSlots: many(productSlots), + specialDeals: many(specialDeals), + orderItems: many(orderItems), + cartItems: many(cartItems), + tags: many(productTags), + applicableCoupons: many(couponApplicableProducts), + reviews: many(productReviews), + groups: many(productGroupMembership), +})); + +export const productTagInfoRelations = relations(productTagInfo, ({ many }) => ({ + products: many(productTags), +})); + +export const productTagsRelations = relations(productTags, ({ one }) => ({ + product: one(productInfo, { fields: [productTags.productId], references: [productInfo.id] }), + tag: one(productTagInfo, { fields: [productTags.tagId], references: [productTagInfo.id] }), +})); + +export const deliverySlotInfoRelations = relations(deliverySlotInfo, ({ many }) => ({ + productSlots: many(productSlots), + orders: many(orders), + vendorSnippets: many(vendorSnippets), +})); + +export const productSlotsRelations = relations(productSlots, ({ one }) => ({ + product: one(productInfo, { fields: [productSlots.productId], references: [productInfo.id] }), + slot: one(deliverySlotInfo, { fields: [productSlots.slotId], references: [deliverySlotInfo.id] }), +})); + +export const specialDealsRelations = relations(specialDeals, ({ one }) => ({ + product: one(productInfo, { fields: [specialDeals.productId], references: [productInfo.id] }), +})); + +export const ordersRelations = relations(orders, ({ one, many }) => ({ + user: one(users, { fields: [orders.userId], references: [users.id] }), + address: one(addresses, { fields: [orders.addressId], references: [addresses.id] }), + slot: one(deliverySlotInfo, { fields: [orders.slotId], references: [deliverySlotInfo.id] }), + orderItems: many(orderItems), + payment: one(payments), + paymentInfo: one(paymentInfoTable, { fields: [orders.paymentInfoId], references: [paymentInfoTable.id] }), + orderStatus: many(orderStatus), + refunds: many(refunds), + couponUsages: many(couponUsage), +})); + +export const orderItemsRelations = relations(orderItems, ({ one }) => ({ + order: one(orders, { fields: [orderItems.orderId], references: [orders.id] }), + product: one(productInfo, { fields: [orderItems.productId], references: [productInfo.id] }), +})); + +export const orderStatusRelations = relations(orderStatus, ({ one }) => ({ + order: one(orders, { fields: [orderStatus.orderId], references: [orders.id] }), + user: one(users, { fields: [orderStatus.userId], references: [users.id] }), + refundCoupon: one(coupons, { fields: [orderStatus.refundCouponId], references: [coupons.id] }), +})); + +export const paymentInfoRelations = relations(paymentInfoTable, ({ one }) => ({ + order: one(orders, { fields: [paymentInfoTable.id], references: [orders.paymentInfoId] }), +})); + +export const paymentsRelations = relations(payments, ({ one }) => ({ + order: one(orders, { fields: [payments.orderId], references: [orders.id] }), +})); + +export const refundsRelations = relations(refunds, ({ one }) => ({ + order: one(orders, { fields: [refunds.orderId], references: [orders.id] }), +})); + +export const notificationsRelations = relations(notifications, ({ one }) => ({ + user: one(users, { fields: [notifications.userId], references: [users.id] }), +})); + +export const productCategoriesRelations = relations(productCategories, ({}) => ({})); + +export const cartItemsRelations = relations(cartItems, ({ one }) => ({ + user: one(users, { fields: [cartItems.userId], references: [users.id] }), + product: one(productInfo, { fields: [cartItems.productId], references: [productInfo.id] }), +})); + +export const complaintsRelations = relations(complaints, ({ one }) => ({ + user: one(users, { fields: [complaints.userId], references: [users.id] }), + order: one(orders, { fields: [complaints.orderId], references: [orders.id] }), +})); + +export const couponsRelations = relations(coupons, ({ one, many }) => ({ + creator: one(staffUsers, { fields: [coupons.createdBy], references: [staffUsers.id] }), + usages: many(couponUsage), + applicableUsers: many(couponApplicableUsers), + applicableProducts: many(couponApplicableProducts), +})); + +export const couponUsageRelations = relations(couponUsage, ({ one }) => ({ + user: one(users, { fields: [couponUsage.userId], references: [users.id] }), + coupon: one(coupons, { fields: [couponUsage.couponId], references: [coupons.id] }), + order: one(orders, { fields: [couponUsage.orderId], references: [orders.id] }), + orderItem: one(orderItems, { fields: [couponUsage.orderItemId], references: [orderItems.id] }), +})); + +export const userDetailsRelations = relations(userDetails, ({ one }) => ({ + user: one(users, { fields: [userDetails.userId], references: [users.id] }), +})); + +export const notifCredsRelations = relations(notifCreds, ({ one }) => ({ + user: one(users, { fields: [notifCreds.userId], references: [users.id] }), +})); + +export const storeInfoRelations = relations(storeInfo, ({ one, many }) => ({ + owner: one(staffUsers, { fields: [storeInfo.owner], references: [staffUsers.id] }), + products: many(productInfo), +})); + +export const couponApplicableUsersRelations = relations(couponApplicableUsers, ({ one }) => ({ + coupon: one(coupons, { fields: [couponApplicableUsers.couponId], references: [coupons.id] }), + user: one(users, { fields: [couponApplicableUsers.userId], references: [users.id] }), +})); + +export const couponApplicableProductsRelations = relations(couponApplicableProducts, ({ one }) => ({ + coupon: one(coupons, { fields: [couponApplicableProducts.couponId], references: [coupons.id] }), + product: one(productInfo, { fields: [couponApplicableProducts.productId], references: [productInfo.id] }), +})); + +export const reservedCouponsRelations = relations(reservedCoupons, ({ one }) => ({ + redeemedUser: one(users, { fields: [reservedCoupons.redeemedBy], references: [users.id] }), + creator: one(staffUsers, { fields: [reservedCoupons.createdBy], references: [staffUsers.id] }), +})); + +export const productReviewsRelations = relations(productReviews, ({ one }) => ({ + user: one(users, { fields: [productReviews.userId], references: [users.id] }), + product: one(productInfo, { fields: [productReviews.productId], references: [productInfo.id] }), +})); + +export const addressZonesRelations = relations(addressZones, ({ many }) => ({ + addresses: many(addresses), + areas: many(addressAreas), +})); + +export const addressAreasRelations = relations(addressAreas, ({ one }) => ({ + zone: one(addressZones, { fields: [addressAreas.zoneId], references: [addressZones.id] }), +})); + +export const productGroupInfoRelations = relations(productGroupInfo, ({ many }) => ({ + memberships: many(productGroupMembership), +})); + +export const productGroupMembershipRelations = relations(productGroupMembership, ({ one }) => ({ + product: one(productInfo, { fields: [productGroupMembership.productId], references: [productInfo.id] }), + group: one(productGroupInfo, { fields: [productGroupMembership.groupId], references: [productGroupInfo.id] }), +})); + +export const homeBannersRelations = relations(homeBanners, ({}) => ({ + // Relations for productIds array would be more complex, skipping for now +})); + +export const staffRolesRelations = relations(staffRoles, ({ many }) => ({ + staffUsers: many(staffUsers), + rolePermissions: many(staffRolePermissions), +})); + +export const staffPermissionsRelations = relations(staffPermissions, ({ many }) => ({ + rolePermissions: many(staffRolePermissions), +})); + +export const staffRolePermissionsRelations = relations(staffRolePermissions, ({ one }) => ({ + role: one(staffRoles, { fields: [staffRolePermissions.staffRoleId], references: [staffRoles.id] }), + permission: one(staffPermissions, { fields: [staffRolePermissions.staffPermissionId], references: [staffPermissions.id] }), +})); \ No newline at end of file diff --git a/apps/backend/src/db/seed.ts b/apps/backend/src/db/seed.ts new file mode 100644 index 0000000..aa1c05e --- /dev/null +++ b/apps/backend/src/db/seed.ts @@ -0,0 +1,137 @@ +import { db } from "./db_index"; +import { units, productInfo, deliverySlotInfo, productSlots, keyValStore, staffRoles, staffPermissions, staffRolePermissions } from "./schema"; +import { eq } from "drizzle-orm"; +import { minOrderValue, deliveryCharge } from '../lib/env-exporter'; +import { CONST_KEYS } from '../lib/const-keys'; + +export async function seed() { + console.log("Seeding database..."); + + // Seed units individually + const unitsToSeed = [ + { shortNotation: "Kg", fullName: "Kilogram" }, + { shortNotation: "L", fullName: "Litre" }, + { shortNotation: "Dz", fullName: "Dozen" }, + { shortNotation: "Pc", fullName: "Unit Piece" }, + ]; + + for (const unit of unitsToSeed) { + const existingUnit = await db.query.units.findFirst({ + where: eq(units.shortNotation, unit.shortNotation), + }); + if (!existingUnit) { + await db.insert(units).values(unit); + } + } + + // Seed staff roles individually + const rolesToSeed = ['super_admin', 'admin', 'marketer', 'delivery_staff'] as const; + + for (const roleName of rolesToSeed) { + const existingRole = await db.query.staffRoles.findFirst({ + where: eq(staffRoles.roleName, roleName), + }); + if (!existingRole) { + await db.insert(staffRoles).values({ roleName }); + } + } + + // Seed staff permissions individually + const permissionsToSeed = ['crud_product', 'make_coupon', 'crud_staff_users'] as const; + + for (const permissionName of permissionsToSeed) { + const existingPermission = await db.query.staffPermissions.findFirst({ + where: eq(staffPermissions.permissionName, permissionName), + }); + if (!existingPermission) { + await db.insert(staffPermissions).values({ permissionName }); + } + } + + // Seed role-permission assignments + await db.transaction(async (tx) => { + // Get role IDs + const superAdminRole = await tx.query.staffRoles.findFirst({ where: eq(staffRoles.roleName, 'super_admin') }); + const adminRole = await tx.query.staffRoles.findFirst({ where: eq(staffRoles.roleName, 'admin') }); + const marketerRole = await tx.query.staffRoles.findFirst({ where: eq(staffRoles.roleName, 'marketer') }); + + // Get permission IDs + const crudProductPerm = await tx.query.staffPermissions.findFirst({ where: eq(staffPermissions.permissionName, 'crud_product') }); + const makeCouponPerm = await tx.query.staffPermissions.findFirst({ where: eq(staffPermissions.permissionName, 'make_coupon') }); + const crudStaffUsersPerm = await tx.query.staffPermissions.findFirst({ where: eq(staffPermissions.permissionName, 'crud_staff_users') }); + + // Assign all permissions to super_admin + [crudProductPerm, makeCouponPerm, crudStaffUsersPerm].forEach(async (perm) => { + if (superAdminRole && perm) { + const existingSuperAdminPerm = await tx.query.staffRolePermissions.findFirst({ + where: eq(staffRolePermissions.staffRoleId, superAdminRole.id) && eq(staffRolePermissions.staffPermissionId, perm.id), + }); + if (!existingSuperAdminPerm) { + await tx.insert(staffRolePermissions).values({ + staffRoleId: superAdminRole.id, + staffPermissionId: perm.id, + }); + } + } + }); + + // Assign all permissions to admin + [crudProductPerm, makeCouponPerm].forEach(async (perm) => { + if (adminRole && perm) { + const existingAdminPerm = await tx.query.staffRolePermissions.findFirst({ + where: eq(staffRolePermissions.staffRoleId, adminRole.id) && eq(staffRolePermissions.staffPermissionId, perm.id), + }); + if (!existingAdminPerm) { + await tx.insert(staffRolePermissions).values({ + staffRoleId: adminRole.id, + staffPermissionId: perm.id, + }); + } + } + }); + + // Assign make_coupon to marketer + if (marketerRole && makeCouponPerm) { + const existingMarketerCoupon = await tx.query.staffRolePermissions.findFirst({ + where: eq(staffRolePermissions.staffRoleId, marketerRole.id) && eq(staffRolePermissions.staffPermissionId, makeCouponPerm.id), + }); + if (!existingMarketerCoupon) { + await tx.insert(staffRolePermissions).values({ + staffRoleId: marketerRole.id, + staffPermissionId: makeCouponPerm.id, + }); + } + } + }); + + // Seed key-val store constants using CONST_KEYS + const constantsToSeed = [ + { key: CONST_KEYS.readableOrderId, value: 0 }, + { key: CONST_KEYS.minRegularOrderValue, value: minOrderValue }, + { key: CONST_KEYS.freeDeliveryThreshold, value: minOrderValue }, + { key: CONST_KEYS.deliveryCharge, value: deliveryCharge }, + { key: CONST_KEYS.flashFreeDeliveryThreshold, value: 500 }, + { key: CONST_KEYS.flashDeliveryCharge, value: 69 }, + { key: CONST_KEYS.popularItems, value: [] }, + { key: CONST_KEYS.versionNum, value: '1.1.0' }, + { key: CONST_KEYS.playStoreUrl, value: 'https://play.google.com/store/apps/details?id=in.freshyo.app' }, + { key: CONST_KEYS.appStoreUrl, value: 'https://play.google.com/store/apps/details?id=in.freshyo.app' }, + { key: CONST_KEYS.isFlashDeliveryEnabled, value: false }, + { key: CONST_KEYS.supportMobile, value: '8688182552' }, + { key: CONST_KEYS.supportEmail, value: 'qushammohd@gmail.com' }, + ]; + + for (const constant of constantsToSeed) { + const existing = await db.query.keyValStore.findFirst({ + where: eq(keyValStore.key, constant.key), + }); + if (!existing) { + await db.insert(keyValStore).values({ + key: constant.key, + value: constant.value, + }); + } + } + + console.log("Seeding completed."); +} \ No newline at end of file diff --git a/apps/backend/src/db/types.ts b/apps/backend/src/db/types.ts new file mode 100755 index 0000000..78c549f --- /dev/null +++ b/apps/backend/src/db/types.ts @@ -0,0 +1,47 @@ +import type { InferSelectModel } from "drizzle-orm"; +import type { + users, + addresses, + units, + productInfo, + deliverySlotInfo, + productSlots, + specialDeals, + orders, + orderItems, + payments, + notifications, + productCategories, + cartItems, + coupons, +} from "./schema"; + +export type User = InferSelectModel; +export type Address = InferSelectModel; +export type Unit = InferSelectModel; +export type ProductInfo = InferSelectModel; +export type DeliverySlotInfo = InferSelectModel; +export type ProductSlot = InferSelectModel; +export type SpecialDeal = InferSelectModel; +export type Order = InferSelectModel; +export type OrderItem = InferSelectModel; +export type Payment = InferSelectModel; +export type Notification = InferSelectModel; +export type ProductCategory = InferSelectModel; +export type CartItem = InferSelectModel; +export type Coupon = InferSelectModel; + +// Combined types +export type ProductWithUnit = ProductInfo & { + unit: Unit; +}; + +export type OrderWithItems = Order & { + items: (OrderItem & { product: ProductInfo })[]; + address: Address; + slot: DeliverySlotInfo; +}; + +export type CartItemWithProduct = CartItem & { + product: ProductInfo; +}; \ No newline at end of file diff --git a/apps/backend/src/jobs/jobs-index.ts b/apps/backend/src/jobs/jobs-index.ts new file mode 100644 index 0000000..1e64d68 --- /dev/null +++ b/apps/backend/src/jobs/jobs-index.ts @@ -0,0 +1,28 @@ +import * as cron from 'node-cron'; +import { checkPendingPayments, checkRefundStatuses } from './payment-status-checker'; + +const runCombinedJob = async () => { + const start = Date.now(); + try { + console.log('Starting combined job: payments and refunds check'); + + // Run payment check + // await checkPendingPayments(); + + // Run refund check + // await checkRefundStatuses(); + + console.log('Combined job completed successfully'); + } catch (error) { + console.error('Error in combined job:', error); + } finally { + const duration = Date.now() - start; + console.log(`Combined job took ${duration}ms`); + } +}; + +// Run on startup +runCombinedJob(); + +// Schedule combined cron job every 10 minutes +cron.schedule('*/10 * * * *', runCombinedJob); \ No newline at end of file diff --git a/apps/backend/src/jobs/payment-status-checker.ts b/apps/backend/src/jobs/payment-status-checker.ts new file mode 100644 index 0000000..92f72b1 --- /dev/null +++ b/apps/backend/src/jobs/payment-status-checker.ts @@ -0,0 +1,79 @@ +import * as cron from 'node-cron'; +import { db } from '../db/db_index'; +import { payments, orders, deliverySlotInfo, refunds } from '../db/schema'; +import { eq, and, gt, isNotNull } from 'drizzle-orm'; +import { RazorpayPaymentService } from '../lib/payments-utils'; + +interface PendingPaymentRecord { + payment: typeof payments.$inferSelect; + order: typeof orders.$inferSelect; + slot: typeof deliverySlotInfo.$inferSelect; +} + +export const createPaymentNotification = (record: PendingPaymentRecord) => { + // Construct message from record data + const message = `Payment pending for order ORD${record.order.readableId.toString().padStart(3, '0')}. Please complete before orders close time.`; + + // TODO: Implement notification sending logic using record.order.userId, record.order.id, message + console.log(`Sending notification to user ${record.order.userId} for order ${record.order.id}: ${message}`); +}; + +export const checkRefundStatuses = async () => { + try { + const initiatedRefunds = await db + .select() + .from(refunds) + .where(and( + eq(refunds.refundStatus, 'initiated'), + isNotNull(refunds.merchantRefundId) + )); + + // Process refunds concurrently using Promise.allSettled + const promises = initiatedRefunds.map(async (refund) => { + if (!refund.merchantRefundId) return; + + try { + const razorpayRefund = await RazorpayPaymentService.fetchRefund(refund.merchantRefundId); + + if (razorpayRefund.status === 'processed') { + await db + .update(refunds) + .set({ refundStatus: 'success', refundProcessedAt: new Date() }) + .where(eq(refunds.id, refund.id)); + } + } catch (error) { + console.error(`Error checking refund ${refund.id}:`, error); + } + }); + + // Wait for all promises to complete + await Promise.allSettled(promises); + } catch (error) { + console.error('Error in checkRefundStatuses:', error); + } +}; + +export const checkPendingPayments = async () => { + try { + const pendingPayments = await db + .select({ + payment: payments, + order: orders, + slot: deliverySlotInfo, + }) + .from(payments) + .innerJoin(orders, eq(payments.orderId, orders.id)) + .innerJoin(deliverySlotInfo, eq(orders.slotId, deliverySlotInfo.id)) + .where(and( + eq(payments.status, 'pending'), + gt(deliverySlotInfo.freezeTime, new Date()) // Freeze time not passed + )); + + for (const record of pendingPayments) { + createPaymentNotification(record); + } + } catch (error) { + console.error('Error checking pending payments:', error); + } +}; + diff --git a/apps/backend/src/lib/api-error.ts b/apps/backend/src/lib/api-error.ts new file mode 100755 index 0000000..03373f3 --- /dev/null +++ b/apps/backend/src/lib/api-error.ts @@ -0,0 +1,14 @@ +export class ApiError extends Error { + public statusCode: number; + public details?: any; + + constructor(message: string, statusCode: number = 500, details?: any) { + console.log(message) + + super(message); + this.name = 'ApiError'; + this.statusCode = statusCode; + this.details = details; + Error.captureStackTrace?.(this, ApiError); + } +} \ No newline at end of file diff --git a/apps/backend/src/lib/axios.ts b/apps/backend/src/lib/axios.ts new file mode 100755 index 0000000..636e216 --- /dev/null +++ b/apps/backend/src/lib/axios.ts @@ -0,0 +1,10 @@ +import axiosParent from "axios"; +import { phonePeBaseUrl } from "./env-exporter"; + +export const phonepeAxios = axiosParent.create({ + baseURL: phonePeBaseUrl, + timeout: 40000, + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, +}); diff --git a/apps/backend/src/lib/catch-async.ts b/apps/backend/src/lib/catch-async.ts new file mode 100755 index 0000000..d78004b --- /dev/null +++ b/apps/backend/src/lib/catch-async.ts @@ -0,0 +1,6 @@ +import express from 'express'; +const catchAsync = + (fn: express.RequestHandler) => + (req: express.Request, res: express.Response, next: express.NextFunction) => + Promise.resolve(fn(req, res, next)).catch(next); +export default catchAsync; \ No newline at end of file diff --git a/apps/backend/src/lib/const-keys.ts b/apps/backend/src/lib/const-keys.ts new file mode 100644 index 0000000..1431e98 --- /dev/null +++ b/apps/backend/src/lib/const-keys.ts @@ -0,0 +1,45 @@ +export const CONST_KEYS = { + minRegularOrderValue: 'minRegularOrderValue', + freeDeliveryThreshold: 'freeDeliveryThreshold', + deliveryCharge: 'deliveryCharge', + flashFreeDeliveryThreshold: 'flashFreeDeliveryThreshold', + flashDeliveryCharge: 'flashDeliveryCharge', + platformFeePercent: 'platformFeePercent', + taxRate: 'taxRate', + minOrderAmountForCoupon: 'minOrderAmountForCoupon', + maxCouponDiscount: 'maxCouponDiscount', + flashDeliverySlotId: 'flashDeliverySlotId', + readableOrderId: 'readableOrderId', + versionNum: 'versionNum', + playStoreUrl: 'playStoreUrl', + appStoreUrl: 'appStoreUrl', + popularItems: 'popularItems', + isFlashDeliveryEnabled: 'isFlashDeliveryEnabled', + supportMobile: 'supportMobile', + supportEmail: 'supportEmail', +} as const; + +export const CONST_LABELS: Record = { + minRegularOrderValue: 'Minimum Regular Order Value', + freeDeliveryThreshold: 'Free Delivery Threshold', + deliveryCharge: 'Delivery Charge', + flashFreeDeliveryThreshold: 'Flash Free Delivery Threshold', + flashDeliveryCharge: 'Flash Delivery Charge', + platformFeePercent: 'Platform Fee Percent', + taxRate: 'Tax Rate', + minOrderAmountForCoupon: 'Minimum Order Amount for Coupon', + maxCouponDiscount: 'Maximum Coupon Discount', + flashDeliverySlotId: 'Flash Delivery Slot ID', + readableOrderId: 'Readable Order ID', + versionNum: 'Version Number', + playStoreUrl: 'Play Store URL', + appStoreUrl: 'App Store URL', + popularItems: 'Popular Items', + isFlashDeliveryEnabled: 'Enable Flash Delivery', + supportMobile: 'Support Mobile', + supportEmail: 'Support Email', +}; + +export type ConstKey = (typeof CONST_KEYS)[keyof typeof CONST_KEYS]; + +export const CONST_KEYS_ARRAY = Object.values(CONST_KEYS) as ConstKey[]; diff --git a/apps/backend/src/lib/const-store.ts b/apps/backend/src/lib/const-store.ts new file mode 100644 index 0000000..bd9b658 --- /dev/null +++ b/apps/backend/src/lib/const-store.ts @@ -0,0 +1,56 @@ +import { db } from '../db/db_index'; +import { keyValStore } from '../db/schema'; +import redisClient from './redis-client'; +import { CONST_KEYS, CONST_KEYS_ARRAY, type ConstKey } from './const-keys'; + +const CONST_REDIS_PREFIX = 'const:'; + +export const computeConstants = async (): Promise => { + try { + console.log('Computing constants from database...'); + + const constants = await db.select().from(keyValStore); + + console.log({constants}) + + for (const constant of constants) { + const redisKey = `${CONST_REDIS_PREFIX}${constant.key}`; + const value = JSON.stringify(constant.value); + console.log({redisKey, value}) + + await redisClient.set(redisKey, value); + } + + console.log(`Computed and stored ${constants.length} constants in Redis`); + } catch (error) { + console.error('Failed to compute constants:', error); + throw error; + } +}; + +export const getConstant = async (key: string): Promise => { + const redisKey = `${CONST_REDIS_PREFIX}${key}`; + const value = await redisClient.get(redisKey); + + if (!value) { + return null; + } + + try { + return JSON.parse(value) as T; + } catch { + return value as unknown as T; + } +}; + +export const getAllConstValues = async (): Promise> => { + const result: Record = {}; + + for (const key of CONST_KEYS_ARRAY) { + result[key] = await getConstant(key); + } + + return result as Record; +}; + +export { CONST_KEYS, CONST_KEYS_ARRAY }; diff --git a/apps/backend/src/lib/const-strings.ts b/apps/backend/src/lib/const-strings.ts new file mode 100755 index 0000000..37e2952 --- /dev/null +++ b/apps/backend/src/lib/const-strings.ts @@ -0,0 +1,28 @@ +/** + * This file contains constants that are used throughout the application + * to avoid hardcoding strings in multiple places + */ + +// User role and designation constants +export const READABLE_ORDER_ID_KEY = 'readableOrderId'; + +// Queue constants +export const NOTIFS_QUEUE = 'notifications'; +export const OTP_COMMENT_NAME='otp-comment' + +// Notification message constants +export const ORDER_PLACED_MESSAGE = 'Your order has been placed successfully!'; +export const PAYMENT_FAILED_MESSAGE = 'Payment failed. Please try again.'; +export const ORDER_PACKAGED_MESSAGE = 'Your order has been packaged and is ready for delivery.'; +export const ORDER_OUT_FOR_DELIVERY_MESSAGE = 'Your order is out for delivery.'; +export const ORDER_DELIVERED_MESSAGE = 'Your order has been delivered.'; +export const ORDER_CANCELLED_MESSAGE = 'Your order has been cancelled.'; +export const REFUND_INITIATED_MESSAGE = 'Refund has been initiated for your order.'; +export const WELCOME_MESSAGE = 'Welcome to Farm2Door! Thank you for joining us.'; + +export const REFUND_STATUS = { + PENDING: 'none', + NOT_APPLICABLE: 'na', + PROCESSING: 'initiated', + SUCCESS: 'success', +}; \ No newline at end of file diff --git a/apps/backend/src/lib/delete-image.ts b/apps/backend/src/lib/delete-image.ts new file mode 100644 index 0000000..5289c45 --- /dev/null +++ b/apps/backend/src/lib/delete-image.ts @@ -0,0 +1,46 @@ +import { eq } from "drizzle-orm"; +import { db } from "../db/db_index"; +import { deleteImageUtil, getOriginalUrlFromSignedUrl } from "./s3-client"; +import { s3Url } from "./env-exporter"; + +function extractS3Key(url: string): string | null { + try { + // Check if this is a signed URL first and get the original if it is + const originalUrl = getOriginalUrlFromSignedUrl(url) || url; + + // Find the index of '.com/' in the URL + // const comIndex = originalUrl.indexOf(".com/"); + const baseUrlIndex = originalUrl.indexOf(s3Url); + + // If '.com/' is found, return everything after it + if (baseUrlIndex !== -1) { + return originalUrl.substring(baseUrlIndex + s3Url.length); // +5 to skip '.com/' + } + } catch (error) { + console.error("Error extracting key from URL:", error); + } + + // Return null if the pattern isn't found or there was an error + return null; +} + + +export async function deleteS3Image(imageUrl: string) { + try { + // First check if this is a signed URL and get the original if it is + const originalUrl = getOriginalUrlFromSignedUrl(imageUrl) || imageUrl; + + const key = extractS3Key(originalUrl || ""); + + + if (!key) { + throw new Error("Invalid image URL format"); + } + const deleteS3 = await deleteImageUtil({keys: [key] }); + if (!deleteS3) { + throw new Error("Failed to delete image from S3"); + } + } catch (error) { + console.error("Error deleting image from S3:", error); + } +} diff --git a/apps/backend/src/lib/disk-persisted-set.ts b/apps/backend/src/lib/disk-persisted-set.ts new file mode 100644 index 0000000..5f968f1 --- /dev/null +++ b/apps/backend/src/lib/disk-persisted-set.ts @@ -0,0 +1,79 @@ +import fs from "fs"; +import path from "path"; + +export class DiskPersistedSet { + private set: Set; + private readonly filePath: string; + private dirty = false; + + constructor(filePath: string = "./persister") { + this.filePath = path.resolve(filePath); + + // ✅ Ensure file exists + if (!fs.existsSync(this.filePath)) { + fs.writeFileSync(this.filePath, "", "utf8"); + } + + // ✅ Load existing values from file + const contents = fs.readFileSync(this.filePath, "utf8"); + this.set = new Set( + contents.split("\n").map(x => x.trim()).filter(x => x.length > 0) + ); + + this.registerExitHandlers(); + } + + private persist() { + if (!this.dirty) return; + fs.writeFileSync(this.filePath, Array.from(this.set).join("\n"), "utf8"); + this.dirty = false; + } + + private markDirty() { + this.dirty = true; + } + + add(value: string): void { + if (!this.set.has(value)) { + this.set.add(value); + this.markDirty(); + this.persist(); + } + } + + delete(value: string): void { + if (this.set.delete(value)) { + this.markDirty(); + this.persist(); + } + } + + has(value: string): boolean { + return this.set.has(value); + } + + values(): string[] { + return Array.from(this.set); + } + + clear(): void { + if (this.set.size > 0) { + this.set.clear(); + this.markDirty(); + this.persist(); + } + } + + private registerExitHandlers() { + const flush = () => this.persist(); + + process.on("exit", flush); + process.on("SIGINT", () => { flush(); process.exit(); }); + process.on("SIGTERM", () => { flush(); process.exit(); }); + process.on("uncaughtException", (err) => { + console.error("Uncaught exception. Flushing DiskPersistedSet:", err); + flush(); + process.exit(1); + }); + } +} diff --git a/apps/backend/src/lib/env-exporter.ts b/apps/backend/src/lib/env-exporter.ts new file mode 100755 index 0000000..65a53b2 --- /dev/null +++ b/apps/backend/src/lib/env-exporter.ts @@ -0,0 +1,43 @@ + +export const appUrl = process.env.APP_URL as string; + +export const jwtSecret: string = process.env.JWT_SECRET as string + +export const defaultRoleName = 'gen_user'; + +export const encodedJwtSecret = new TextEncoder().encode(jwtSecret) + +export const s3AccessKeyId = process.env.S3_ACCESS_KEY_ID as string + +export const s3SecretAccessKey = process.env.S3_SECRET_ACCESS_KEY as string + +export const s3BucketName = process.env.S3_BUCKET_NAME as string + +export const s3Region = process.env.S3_REGION as string + +export const s3Url = process.env.S3_URL as string + +export const redisUrl = process.env.REDIS_URL as string + + +export const expoAccessToken = process.env.EXPO_ACCESS_TOKEN as string; + +export const phonePeBaseUrl = process.env.PHONE_PE_BASE_URL as string; + +export const phonePeClientId = process.env.PHONE_PE_CLIENT_ID as string; + +export const phonePeClientVersion = Number(process.env.PHONE_PE_CLIENT_VERSION as string); + +export const phonePeClientSecret = process.env.PHONE_PE_CLIENT_SECRET as string; + +export const phonePeMerchantId = process.env.PHONE_PE_MERCHANT_ID as string; + +export const razorpayId = process.env.RAZORPAY_KEY as string; + +export const razorpaySecret = process.env.RAZORPAY_SECRET as string; + +export const otpSenderAuthToken = process.env.OTP_SENDER_AUTH_TOKEN as string; + +export const minOrderValue = Number(process.env.MIN_ORDER_VALUE as string); + +export const deliveryCharge = Number(process.env.DELIVERY_CHARGE as string); diff --git a/apps/backend/src/lib/event-queue.ts b/apps/backend/src/lib/event-queue.ts new file mode 100644 index 0000000..13e0d09 --- /dev/null +++ b/apps/backend/src/lib/event-queue.ts @@ -0,0 +1,12 @@ +import redisClient from './redis-client'; + +export async function enqueue(queueName: string, eventData: any): Promise { + try { + const jsonData = JSON.stringify(eventData); + const result = await redisClient.lPush(queueName, jsonData); + return result > 0; + } catch (error) { + console.error('Event enqueue error:', error); + return false; + } +} \ No newline at end of file diff --git a/apps/backend/src/lib/expo-service.ts b/apps/backend/src/lib/expo-service.ts new file mode 100755 index 0000000..1e87423 --- /dev/null +++ b/apps/backend/src/lib/expo-service.ts @@ -0,0 +1,41 @@ +import { Expo } from "expo-server-sdk"; +import { title } from "process"; +import { expoAccessToken } from "./env-exporter"; + +const expo = new Expo({ + accessToken: expoAccessToken, + useFcmV1: true, +}); + +type NotificationArgs = { + pushToken: string; + title?: string; + body?: string; + data: Record | undefined; + // data?: object; +}; + +export const sendPushNotificationsMany = async (args: NotificationArgs[]) => { + // const { pushToken, title, body, data } = args; + const notifPayloads = args.map((arg) => ({ + to: arg.pushToken, + title: arg.title, + body: arg.body, + data: arg.data, + sound: "default", + priority: "high" as any, + })); + const chunks = expo.chunkPushNotifications(notifPayloads); + + let tickets = []; + (async () => { + for (let chunk of chunks) { + try { + let ticketChunk = await expo.sendPushNotificationsAsync(chunk); + tickets.push(...ticketChunk); + } catch (error) { + console.error(error); + } + } + })(); +}; diff --git a/apps/backend/src/lib/init.ts b/apps/backend/src/lib/init.ts new file mode 100755 index 0000000..1e3532b --- /dev/null +++ b/apps/backend/src/lib/init.ts @@ -0,0 +1,34 @@ +import roleManager from './roles-manager'; +import './notif-job'; +import { computeConstants } from './const-store'; + +/** + * Initialize all application services + * This function handles initialization of: + * - Role Manager (fetches and caches all roles) + * - Const Store (syncs constants from DB to Redis) + * - Other services can be added here in the future + */ +export const initFunc = async (): Promise => { + try { + console.log('Starting application initialization...'); + + // Initialize role manager + await roleManager.fetchRoles(); + console.log('Role manager initialized successfully'); + + // Compute and store constants in Redis + await computeConstants(); + console.log('Const store initialized successfully'); + + // Notification queue and worker are initialized via import + console.log('Notification queue and worker initialized'); + + console.log('Application initialization completed successfully'); + } catch (error) { + console.error('Application initialization failed:', error); + throw error; + } +}; + +export default initFunc; diff --git a/apps/backend/src/lib/mbnr-geojson.ts b/apps/backend/src/lib/mbnr-geojson.ts new file mode 100644 index 0000000..7dc88fe --- /dev/null +++ b/apps/backend/src/lib/mbnr-geojson.ts @@ -0,0 +1,120 @@ +export const mbnrGeoJson = { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [ + 78.0540565157155, + 16.750355644371382 + ], + [ + 78.02147549424018, + 16.72066473405593 + ], + [ + 78.03026125246384, + 16.71696749930787 + ], + [ + 78.0438058450269, + 16.72191442229257 + ], + [ + 78.01378723066603, + 16.729427120762438 + ], + [ + 78.01192390645633, + 16.767270033080678 + ], + [ + 77.98897480599248, + 16.78383139678816 + ], + [ + 77.98650506846502, + 16.779477610410623 + ], + [ + 77.99211289459566, + 16.764294442899583 + ], + [ + 77.9917733766166, + 16.760247911187193 + ], + [ + 77.9871626670851, + 16.762487176781022 + ], + [ + 77.98216269568468, + 16.762520539253813 + ], + [ + 77.9728079653313, + 16.75895746646411 + ], + [ + 77.97076993211158, + 16.749241850772236 + ], + [ + 77.97290869571145, + 16.714289841456335 + ], + [ + 77.98673742913684, + 16.716189282573396 + ], + [ + 78.00286970994557, + 16.718191131206893 + ], + [ + 78.02757966423519, + 16.720603921728966 + ], + [ + 78.01653780770818, + 16.73184590223127 + ], + [ + 78.0064695230268, + 16.760236966033375 + ], + [ + 78.0148831108591, + 16.760801801995825 + ], + [ + 78.01488756695255, + 16.75827980335133 + ], + [ + 78.0244311364159, + 16.744778942163208 + ], + [ + 78.03342267256608, + 16.760773251410058 + ], + [ + 78.05078586709863, + 16.763902127913653 + ], + [ + 78.0540565157155, + 16.750355644371382 + ] + ] + ], + "type": "Polygon" + } + } + ] +}; \ No newline at end of file diff --git a/apps/backend/src/lib/mbnr.geojson b/apps/backend/src/lib/mbnr.geojson new file mode 100644 index 0000000..32d63b3 --- /dev/null +++ b/apps/backend/src/lib/mbnr.geojson @@ -0,0 +1,120 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [ + 78.0540565157155, + 16.750355644371382 + ], + [ + 78.02147549424018, + 16.72066473405593 + ], + [ + 78.03026125246384, + 16.71696749930787 + ], + [ + 78.0438058450269, + 16.72191442229257 + ], + [ + 78.01378723066603, + 16.729427120762438 + ], + [ + 78.01192390645633, + 16.767270033080678 + ], + [ + 77.98897480599248, + 16.78383139678816 + ], + [ + 77.98650506846502, + 16.779477610410623 + ], + [ + 77.99211289459566, + 16.764294442899583 + ], + [ + 77.9917733766166, + 16.760247911187193 + ], + [ + 77.9871626670851, + 16.762487176781022 + ], + [ + 77.98216269568468, + 16.762520539253813 + ], + [ + 77.9728079653313, + 16.75895746646411 + ], + [ + 77.97076993211158, + 16.749241850772236 + ], + [ + 77.97290869571145, + 16.714289841456335 + ], + [ + 77.98673742913684, + 16.716189282573396 + ], + [ + 78.00286970994557, + 16.718191131206893 + ], + [ + 78.02757966423519, + 16.720603921728966 + ], + [ + 78.01653780770818, + 16.73184590223127 + ], + [ + 78.0064695230268, + 16.760236966033375 + ], + [ + 78.0148831108591, + 16.760801801995825 + ], + [ + 78.01488756695255, + 16.75827980335133 + ], + [ + 78.0244311364159, + 16.744778942163208 + ], + [ + 78.03342267256608, + 16.760773251410058 + ], + [ + 78.05078586709863, + 16.763902127913653 + ], + [ + 78.0540565157155, + 16.750355644371382 + ] + ] + ], + "type": "Polygon" + } + } + ] +} \ No newline at end of file diff --git a/apps/backend/src/lib/notif-job.ts b/apps/backend/src/lib/notif-job.ts new file mode 100644 index 0000000..fcbd7e1 --- /dev/null +++ b/apps/backend/src/lib/notif-job.ts @@ -0,0 +1,111 @@ +import { Queue, Worker } from 'bullmq'; +import { redisUrl } from './env-exporter'; +import { + NOTIFS_QUEUE, + ORDER_PLACED_MESSAGE, + PAYMENT_FAILED_MESSAGE, + ORDER_PACKAGED_MESSAGE, + ORDER_OUT_FOR_DELIVERY_MESSAGE, + ORDER_DELIVERED_MESSAGE, + ORDER_CANCELLED_MESSAGE, + REFUND_INITIATED_MESSAGE +} from './const-strings'; + +export const notificationQueue = new Queue(NOTIFS_QUEUE, { + connection: { url: redisUrl }, + defaultJobOptions: { + removeOnComplete: 50, + removeOnFail: 100, + attempts: 3, + }, +}); + +export const notificationWorker = new Worker(NOTIFS_QUEUE, async (job) => { + if (!job) return; + console.log(`Processing notification job ${job.id}`); + // TODO: Implement sendPushNotification +}, { + connection: { url: redisUrl }, + concurrency: 5, +}); + +notificationWorker.on('completed', (job) => { + if (job) console.log(`Notification job ${job.id} completed`); +}); +notificationWorker.on('failed', (job, err) => { + if (job) console.error(`Notification job ${job.id} failed:`, err); +}); + +export async function scheduleNotification(userId: number, payload: any, options?: { delay?: number; priority?: number }) { + const jobData = { userId, ...payload }; + await notificationQueue.add('send-notification', jobData, options); +} + +// Utility methods for specific notification events +export async function sendOrderPlacedNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Order Placed', + body: ORDER_PLACED_MESSAGE, + type: 'order', + orderId + }); +} + +export async function sendPaymentFailedNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Payment Failed', + body: PAYMENT_FAILED_MESSAGE, + type: 'payment', + orderId + }); +} + +export async function sendOrderPackagedNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Order Packaged', + body: ORDER_PACKAGED_MESSAGE, + type: 'order', + orderId + }); +} + +export async function sendOrderOutForDeliveryNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Out for Delivery', + body: ORDER_OUT_FOR_DELIVERY_MESSAGE, + type: 'order', + orderId + }); +} + +export async function sendOrderDeliveredNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Order Delivered', + body: ORDER_DELIVERED_MESSAGE, + type: 'order', + orderId + }); +} + +export async function sendOrderCancelledNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Order Cancelled', + body: ORDER_CANCELLED_MESSAGE, + type: 'order', + orderId + }); +} + +export async function sendRefundInitiatedNotification(userId: number, orderId?: string) { + await scheduleNotification(userId, { + title: 'Refund Initiated', + body: REFUND_INITIATED_MESSAGE, + type: 'refund', + orderId + }); +} + +process.on('SIGTERM', async () => { + await notificationQueue.close(); + await notificationWorker.close(); +}); \ No newline at end of file diff --git a/apps/backend/src/lib/notif-service.ts b/apps/backend/src/lib/notif-service.ts new file mode 100755 index 0000000..2cb9480 --- /dev/null +++ b/apps/backend/src/lib/notif-service.ts @@ -0,0 +1,247 @@ +import { db } from "../db/db_index"; +import { sendPushNotificationsMany } from "./expo-service"; +// import { usersTable, notifCredsTable, notificationTable } from "../db/schema"; +import { eq, inArray } from "drizzle-orm"; + +// Core notification dispatch methods (renamed for clarity) +export async function dispatchBulkNotification({ + userIds = [], + pushTokens = [], + title, + body, + data, +}: { + userIds?: number[]; + pushTokens?: string[]; + title: string; + body: string; + data?: Record; +}) { + try { + let allPushTokens: string[] = []; + + // Add provided pushTokens directly + if (pushTokens && pushTokens.length > 0) { + allPushTokens.push(...pushTokens.filter(Boolean)); + } + + // Fetch push tokens for userIds + // if (userIds && userIds.length > 0) { + // const tokensFromDb = await db.query.notifCredsTable.findMany({ + // where: inArray(notifCredsTable.userId, userIds), + // columns: { pushToken: true }, + // }); + // allPushTokens.push( + // ...tokensFromDb.map((t) => t.pushToken).filter(Boolean) + // ); + // } + + // Remove duplicates + allPushTokens = Array.from(new Set(allPushTokens)); + + if (allPushTokens.length === 0) { + console.warn(`No push tokens found for users: ${userIds?.join(", ")}`); + return; + } + + const messages = allPushTokens.map((pushToken) => ({ + pushToken, + title, + body, + data, + })); + await sendPushNotificationsMany(messages); + } catch (error) { + console.error("Error dispatching bulk notifications:", error); + throw new Error("Failed to dispatch notifications"); + } +} + +// Helper to dispatch notification to a single user or pushToken +export async function dispatchUserNotification({ + userId, + pushToken, + title, + body, + data, +}: { + userId?: number; + pushToken?: string; + title: string; + body: string; + data?: Record; +}) { + // Add entry to notificationTable if userId is provided + if (userId) { + try { + // await db.insert(notificationTable).values({ + // userId, + // title, + // body, + // payload: data, + // // addedOn will default to now + // }); + } catch (err) { + console.error('Failed to insert notificationTable entry:', err); + } + } + + await dispatchBulkNotification({ + userIds: userId ? [userId] : [], + pushTokens: pushToken ? [pushToken] : [], + title, + body, + data, + }); +} + +// ============================================================================= +// PURPOSE-SPECIFIC NOTIFICATION METHODS +// ============================================================================= + +// Order-related notifications +export const notifyOrderPlaced = (orderId: number, userId: number) => + dispatchUserNotification({ + title: 'Order Placed Successfully! 🎉', + body: `Your order #${orderId} has been placed and is being processed.`, + userId, + data: { orderId, type: 'order_placed' } + }); + +export const notifyOrderConfirmed = (orderId: number, userId: number) => + dispatchUserNotification({ + title: 'Order Confirmed! ✅', + body: `Your order #${orderId} has been confirmed and is being prepared.`, + userId, + data: { orderId, type: 'order_confirmed' } + }); + +export const notifyOrderReady = (orderId: number, userId: number) => + dispatchUserNotification({ + title: 'Order Ready for Pickup! 🍽️', + body: `Your order #${orderId} is ready for pickup.`, + userId, + data: { orderId, type: 'order_ready' } + }); + +export const notifyOrderCancelled = (orderId: number, userId: number, reason?: string) => + dispatchUserNotification({ + title: 'Order Cancelled ❌', + body: `Your order #${orderId} has been cancelled.${reason ? ` Reason: ${reason}` : ''}`, + userId, + data: { orderId, type: 'order_cancelled', reason } + }); + +// Delivery notifications +export const notifyDeliveryAssigned = (orderId: number, userId: number, deliveryPerson: string) => + dispatchUserNotification({ + title: 'Delivery Partner Assigned 🚚', + body: `${deliveryPerson} will deliver your order #${orderId}.`, + userId, + data: { orderId, deliveryPerson, type: 'delivery_assigned' } + }); + +export const notifyOutForDelivery = (orderId: number, userId: number, eta: string) => + dispatchUserNotification({ + title: 'Out for Delivery! 📦', + body: `Your order #${orderId} is out for delivery. Expected arrival: ${eta}`, + userId, + data: { orderId, eta, type: 'out_for_delivery' } + }); + +export const notifyDelivered = (orderId: number, userId: number) => + dispatchUserNotification({ + title: 'Order Delivered! 🎊', + body: `Your order #${orderId} has been delivered successfully.`, + userId, + data: { orderId, type: 'delivered' } + }); + +// Payment notifications +export const notifyPaymentSuccess = (orderId: number, userId: number, amount: number) => + dispatchUserNotification({ + title: 'Payment Successful 💳', + body: `Payment of ₹${amount} for order #${orderId} was successful.`, + userId, + data: { orderId, amount, type: 'payment_success' } + }); + +export const notifyPaymentFailed = (orderId: number, userId: number) => + dispatchUserNotification({ + title: 'Payment Failed ❌', + body: `Payment for order #${orderId} failed. Please try again.`, + userId, + data: { orderId, type: 'payment_failed' } + }); + +export const notifyRefundProcessed = (orderId: number, userId: number, amount: number) => + dispatchUserNotification({ + title: 'Refund Processed 💰', + body: `Refund of ₹${amount} for order #${orderId} has been processed.`, + userId, + data: { orderId, amount, type: 'refund_processed' } + }); + +// Promotional notifications +export const notifyNewOffer = (userIds: number[], offerTitle: string, offerDetails: string) => + dispatchBulkNotification({ + title: `New Offer: ${offerTitle} 🎁`, + body: offerDetails, + userIds, + data: { type: 'promotion', offerTitle } + }); + +export const notifyFlashSale = (userIds: number[], productName: string, discount: number) => + dispatchBulkNotification({ + title: 'Flash Sale! ⚡', + body: `Get ${discount}% off on ${productName}. Limited time offer!`, + userIds, + data: { type: 'flash_sale', productName, discount } + }); + +export const notifyLoyaltyPointsEarned = (userId: number, points: number, reason: string) => + dispatchUserNotification({ + title: 'Loyalty Points Earned! ⭐', + body: `You earned ${points} points for ${reason}.`, + userId, + data: { points, reason, type: 'loyalty_points' } + }); + +// Account notifications +export const notifyWelcome = (userId: number, userName: string) => + dispatchUserNotification({ + title: 'Welcome to Meat Farmer! 🥩', + body: `Hi ${userName}, welcome to our fresh meat delivery service.`, + userId, + data: { type: 'welcome' } + }); + +export const notifyPasswordReset = (userId: number) => + dispatchUserNotification({ + title: 'Password Reset Successful 🔐', + body: 'Your password has been reset successfully.', + userId, + data: { type: 'password_reset' } + }); + +export const notifyAccountVerified = (userId: number) => + dispatchUserNotification({ + title: 'Account Verified! ✅', + body: 'Your account has been successfully verified.', + userId, + data: { type: 'account_verified' } + }); + +// ============================================================================= +// BACKWARD COMPATIBILITY (DEPRECATED) +// ============================================================================= + +/** + * @deprecated Use notifyOrderConfirmed() or other purpose-specific methods instead + */ +export const sendNotifToSingleUser = dispatchUserNotification; + +/** + * @deprecated Use notifyNewOffer() or other purpose-specific methods instead + */ +export const sendNotifToManyUsers = dispatchBulkNotification; \ No newline at end of file diff --git a/apps/backend/src/lib/otp-utils.ts b/apps/backend/src/lib/otp-utils.ts new file mode 100644 index 0000000..dc39b45 --- /dev/null +++ b/apps/backend/src/lib/otp-utils.ts @@ -0,0 +1,55 @@ +import { ApiError } from './api-error'; +import { otpSenderAuthToken } from './env-exporter'; + +const otpStore = new Map(); + +const setOtpCreds = (phone: string, verificationId: string) => { + otpStore.set(phone, verificationId); +}; + +export function getOtpCreds(mobile: string) { + const authKey = otpStore.get(mobile); + + return authKey || null; +} + +export const sendOtp = async (phone: string) => { + if (!phone) { + throw new ApiError("Phone number is required", 400); + } + const reqUrl = `https://cpaas.messagecentral.com/verification/v3/send?countryCode=91&flowType=SMS&mobileNumber=${phone}&timeout=300`; + const resp = await fetch(reqUrl, { + headers: { + authToken: otpSenderAuthToken, + }, + method: "POST", + }); + const data = await resp.json(); + + if (data.message === "SUCCESS") { + setOtpCreds(phone, data.data.verificationId); + return { success: true, message: "OTP sent successfully", verificationId: data.data.verificationId }; + } + if (data.message === "REQUEST_ALREADY_EXISTS") { + return { success: true, message: "OTP already sent. Last OTP is still valid" }; + } + + throw new ApiError("Error while sending OTP. Please try again", 500); +}; + +export async function verifyOtpUtil(mobile: string, otp: string, verifId: string):Promise { + const reqUrl = `https://cpaas.messagecentral.com/verification/v3/validateOtp?&verificationId=${verifId}&code=${otp}`; + const resp = await fetch(reqUrl, { + method: "GET", + headers: { + authToken: otpSenderAuthToken, + }, + }); + + const rawData = await resp.json(); + if (rawData.data?.verificationStatus === "VERIFICATION_COMPLETED") { + // delete the verificationId from the local storage + return true; + } + return false; +} \ No newline at end of file diff --git a/apps/backend/src/lib/payments-utils.ts b/apps/backend/src/lib/payments-utils.ts new file mode 100644 index 0000000..02e7791 --- /dev/null +++ b/apps/backend/src/lib/payments-utils.ts @@ -0,0 +1,59 @@ +import Razorpay from "razorpay"; +import { razorpayId, razorpaySecret } from "./env-exporter"; +import { db } from "../db/db_index"; +import { payments } from "../db/schema"; + +type Tx = Parameters[0]>[0]; + +export class RazorpayPaymentService { + private static instance = new Razorpay({ + key_id: razorpayId, + key_secret: razorpaySecret, + }); + + static async createOrder(orderId: number, amount: string) { + // Create Razorpay order + const razorpayOrder = await this.instance.orders.create({ + amount: parseFloat(amount) * 100, // Convert to paisa + currency: 'INR', + receipt: `order_${orderId}`, + notes: { + customerOrderId: orderId.toString(), + }, + }); + + return razorpayOrder; + } + + static async insertPaymentRecord(orderId: number, razorpayOrder: any, tx?: Tx) { + // Use transaction if provided, otherwise use db + const dbInstance = tx || db; + + // Insert payment record + const [payment] = await dbInstance + .insert(payments) + .values({ + status: 'pending', + gateway: 'razorpay', + orderId, + token: orderId.toString(), + merchantOrderId: razorpayOrder.id, + payload: razorpayOrder, + }) + .returning(); + + return payment; + } + + static async initiateRefund(paymentId: string, amount: number) { + const refund = await this.instance.payments.refund(paymentId, { + amount, + }); + return refund; + } + + static async fetchRefund(refundId: string) { + const refund = await this.instance.refunds.fetch(refundId); + return refund; + } +} \ No newline at end of file diff --git a/apps/backend/src/lib/redis-client.ts b/apps/backend/src/lib/redis-client.ts new file mode 100644 index 0000000..8539efa --- /dev/null +++ b/apps/backend/src/lib/redis-client.ts @@ -0,0 +1,80 @@ +import { createClient, RedisClientType } from 'redis'; +import { redisUrl } from './env-exporter'; + +class RedisClient { + private client: RedisClientType; + private isConnected: boolean = false; + + constructor() { + this.client = createClient({ + url: redisUrl, + }); + + this.client.on('error', (err) => { + console.error('Redis Client Error:', err); + }); + + this.client.on('connect', () => { + console.log('Redis Client Connected'); + this.isConnected = true; + }); + + this.client.on('disconnect', () => { + console.log('Redis Client Disconnected'); + this.isConnected = false; + }); + + this.client.on('ready', () => { + console.log('Redis Client Ready'); + }); + + this.client.on('reconnecting', () => { + console.log('Redis Client Reconnecting'); + }); + + // Connect immediately (fire and forget) + this.client.connect().catch((err) => { + console.error('Failed to connect Redis:', err); + }); + } + + async set(key: string, value: string, ttlSeconds?: number): Promise { + if (ttlSeconds) { + return await this.client.setEx(key, ttlSeconds, value); + } else { + return await this.client.set(key, value); + } + } + + async get(key: string): Promise { + return await this.client.get(key); + } + + async exists(key: string): Promise { + const result = await this.client.exists(key); + return result === 1; + } + + async delete(key: string): Promise { + return await this.client.del(key); + } + + async lPush(key: string, value: string): Promise { + return await this.client.lPush(key, value); + } + + disconnect(): void { + if (this.isConnected) { + this.client.disconnect(); + } + } + + get isClientConnected(): boolean { + return this.isConnected; + } +} + +const redisClient = new RedisClient(); + +export default redisClient; +export { RedisClient }; \ No newline at end of file diff --git a/apps/backend/src/lib/redisKeyGetters.ts b/apps/backend/src/lib/redisKeyGetters.ts new file mode 100644 index 0000000..c72f66e --- /dev/null +++ b/apps/backend/src/lib/redisKeyGetters.ts @@ -0,0 +1,3 @@ +export function getSlotSequenceKey(slotId: number | string): string { + return `slot_sequence_${slotId}`; +} \ No newline at end of file diff --git a/apps/backend/src/lib/roles-manager.ts b/apps/backend/src/lib/roles-manager.ts new file mode 100755 index 0000000..bdb8057 --- /dev/null +++ b/apps/backend/src/lib/roles-manager.ts @@ -0,0 +1,124 @@ +import { db } from "../db/db_index"; + +/** + * Constants for role names to avoid hardcoding and typos + */ +export const ROLE_NAMES = { + ADMIN: 'admin', + GENERAL_USER: 'gen_user', + HOSPITAL_ADMIN: 'hospital_admin', + DOCTOR: 'doctor', + RECEPTIONIST: 'receptionist' +}; + +export const defaultRole = ROLE_NAMES.GENERAL_USER; + +/** + * RoleManager class to handle caching and retrieving role information + * Provides methods to fetch roles from DB and cache them for quick access + */ +class RoleManager { + private roles: Map = new Map(); + private rolesByName: Map = new Map(); + private isInitialized: boolean = false; + + constructor() { + // Singleton instance + } + + /** + * Fetch all roles from the database and cache them + * This should be called during application startup + */ + public async fetchRoles(): Promise { + try { + // const roles = await db.query.roleInfoTable.findMany(); + + // // Clear existing maps before adding new data + // this.roles.clear(); + // this.rolesByName.clear(); + + // // Cache roles by ID and by name for quick lookup + // roles.forEach(role => { + // this.roles.set(role.id, role); + // this.rolesByName.set(role.name, role); + // }); + + // this.isInitialized = true; + // console.log(`[RoleManager] Cached ${roles.length} roles`); + } catch (error) { + console.error('[RoleManager] Error fetching roles:', error); + throw error; + } + } + + /** + * Get all roles from cache + * If not initialized, fetches roles from DB first + */ + public async getRoles(): Promise<{ id: number; name: string; description: string | null }[]> { + if (!this.isInitialized) { + await this.fetchRoles(); + } + return Array.from(this.roles.values()); + } + + /** + * Get role by ID + * @param id Role ID + */ + public async getRoleById(id: number): Promise<{ id: number; name: string; description: string | null } | undefined> { + if (!this.isInitialized) { + await this.fetchRoles(); + } + return this.roles.get(id); + } + + /** + * Get role by name + * @param name Role name + */ + public async getRoleByName(name: string): Promise<{ id: number; name: string; description: string | null } | undefined> { + if (!this.isInitialized) { + await this.fetchRoles(); + } + return this.rolesByName.get(name); + } + + /** + * Check if a role exists by name + * @param name Role name + */ + public async roleExists(name: string): Promise { + if (!this.isInitialized) { + await this.fetchRoles(); + } + return this.rolesByName.has(name); + } + + /** + * Get business roles (roles that are not 'admin' or 'gen_user') + */ + public async getBusinessRoles(): Promise<{ id: number; name: string; description: string | null }[]> { + if (!this.isInitialized) { + await this.fetchRoles(); + } + + return Array.from(this.roles.values()).filter( + role => role.name !== ROLE_NAMES.ADMIN && role.name !== ROLE_NAMES.GENERAL_USER + ); + } + + /** + * Force refresh the roles cache + */ + public async refreshRoles(): Promise { + await this.fetchRoles(); + } +} + +// Create a singleton instance +const roleManager = new RoleManager(); + +// Export the singleton instance +export default roleManager; diff --git a/apps/backend/src/lib/s3-client.ts b/apps/backend/src/lib/s3-client.ts new file mode 100755 index 0000000..7854200 --- /dev/null +++ b/apps/backend/src/lib/s3-client.ts @@ -0,0 +1,205 @@ +// import { s3A, awsBucketName, awsRegion, awsSecretAccessKey } from "../lib/env-exporter" +import { DeleteObjectCommand, DeleteObjectsCommand, PutObjectCommand, S3Client, GetObjectCommand } from "@aws-sdk/client-s3" +import { getSignedUrl } from "@aws-sdk/s3-request-presigner" +import signedUrlCache from "./signed-url-cache" +import { s3AccessKeyId, s3Region, s3Url, s3SecretAccessKey, s3BucketName } from "./env-exporter"; +import { db } from "../db/db_index"; // Adjust path if needed +import { uploadUrlStatus } from "../db/schema"; +import { and, eq } from 'drizzle-orm'; + +const s3Client = new S3Client({ + region: s3Region, + endpoint: s3Url, + forcePathStyle: true, + credentials: { + accessKeyId: s3AccessKeyId, + secretAccessKey: s3SecretAccessKey, + }, +}) +export default s3Client; + +export const imageUploadS3 = async(body: Buffer, type: string, key:string) => { + // const key = `${category}/${Date.now()}` + const command = new PutObjectCommand({ + Bucket: s3BucketName, + Key: key, + Body: body, + ContentType: type, + }) + const resp = await s3Client.send(command) + + const imageUrl = `${key}` + return imageUrl; +} + + +// export async function deleteImageUtil(...keys:string[]):Promise; + +export async function deleteImageUtil({bucket = s3BucketName, keys}:{bucket?:string, keys: string[]}) { + + if (keys.length === 0) { + return true; + } + try { + const deleteParams = { + Bucket: bucket, + Delete: { + Objects: keys.map((key) => ({ Key: key })), + Quiet: false, + } + } + + const deleteCommand = new DeleteObjectsCommand(deleteParams) + await s3Client.send(deleteCommand) + return true + } + catch (error) { + console.error("Error deleting image:", error) + throw new Error("Failed to delete image") + return false; + } +} + + +/** + * Generate a signed URL from an S3 URL + * @param s3Url The full S3 URL (e.g., https://bucket-name.s3.region.amazonaws.com/path/to/object) + * @param expiresIn Expiration time in seconds (default: 259200 seconds = 3 days) + * @returns A pre-signed URL that provides temporary access to the object + */ +export async function generateSignedUrlFromS3Url(s3UrlRaw: string|null, expiresIn: number = 259200): Promise { + if (!s3UrlRaw) { + return ''; + } + + const s3Url = s3UrlRaw + + try { + // Check if we have a cached signed URL + const cachedUrl = signedUrlCache.get(s3Url); + if (cachedUrl) { + // Found in cache, return it + return cachedUrl; + } + + // Create the command to get the object + const command = new GetObjectCommand({ + Bucket: s3BucketName, + Key: s3Url, + }); + + // Generate the signed URL + const signedUrl = await getSignedUrl(s3Client, command, { expiresIn }); + + // Cache the signed URL with TTL matching the expiration time (convert seconds to milliseconds) + signedUrlCache.set(s3Url, signedUrl, (expiresIn * 1000) - 60000); // Subtract 1 minute to ensure it doesn't expire before use + + return signedUrl; + } catch (error) { + console.error("Error generating signed URL:", error); + throw new Error("Failed to generate signed URL"); + } +} + +/** + * Get the original S3 URL from a signed URL + * @param signedUrl The signed URL + * @returns The original S3 URL if found in cache, otherwise null + */ +export function getOriginalUrlFromSignedUrl(signedUrl: string|null): string|null { + if (!signedUrl) { + return null; + } + + // Try to find the original URL in our cache + const originalUrl = signedUrlCache.getOriginalUrl(signedUrl); + + return originalUrl || null; +} + +/** + * Generate signed URLs for multiple S3 URLs + * @param s3Urls Array of S3 URLs or null values + * @param expiresIn Expiration time in seconds (default: 259200 seconds = 3 days) + * @returns Array of signed URLs (empty strings for null/invalid inputs) + */ +export async function generateSignedUrlsFromS3Urls(s3Urls: (string|null)[], expiresIn: number = 259200): Promise { + if (!s3Urls || !s3Urls.length) { + return []; + } + + try { + // Process URLs in parallel for better performance + const signedUrls = await Promise.all( + s3Urls.map(url => generateSignedUrlFromS3Url(url, expiresIn).catch(() => '')) + ); + + return signedUrls; + } catch (error) { + console.error("Error generating multiple signed URLs:", error); + // Return an array of empty strings with the same length as input + return s3Urls.map(() => ''); + } +} + +export async function generateUploadUrl(key: string, mimeType: string, expiresIn: number = 180): Promise { + try { + // Insert record into upload_url_status + await db.insert(uploadUrlStatus).values({ + key: key, + status: 'pending', + }); + + // Generate signed upload URL + const command = new PutObjectCommand({ + Bucket: s3BucketName, + Key: key, + ContentType: mimeType, + }); + + const signedUrl = await getSignedUrl(s3Client, command, { expiresIn }); + return signedUrl; + } catch (error) { + console.error('Error generating upload URL:', error); + throw new Error('Failed to generate upload URL'); + } +} + + +// export function extractKeyFromPresignedUrl(url:string) { +// const u = new URL(url); +// const rawKey = u.pathname.replace(/^\/+/, ""); // remove leading slash +// return decodeURIComponent(rawKey); +// } + +// New function (excludes bucket name) +export function extractKeyFromPresignedUrl(url: string): string { + const u = new URL(url); + const rawKey = u.pathname.replace(/^\/+/, ""); // remove leading slash + const decodedKey = decodeURIComponent(rawKey); + // Remove bucket prefix + const parts = decodedKey.split('/'); + parts.shift(); // Remove bucket name + return parts.join('/'); +} + +export async function claimUploadUrl(url: string): Promise { + try { + const semiKey = extractKeyFromPresignedUrl(url); + const key = s3BucketName+'/'+ semiKey + + // Update status to 'claimed' if currently 'pending' + const result = await db + .update(uploadUrlStatus) + .set({ status: 'claimed' }) + .where(and(eq(uploadUrlStatus.key, semiKey), eq(uploadUrlStatus.status, 'pending'))) + .returning(); + + if (result.length === 0) { + throw new Error('Upload URL not found or already claimed'); + } + } catch (error) { + console.error('Error claiming upload URL:', error); + throw new Error('Failed to claim upload URL'); + } +} \ No newline at end of file diff --git a/apps/backend/src/lib/signed-url-cache.ts b/apps/backend/src/lib/signed-url-cache.ts new file mode 100755 index 0000000..0f4e98c --- /dev/null +++ b/apps/backend/src/lib/signed-url-cache.ts @@ -0,0 +1,263 @@ +import fs from 'fs'; +import path from 'path'; + +const CACHE_FILE_PATH = path.join('.', 'assets', 'signed-url-cache.json'); + +// Interface for cache entries with TTL +interface CacheEntry { + value: string; + expiresAt: number; // Timestamp when this entry expires +} + +class SignedURLCache { + private originalToSignedCache: Map; + private signedToOriginalCache: Map; + + constructor() { + this.originalToSignedCache = new Map(); + this.signedToOriginalCache = new Map(); + + // Create cache directory if it doesn't exist + const cacheDir = path.dirname(CACHE_FILE_PATH); + if (!fs.existsSync(cacheDir)) { + console.log('creating the directory') + + fs.mkdirSync(cacheDir, { recursive: true }); + } + else { + console.log('the directory is already present') + + } + } + + /** + * Get a signed URL from the cache using an original URL as the key + */ + get(originalUrl: string): string | undefined { + const entry = this.originalToSignedCache.get(originalUrl); + + // If no entry or entry has expired, return undefined + if (!entry || Date.now() > entry.expiresAt) { + if (entry) { + // Remove expired entry + this.originalToSignedCache.delete(originalUrl); + // Also remove from reverse mapping if it exists + this.signedToOriginalCache.delete(entry.value); + } + return undefined; + } + + return entry.value; + } + + /** + * Get the original URL from the cache using a signed URL as the key + */ + getOriginalUrl(signedUrl: string): string | undefined { + const entry = this.signedToOriginalCache.get(signedUrl); + + // If no entry or entry has expired, return undefined + if (!entry || Date.now() > entry.expiresAt) { + if (entry) { + // Remove expired entry + this.signedToOriginalCache.delete(signedUrl); + // Also remove from primary mapping if it exists + this.originalToSignedCache.delete(entry.value); + } + return undefined; + } + + return entry.value; + } + + /** + * Set a value in the cache with a TTL (Time To Live) + * @param originalUrl The original S3 URL + * @param signedUrl The signed URL + * @param ttlMs Time to live in milliseconds (default: 3 days) + */ + set(originalUrl: string, signedUrl: string, ttlMs: number = 259200000): void { + const expiresAt = Date.now() + ttlMs; + + const entry: CacheEntry = { + value: signedUrl, + expiresAt + }; + + const reverseEntry: CacheEntry = { + value: originalUrl, + expiresAt + }; + + this.originalToSignedCache.set(originalUrl, entry); + this.signedToOriginalCache.set(signedUrl, reverseEntry); + } + + has(originalUrl: string): boolean { + const entry = this.originalToSignedCache.get(originalUrl); + + // Entry exists and hasn't expired + return !!entry && Date.now() <= entry.expiresAt; + } + + hasSignedUrl(signedUrl: string): boolean { + const entry = this.signedToOriginalCache.get(signedUrl); + + // Entry exists and hasn't expired + return !!entry && Date.now() <= entry.expiresAt; + } + + clear(): void { + this.originalToSignedCache.clear(); + this.signedToOriginalCache.clear(); + this.saveToDisk(); + } + + /** + * Remove all expired entries from the cache + * @returns The number of expired entries that were removed + */ + clearExpired(): number { + const now = Date.now(); + let removedCount = 0; + + // Clear expired entries from original to signed cache + for (const [originalUrl, entry] of this.originalToSignedCache.entries()) { + if (now > entry.expiresAt) { + this.originalToSignedCache.delete(originalUrl); + removedCount++; + } + } + + // Clear expired entries from signed to original cache + for (const [signedUrl, entry] of this.signedToOriginalCache.entries()) { + if (now > entry.expiresAt) { + this.signedToOriginalCache.delete(signedUrl); + // No need to increment removedCount as we've already counted these in the first loop + } + } + + if (removedCount > 0) { + console.log(`SignedURLCache: Cleared ${removedCount} expired entries`); + } + + return removedCount; + } + + /** + * Save the cache to disk + */ + saveToDisk(): void { + try { + // Remove expired entries before saving + const removedCount = this.clearExpired(); + + // Convert Maps to serializable objects + const serializedOriginalToSigned: Record = {}; + const serializedSignedToOriginal: Record = {}; + + for (const [originalUrl, entry] of this.originalToSignedCache.entries()) { + serializedOriginalToSigned[originalUrl] = { + value: entry.value, + expiresAt: entry.expiresAt + }; + } + + for (const [signedUrl, entry] of this.signedToOriginalCache.entries()) { + serializedSignedToOriginal[signedUrl] = { + value: entry.value, + expiresAt: entry.expiresAt + }; + } + + const serializedCache = { + originalToSigned: serializedOriginalToSigned, + signedToOriginal: serializedSignedToOriginal + }; + + // Write to file + fs.writeFileSync( + CACHE_FILE_PATH, + JSON.stringify(serializedCache), + 'utf8' + ); + + console.log(`SignedURLCache: Saved ${this.originalToSignedCache.size} entries to disk`); + } catch (error) { + console.error('Error saving SignedURLCache to disk:', error); + } + } + + /** + * Load the cache from disk + */ + loadFromDisk(): void { + try { + if (fs.existsSync(CACHE_FILE_PATH)) { + // Read from file + const data = fs.readFileSync(CACHE_FILE_PATH, 'utf8'); + + // Parse the data + const parsedData = JSON.parse(data) as { + originalToSigned: Record, + signedToOriginal: Record + }; + + // Only load entries that haven't expired yet + const now = Date.now(); + let loadedCount = 0; + let expiredCount = 0; + + // Load original to signed mappings + if (parsedData.originalToSigned) { + for (const [originalUrl, entry] of Object.entries(parsedData.originalToSigned)) { + if (now <= entry.expiresAt) { + this.originalToSignedCache.set(originalUrl, entry); + loadedCount++; + } else { + expiredCount++; + } + } + } + + // Load signed to original mappings + if (parsedData.signedToOriginal) { + for (const [signedUrl, entry] of Object.entries(parsedData.signedToOriginal)) { + if (now <= entry.expiresAt) { + this.signedToOriginalCache.set(signedUrl, entry); + // Don't increment loadedCount as these are pairs of what we already counted + } else { + // Don't increment expiredCount as these are pairs of what we already counted + } + } + } + + console.log(`SignedURLCache: Loaded ${loadedCount} valid entries from disk (skipped ${expiredCount} expired entries)`); + } else { + console.log('SignedURLCache: No cache file found, starting with empty cache'); + } + } catch (error) { + console.error('Error loading SignedURLCache from disk:', error); + // Start with empty caches if loading fails + this.originalToSignedCache = new Map(); + this.signedToOriginalCache = new Map(); + } + } +} + +// Create a singleton instance to be used throughout the application +const signedUrlCache = new SignedURLCache(); + +process.on('SIGINT', () => { + console.log('SignedURLCache: Saving cache before shutdown...'); + signedUrlCache.saveToDisk(); + process.exit(0); +}); + +process.on('SIGTERM', () => { + console.log('SignedURLCache: Saving cache before shutdown...'); + signedUrlCache.saveToDisk(); + process.exit(0); +}); + +export default signedUrlCache; \ No newline at end of file diff --git a/apps/backend/src/lib/upload-handler.ts b/apps/backend/src/lib/upload-handler.ts new file mode 100755 index 0000000..3caa4c2 --- /dev/null +++ b/apps/backend/src/lib/upload-handler.ts @@ -0,0 +1,8 @@ +import multerParent from 'multer'; +const uploadHandler = multerParent({ + limits: { + fileSize: 10 * 1024 * 1024, // 10 MB + } +}); + +export default uploadHandler \ No newline at end of file diff --git a/apps/backend/src/main-router.ts b/apps/backend/src/main-router.ts new file mode 100755 index 0000000..619a090 --- /dev/null +++ b/apps/backend/src/main-router.ts @@ -0,0 +1,64 @@ +import { Router, Request, Response, NextFunction } from "express"; +import avRouter from "./admin-apis/av-router"; +import { ApiError } from "./lib/api-error"; +import v1Router from "./v1-router"; +import testController from "./test-controller"; +import { authenticateUser } from "./middleware/auth.middleware"; +import { raiseComplaint } from "./uv-apis/user-rest.controller"; +import uploadHandler from "./lib/upload-handler"; + +const router = Router(); + +// Health check endpoints (no auth required) +router.get('/health', (req: Request, res: Response) => { + res.status(200).json({ + status: 'OK', + timestamp: new Date().toISOString(), + uptime: process.uptime(), + message: 'Hello world' + }); +}); +router.get('/seed', (req:Request, res: Response) => { + res.status(200).json({ + status: 'OK', + timestamp: new Date().toISOString(), + uptime: process.uptime() + }); +}) + +// Apply authentication middleware to all subsequent routes +router.use(authenticateUser); + +router.use('/v1', v1Router); +// router.use('/av', avRouter); +router.use('/test', testController); + +// User REST APIs +router.post('/uv/complaints/raise', + uploadHandler.array('images', 5), + raiseComplaint +); + +// Global error handling middleware +router.use((err: Error, req: Request, res: Response, next: NextFunction) => { + console.error('Error:', err); + + if (err instanceof ApiError) { + return res.status(err.statusCode).json({ + error: err.message, + details: err.details, + statusCode: err.statusCode + }); + } + + // Handle unknown errors + return res.status(500).json({ + error: 'Internal Server Error', + message: process.env.NODE_ENV === 'development' ? err.message : undefined, + statusCode: 500 + }); +}); + +const mainRouter = router; + +export default mainRouter; \ No newline at end of file diff --git a/apps/backend/src/middleware/auth.middleware.ts b/apps/backend/src/middleware/auth.middleware.ts new file mode 100644 index 0000000..3ff1de4 --- /dev/null +++ b/apps/backend/src/middleware/auth.middleware.ts @@ -0,0 +1,67 @@ +import { Request, Response, NextFunction } from 'express'; +import jwt from 'jsonwebtoken'; +import { db } from '../db/db_index'; +import { staffUsers, userDetails } from '../db/schema'; +import { eq } from 'drizzle-orm'; +import { ApiError } from '../lib/api-error'; + +interface AuthenticatedRequest extends Request { + user?: { + userId: number; + name?: string; + email?: string; + mobile?: string; + }; + staffUser?: { + id: number; + name: string; + }; +} + +export const authenticateUser = async (req: AuthenticatedRequest, res: Response, next: NextFunction) => { + try { + const authHeader = req.headers.authorization; + + if (!authHeader?.startsWith('Bearer ')) { + throw new ApiError('Authorization token required', 401); + } + + const token = authHeader.substring(7); + console.log(req.headers) + + const decoded = jwt.verify(token, process.env.JWT_SECRET || 'your-secret-key') as any; + + // Check if this is a staff token (has staffId) + if (decoded.staffId) { + // This is a staff token, verify staff exists + const staff = await db.query.staffUsers.findFirst({ + where: eq(staffUsers.id, decoded.staffId), + }); + + if (!staff) { + throw new ApiError('Invalid staff token', 401); + } + + req.staffUser = { + id: staff.id, + name: staff.name, + }; + } else { + // This is a regular user token + req.user = decoded; + + // Check if user is suspended + const details = await db.query.userDetails.findFirst({ + where: eq(userDetails.userId, decoded.userId), + }); + + if (details?.isSuspended) { + throw new ApiError('Account suspended', 403); + } + } + + next(); + } catch (error) { + next(error); + } +}; \ No newline at end of file diff --git a/apps/backend/src/middleware/auth.ts b/apps/backend/src/middleware/auth.ts new file mode 100755 index 0000000..d7a091f --- /dev/null +++ b/apps/backend/src/middleware/auth.ts @@ -0,0 +1,67 @@ +import { Request, Response, NextFunction } from 'express'; +import jwt from 'jsonwebtoken'; +import { ApiError } from '../lib/api-error'; + +// Extend the Request interface to include user property +declare global { + namespace Express { + interface Request { + user?: any; + } + } +} + +export const verifyToken = (req: Request, res: Response, next: NextFunction) => { + try { + // Get token from Authorization header + const authHeader = req.headers.authorization; + + + if (!authHeader || !authHeader.startsWith('Bearer ')) { + throw new ApiError('Access denied. No token provided', 401); + } + + const token = authHeader.split(' ')[1]; + + if (!token) { + throw new ApiError('Access denied. Invalid token format', 401); + } + + // Verify token + const decoded = jwt.verify(token, process.env.JWT_SECRET || 'your-secret-key'); + + + // Add user info to request + req.user = decoded; + + next(); + } catch (error) { + if (error instanceof jwt.JsonWebTokenError) { + next(new ApiError('Invalid Auth Credentials', 401)); + } else { + next(error); + } + } +}; + +export const requireRole = (roles: string[]) => { + return (req: Request, res: Response, next: NextFunction) => { + try { + if (!req.user) { + throw new ApiError('Authentication required', 401); + } + + // Check if user has any of the required roles + const userRoles = req.user.roles || []; + const hasPermission = roles.some(role => userRoles.includes(role)); + + if (!hasPermission) { + throw new ApiError('Access denied. Insufficient permissions', 403); + } + + next(); + } catch (error) { + next(error); + } + }; +}; diff --git a/apps/backend/src/middleware/staff-auth.ts b/apps/backend/src/middleware/staff-auth.ts new file mode 100644 index 0000000..471b172 --- /dev/null +++ b/apps/backend/src/middleware/staff-auth.ts @@ -0,0 +1,76 @@ +import { Request, Response, NextFunction } from 'express'; +import jwt from 'jsonwebtoken'; +import { db } from '../db/db_index'; +import { staffUsers } from '../db/schema'; +import { eq } from 'drizzle-orm'; +import { ApiError } from '../lib/api-error'; + +// Extend Request interface to include staffUser +declare global { + namespace Express { + interface Request { + staffUser?: { + id: number; + name: string; + }; + } + } +} + +/** + * Verify JWT token and extract payload + */ +const verifyStaffToken = (token: string) => { + try { + return jwt.verify(token, process.env.JWT_SECRET || 'default-secret'); + } catch (error) { + throw new ApiError('Access denied. Invalid auth credentials', 401); + } +}; + +/** + * Middleware to authenticate staff users and attach staffUser to request + */ +export const authenticateStaff = async (req: Request, res: Response, next: NextFunction) => { + try { + // Extract token from Authorization header + const authHeader = req.headers.authorization; + + if (!authHeader || !authHeader.startsWith('Bearer ')) { + throw new ApiError('Staff authentication required', 401); + } + + const token = authHeader.split(' ')[1]; + + if (!token) { + throw new ApiError('Staff authentication token missing', 401); + } + + // Verify token and extract payload + const decoded = verifyStaffToken(token) as any; + + // Verify staffId exists in token + if (!decoded.staffId) { + throw new ApiError('Invalid staff token format', 401); + } + + // Fetch staff user from database + const staff = await db.query.staffUsers.findFirst({ + where: eq(staffUsers.id, decoded.staffId), + }); + + if (!staff) { + throw new ApiError('Staff user not found', 401); + } + + // Attach staff user to request + req.staffUser = { + id: staff.id, + name: staff.name, + }; + + next(); + } catch (error) { + next(error); + } +}; \ No newline at end of file diff --git a/apps/backend/src/test-controller.ts b/apps/backend/src/test-controller.ts new file mode 100644 index 0000000..ae98af6 --- /dev/null +++ b/apps/backend/src/test-controller.ts @@ -0,0 +1,13 @@ +import { Router, Request, Response } from 'express'; + +const router = Router(); + +router.get('/', (req: Request, res: Response) => { + res.json({ + status: 'ok', + message: 'Health check passed', + timestamp: new Date().toISOString(), + }); +}); + +export default router; \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/address.ts b/apps/backend/src/trpc/admin-apis/address.ts new file mode 100644 index 0000000..32f753a --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/address.ts @@ -0,0 +1,32 @@ +import { z } from 'zod'; +import { addressZones, addressAreas } from '../../db/schema'; +import { eq, desc } from 'drizzle-orm'; +import { db } from '../../db/db_index'; +import { router,protectedProcedure } from '../trpc-index'; + +const addressRouter = router({ + getZones: protectedProcedure.query(async () => { + const zones = await db.select().from(addressZones).orderBy(desc(addressZones.addedAt)); + return zones + }), + + getAreas: protectedProcedure.query(async () => { + const areas = await db.select().from(addressAreas).orderBy(desc(addressAreas.createdAt)); + return areas + }), + + createZone: protectedProcedure.input(z.object({ zoneName: z.string().min(1) })).mutation(async ({ input }) => { + + const zone = await db.insert(addressZones).values({ zoneName: input.zoneName }).returning(); + return {zone: zone}; + }), + + createArea: protectedProcedure.input(z.object({ placeName: z.string().min(1), zoneId: z.number().nullable() })).mutation(async ({ input }) => { + const area = await db.insert(addressAreas).values({ placeName: input.placeName, zoneId: input.zoneId }).returning(); + return {area}; + }), + + // TODO: Add update and delete mutations if needed +}); + +export default addressRouter; \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/admin-trpc-index.ts b/apps/backend/src/trpc/admin-apis/admin-trpc-index.ts new file mode 100644 index 0000000..a2e0571 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/admin-trpc-index.ts @@ -0,0 +1,34 @@ +import { router } from '../trpc-index'; +import { complaintRouter } from './complaint'; +import { couponRouter } from './coupon'; +import { cancelledOrdersRouter } from './cancelled-orders'; +import { orderRouter } from './order'; +import { vendorSnippetsRouter } from './vendor-snippets'; +import { slotsRouter } from './slots'; +import { productRouter } from './product'; +import { staffUserRouter } from './staff-user'; +import { storeRouter } from './store'; +import { adminPaymentsRouter } from './payments'; +import addressRouter from './address'; +import { bannerRouter } from './banner'; +import { userRouter } from './user'; +import { constRouter } from './const'; + +export const adminRouter = router({ + complaint: complaintRouter, + coupon: couponRouter, + cancelledOrders: cancelledOrdersRouter, + order: orderRouter, + vendorSnippets: vendorSnippetsRouter, + slots: slotsRouter, + product: productRouter, + staffUser: staffUserRouter, + store: storeRouter, + payments: adminPaymentsRouter, + address: addressRouter, + banner: bannerRouter, + user: userRouter, + const: constRouter, +}); + +export type AdminRouter = typeof adminRouter; \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/banner.ts b/apps/backend/src/trpc/admin-apis/banner.ts new file mode 100644 index 0000000..f50880b --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/banner.ts @@ -0,0 +1,162 @@ +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { homeBanners } from '../../db/schema'; +import { eq, and, desc, sql } from 'drizzle-orm'; +import { protectedProcedure, router } from '../trpc-index'; +import { extractKeyFromPresignedUrl, generateSignedUrlFromS3Url } from '../../lib/s3-client'; +import { ApiError } from 'src/lib/api-error'; + +export const bannerRouter = router({ + // Get all banners + getBanners: protectedProcedure + .query(async () => { + try { + + const banners = await db.query.homeBanners.findMany({ + orderBy: desc(homeBanners.createdAt), // Order by creation date instead + // Removed product relationship since we now use productIds array + }); + + // Convert S3 keys to signed URLs for client + const bannersWithSignedUrls = await Promise.all( + banners.map(async (banner) => { + try { + return { + ...banner, + imageUrl: banner.imageUrl ? await generateSignedUrlFromS3Url(banner.imageUrl) : banner.imageUrl, + // Ensure productIds is always an array + productIds: banner.productIds || [], + }; + } catch (error) { + console.error(`Failed to generate signed URL for banner ${banner.id}:`, error); + return { + ...banner, + imageUrl: banner.imageUrl, // Keep original on error + // Ensure productIds is always an array + productIds: banner.productIds || [], + }; + } + }) + ); + + return { + banners: bannersWithSignedUrls, + }; + } + catch(e:any) { + console.log(e) + + throw new ApiError(e.message); + } + }), + + // Get single banner by ID + getBanner: protectedProcedure + .input(z.object({ id: z.number() })) + .query(async ({ input }) => { + const banner = await db.query.homeBanners.findFirst({ + where: eq(homeBanners.id, input.id), + // Removed product relationship since we now use productIds array + }); + + if (banner) { + try { + // Convert S3 key to signed URL for client + if (banner.imageUrl) { + banner.imageUrl = await generateSignedUrlFromS3Url(banner.imageUrl); + } + } catch (error) { + console.error(`Failed to generate signed URL for banner ${banner.id}:`, error); + // Keep original imageUrl on error + } + + // Ensure productIds is always an array (handle migration compatibility) + if (!banner.productIds) { + banner.productIds = []; + } + } + + return banner; + }), + + // Create new banner + createBanner: protectedProcedure + .input(z.object({ + name: z.string().min(1), + imageUrl: z.string().url(), + description: z.string().optional(), + productIds: z.array(z.number()).optional(), + redirectUrl: z.string().url().optional(), + // serialNum removed completely + })) + .mutation(async ({ input }) => { + try { + const imageUrl = extractKeyFromPresignedUrl(input.imageUrl) + const [banner] = await db.insert(homeBanners).values({ + name: input.name, + imageUrl: imageUrl, + description: input.description, + productIds: input.productIds || [], + redirectUrl: input.redirectUrl, + serialNum: 999, // Default value, not used + isActive: false, // Default to inactive + }).returning(); + + return banner; + } catch (error) { + console.error('Error creating banner:', error); + throw error; // Re-throw to maintain tRPC error handling + } + }), + + // Update banner + updateBanner: protectedProcedure + .input(z.object({ + id: z.number(), + name: z.string().min(1).optional(), + imageUrl: z.string().url().optional(), + description: z.string().optional(), + productIds: z.array(z.number()).optional(), + redirectUrl: z.string().url().optional(), + serialNum: z.number().nullable().optional(), + isActive: z.boolean().optional(), + })) + .mutation(async ({ input }) => { + try { + + const { id, ...updateData } = input; + const incomingProductIds = input.productIds; + // Extract S3 key from presigned URL if imageUrl is provided + const processedData = { + ...updateData, + ...(updateData.imageUrl && { + imageUrl: extractKeyFromPresignedUrl(updateData.imageUrl) + }), + }; + + // Handle serialNum null case + const finalData: any = { ...processedData }; + if ('serialNum' in finalData && finalData.serialNum === null) { + // Set to null explicitly + finalData.serialNum = null; + } + + const [banner] = await db.update(homeBanners) + .set({ ...finalData, lastUpdated: new Date(), }) + .where(eq(homeBanners.id, id)) + .returning(); + return banner; + } catch (error) { + console.error('Error updating banner:', error); + throw error; + } + }), + + // Delete banner + deleteBanner: protectedProcedure + .input(z.object({ id: z.number() })) + .mutation(async ({ input }) => { + await db.delete(homeBanners).where(eq(homeBanners.id, input.id)); + return { success: true }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/cancelled-orders.ts b/apps/backend/src/trpc/admin-apis/cancelled-orders.ts new file mode 100644 index 0000000..0fa54dc --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/cancelled-orders.ts @@ -0,0 +1,179 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { orders, orderStatus, users, addresses, orderItems, productInfo, units, refunds } from '../../db/schema'; +import { eq, desc } from 'drizzle-orm'; + +const updateCancellationReviewSchema = z.object({ + orderId: z.number(), + cancellationReviewed: z.boolean(), + adminNotes: z.string().optional(), +}); + +const updateRefundSchema = z.object({ + orderId: z.number(), + isRefundDone: z.boolean(), +}); + +export const cancelledOrdersRouter = router({ + getAll: protectedProcedure + .query(async () => { + // First get cancelled order statuses with order details + const cancelledOrderStatuses = await db.query.orderStatus.findMany({ + where: eq(orderStatus.isCancelled, true), + with: { + order: { + with: { + user: true, + address: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + refunds: true, + }, + }, + }, + orderBy: [desc(orderStatus.orderTime)], + }); + + const filteredStatuses = cancelledOrderStatuses.filter(status => { + return status.order.isCod || status.paymentStatus === 'success'; + }); + + return filteredStatuses.map(status => { + const refund = status.order.refunds[0]; + return { + id: status.order.id, + readableId: status.order.readableId, + customerName: `${status.order.user.name}`, + address: `${status.order.address.addressLine1}, ${status.order.address.city}`, + totalAmount: status.order.totalAmount, + cancellationReviewed: status.cancellationReviewed || false, + isRefundDone: refund?.refundStatus === 'processed' || false, + adminNotes: status.order.adminNotes, + cancelReason: status.cancelReason, + paymentMode: status.order.isCod ? 'COD' : 'Online', + paymentStatus: status.paymentStatus || 'pending', + items: status.order.orderItems.map(item => ({ + name: item.product.name, + quantity: item.quantity, + price: item.price, + unit: item.product.unit?.shortNotation, + amount: parseFloat(item.price.toString()) * parseFloat(item.quantity || '0'), + })), + createdAt: status.order.createdAt, + }; + }); + }), + + updateReview: protectedProcedure + .input(updateCancellationReviewSchema) + .mutation(async ({ input }) => { + const { orderId, cancellationReviewed, adminNotes } = input; + + const result = await db.update(orderStatus) + .set({ + cancellationReviewed, + cancellationAdminNotes: adminNotes || null, + cancellationReviewedAt: new Date(), + }) + .where(eq(orderStatus.orderId, orderId)) + .returning(); + + if (result.length === 0) { + throw new Error("Cancellation record not found"); + } + + return result[0]; + }), + + getById: protectedProcedure + .input(z.object({ id: z.number() })) + .query(async ({ input }) => { + const { id } = input; + + // Get cancelled order with full details + const cancelledOrderStatus = await db.query.orderStatus.findFirst({ + where: eq(orderStatus.id, id), + with: { + order: { + with: { + user: true, + address: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + }, + }, + }, + }); + + if (!cancelledOrderStatus || !cancelledOrderStatus.isCancelled) { + throw new Error("Cancelled order not found"); + } + + // Get refund details separately + const refund = await db.query.refunds.findFirst({ + where: eq(refunds.orderId, cancelledOrderStatus.orderId), + }); + + const order = cancelledOrderStatus.order; + + // Format the response similar to the getAll method + const formattedOrder = { + id: order.id, + readableId: order.readableId, + customerName: order.user.name, + address: `${order.address.addressLine1}${order.address.addressLine2 ? ', ' + order.address.addressLine2 : ''}, ${order.address.city}, ${order.address.state} ${order.address.pincode}`, + totalAmount: order.totalAmount, + cancellationReviewed: cancelledOrderStatus.cancellationReviewed || false, + isRefundDone: refund?.refundStatus === 'processed' || false, + adminNotes: cancelledOrderStatus.cancellationAdminNotes || null, + cancelReason: cancelledOrderStatus.cancelReason || null, + items: order.orderItems.map((item: any) => ({ + name: item.product.name, + quantity: item.quantity, + price: parseFloat(item.price.toString()), + unit: item.product.unit?.shortNotation || 'unit', + amount: parseFloat(item.price.toString()) * parseFloat(item.quantity), + image: item.product.images?.[0] || null, + })), + createdAt: order.createdAt.toISOString(), + }; + + return { order: formattedOrder }; + }), + + updateRefund: protectedProcedure + .input(updateRefundSchema) + .mutation(async ({ input }) => { + const { orderId, isRefundDone } = input; + + const refundStatus = isRefundDone ? 'processed' : 'none'; + const result = await db.update(refunds) + .set({ + refundStatus, + refundProcessedAt: isRefundDone ? new Date() : null, + }) + .where(eq(refunds.orderId, orderId)) + .returning(); + + if (result.length === 0) { + throw new Error("Cancellation record not found"); + } + + return result[0]; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/complaint.ts b/apps/backend/src/trpc/admin-apis/complaint.ts new file mode 100644 index 0000000..01c1023 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/complaint.ts @@ -0,0 +1,79 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { complaints, users } from '../../db/schema'; +import { eq } from 'drizzle-orm'; +import { generateSignedUrlsFromS3Urls } from '../../lib/s3-client'; + +export const complaintRouter = router({ + getAll: protectedProcedure + .input(z.object({ + page: z.number().optional().default(1), + limit: z.number().optional().default(10), + })) + .query(async ({ input }) => { + const page = input.page; + const limit = input.limit; + const offset = (page - 1) * limit; + + const [complaintsData, totalCountResult] = await Promise.all([ + db + .select({ + id: complaints.id, + complaintBody: complaints.complaintBody, + userId: complaints.userId, + orderId: complaints.orderId, + isResolved: complaints.isResolved, + createdAt: complaints.createdAt, + userName: users.name, + images: complaints.images, + }) + .from(complaints) + .leftJoin(users, eq(complaints.userId, users.id)) + .orderBy(complaints.createdAt) + .limit(limit) + .offset(offset), + db + .select({ count: db.$count(complaints) }) + .from(complaints), + ]); + + const totalCount = totalCountResult[0].count; + + // Generate signed URLs for images + const complaintsWithSignedImages = await Promise.all( + complaintsData.map(async (c) => { + const signedImages = c.images + ? await generateSignedUrlsFromS3Urls(c.images as string[]) + : []; + + return { + id: c.id, + text: c.complaintBody, + userId: c.userId, + userName: c.userName, + orderId: c.orderId, + status: c.isResolved ? 'resolved' : 'pending', + createdAt: c.createdAt, + images: signedImages, + }; + }) + ); + + return { + complaints: complaintsWithSignedImages, + totalCount, + }; + }), + + resolve: protectedProcedure + .input(z.object({ id: z.string(), response: z.string().optional() })) + .mutation(async ({ input }) => { + await db + .update(complaints) + .set({ isResolved: true, response: input.response }) + .where(eq(complaints.id, parseInt(input.id))); + + return { message: 'Complaint resolved successfully' }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/const.ts b/apps/backend/src/trpc/admin-apis/const.ts new file mode 100644 index 0000000..b9f60b4 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/const.ts @@ -0,0 +1,61 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { keyValStore } from '../../db/schema'; +import { computeConstants } from '../../lib/const-store'; +import { CONST_KEYS } from '../../lib/const-keys'; + +export const constRouter = router({ + getConstants: protectedProcedure + .query(async () => { + + const constants = await db.select().from(keyValStore); + + const resp = constants.map(c => ({ + key: c.key, + value: c.value, + })); + + return resp; + }), + + updateConstants: protectedProcedure + .input(z.object({ + constants: z.array(z.object({ + key: z.string(), + value: z.any(), + })), + })) + .mutation(async ({ input }) => { + const { constants } = input; + + const validKeys = Object.values(CONST_KEYS) as string[]; + const invalidKeys = constants + .filter(c => !validKeys.includes(c.key)) + .map(c => c.key); + + if (invalidKeys.length > 0) { + throw new Error(`Invalid constant keys: ${invalidKeys.join(', ')}`); + } + + await db.transaction(async (tx) => { + for (const { key, value } of constants) { + await tx.insert(keyValStore) + .values({ key, value }) + .onConflictDoUpdate({ + target: keyValStore.key, + set: { value }, + }); + } + }); + + // Refresh all constants in Redis after database update + await computeConstants(); + + return { + success: true, + updatedCount: constants.length, + keys: constants.map(c => c.key), + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/coupon.ts b/apps/backend/src/trpc/admin-apis/coupon.ts new file mode 100644 index 0000000..d659fde --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/coupon.ts @@ -0,0 +1,711 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { coupons, users, staffUsers, orders, couponApplicableUsers, couponApplicableProducts, orderStatus, reservedCoupons } from '../../db/schema'; +import { eq, and, like, or, inArray, lt } from 'drizzle-orm'; +import dayjs from 'dayjs'; + +const createCouponBodySchema = z.object({ + couponCode: z.string().optional(), + isUserBased: z.boolean().optional(), + discountPercent: z.number().optional(), + flatDiscount: z.number().optional(), + minOrder: z.number().optional(), + targetUser: z.number().optional(), + productIds: z.array(z.number()).optional().nullable(), + applicableUsers: z.array(z.number()).optional(), + applicableProducts: z.array(z.number()).optional(), + maxValue: z.number().optional(), + isApplyForAll: z.boolean().optional(), + validTill: z.string().optional(), + maxLimitForUser: z.number().optional(), + exclusiveApply: z.boolean().optional(), +}); + +const validateCouponBodySchema = z.object({ + code: z.string(), + userId: z.number(), + orderAmount: z.number(), +}); + +export const couponRouter = router({ + create: protectedProcedure + .input(createCouponBodySchema) + .mutation(async ({ input, ctx }) => { + const { couponCode, isUserBased, discountPercent, flatDiscount, minOrder, productIds, applicableUsers, applicableProducts, maxValue, isApplyForAll, validTill, maxLimitForUser, exclusiveApply } = input; + + // Validation: ensure at least one discount type is provided + if ((!discountPercent && !flatDiscount) || (discountPercent && flatDiscount)) { + throw new Error("Either discountPercent or flatDiscount must be provided (but not both)"); + } + + // If user-based, applicableUsers is required (unless it's apply for all) + if (isUserBased && (!applicableUsers || applicableUsers.length === 0) && !isApplyForAll) { + throw new Error("applicableUsers is required for user-based coupons (or set isApplyForAll to true)"); + } + + // Cannot be both user-based and apply for all + if (isUserBased && isApplyForAll) { + throw new Error("Cannot be both user-based and apply for all users"); + } + + // If applicableUsers is provided, verify users exist + if (applicableUsers && applicableUsers.length > 0) { + const existingUsers = await db.query.users.findMany({ + where: inArray(users.id, applicableUsers), + columns: { id: true }, + }); + if (existingUsers.length !== applicableUsers.length) { + throw new Error("Some applicable users not found"); + } + } + + // Get staff user ID from auth middleware + const staffUserId = ctx.staffUser?.id; + if (!staffUserId) { + throw new Error("Unauthorized"); + } + + // Generate coupon code if not provided + let finalCouponCode = couponCode; + if (!finalCouponCode) { + // Generate a unique coupon code + const timestamp = Date.now().toString().slice(-6); + const random = Math.random().toString(36).substring(2, 8).toUpperCase(); + finalCouponCode = `MF${timestamp}${random}`; + } + + // Check if coupon code already exists + const existingCoupon = await db.query.coupons.findFirst({ + where: eq(coupons.couponCode, finalCouponCode), + }); + + if (existingCoupon) { + throw new Error("Coupon code already exists"); + } + + const result = await db.insert(coupons).values({ + couponCode: finalCouponCode, + isUserBased: isUserBased || false, + discountPercent: discountPercent?.toString(), + flatDiscount: flatDiscount?.toString(), + minOrder: minOrder?.toString(), + productIds: productIds || null, + createdBy: staffUserId, + maxValue: maxValue?.toString(), + isApplyForAll: isApplyForAll || false, + validTill: validTill ? dayjs(validTill).toDate() : undefined, + maxLimitForUser: maxLimitForUser, + exclusiveApply: exclusiveApply || false, + }).returning(); + + const coupon = result[0]; + + // Insert applicable users + if (applicableUsers && applicableUsers.length > 0) { + await db.insert(couponApplicableUsers).values( + applicableUsers.map(userId => ({ + couponId: coupon.id, + userId, + })) + ); + } + + // Insert applicable products + if (applicableProducts && applicableProducts.length > 0) { + await db.insert(couponApplicableProducts).values( + applicableProducts.map(productId => ({ + couponId: coupon.id, + productId, + })) + ); + } + + return coupon; + }), + + getAll: protectedProcedure + .input(z.object({ + cursor: z.number().optional(), + limit: z.number().default(50), + search: z.string().optional(), + })) + .query(async ({ input }) => { + const { cursor, limit, search } = input; + + let whereCondition = undefined; + const conditions = []; + + if (cursor) { + conditions.push(lt(coupons.id, cursor)); + } + + if (search && search.trim()) { + conditions.push(like(coupons.couponCode, `%${search}%`)); + } + + if (conditions.length > 0) { + whereCondition = and(...conditions); + } + + const result = await db.query.coupons.findMany({ + where: whereCondition, + with: { + creator: true, + applicableUsers: { + with: { + user: true, + }, + }, + applicableProducts: { + with: { + product: true, + }, + }, + }, + orderBy: (coupons, { desc }) => [desc(coupons.createdAt)], + limit: limit + 1, + }); + + const hasMore = result.length > limit; + const couponsList = hasMore ? result.slice(0, limit) : result; + const nextCursor = hasMore ? result[result.length - 1].id : undefined; + + return { coupons: couponsList, nextCursor }; + }), + + getById: protectedProcedure + .input(z.object({ id: z.number() })) + .query(async ({ input }) => { + const couponId = input.id; + + const result = await db.query.coupons.findFirst({ + where: eq(coupons.id, couponId), + with: { + creator: true, + applicableUsers: { + with: { + user: true, + }, + }, + applicableProducts: { + with: { + product: true, + }, + }, + }, + }); + + if (!result) { + throw new Error("Coupon not found"); + } + + return { + ...result, + productIds: (result.productIds as number[]) || undefined, + applicableUsers: result.applicableUsers.map(au => au.user), + applicableProducts: result.applicableProducts.map(ap => ap.product), + }; + }), + + update: protectedProcedure + .input(z.object({ + id: z.number(), + updates: createCouponBodySchema.extend({ + isInvalidated: z.boolean().optional(), + }), + })) + .mutation(async ({ input }) => { + const { id, updates } = input; + + // Validation: ensure discount types are valid + if (updates.discountPercent !== undefined && updates.flatDiscount !== undefined) { + if (updates.discountPercent && updates.flatDiscount) { + throw new Error("Cannot have both discountPercent and flatDiscount"); + } + } + + // If updating to user-based, applicableUsers is required + if (updates.isUserBased && (!updates.applicableUsers || updates.applicableUsers.length === 0)) { + const existingCount = await db.$count(couponApplicableUsers, eq(couponApplicableUsers.couponId, id)); + if (existingCount === 0) { + throw new Error("applicableUsers is required for user-based coupons"); + } + } + + // If applicableUsers is provided, verify users exist + if (updates.applicableUsers && updates.applicableUsers.length > 0) { + const existingUsers = await db.query.users.findMany({ + where: inArray(users.id, updates.applicableUsers), + columns: { id: true }, + }); + if (existingUsers.length !== updates.applicableUsers.length) { + throw new Error("Some applicable users not found"); + } + } + + const updateData: any = { ...updates }; + delete updateData.applicableUsers; // Remove since we use couponApplicableUsers table + if (updates.discountPercent !== undefined) { + updateData.discountPercent = updates.discountPercent?.toString(); + } + if (updates.flatDiscount !== undefined) { + updateData.flatDiscount = updates.flatDiscount?.toString(); + } + if (updates.minOrder !== undefined) { + updateData.minOrder = updates.minOrder?.toString(); + } + if (updates.maxValue !== undefined) { + updateData.maxValue = updates.maxValue?.toString(); + } + if (updates.validTill !== undefined) { + updateData.validTill = updates.validTill ? dayjs(updates.validTill).toDate() : null; + } + + const result = await db.update(coupons) + .set(updateData) + .where(eq(coupons.id, id)) + .returning(); + + if (result.length === 0) { + throw new Error("Coupon not found"); + } + + console.log('updated coupon successfully') + + // Update applicable users: delete existing and insert new + if (updates.applicableUsers !== undefined) { + await db.delete(couponApplicableUsers).where(eq(couponApplicableUsers.couponId, id)); + if (updates.applicableUsers.length > 0) { + await db.insert(couponApplicableUsers).values( + updates.applicableUsers.map(userId => ({ + couponId: id, + userId, + })) + ); + } + } + + // Update applicable products: delete existing and insert new + if (updates.applicableProducts !== undefined) { + await db.delete(couponApplicableProducts).where(eq(couponApplicableProducts.couponId, id)); + if (updates.applicableProducts.length > 0) { + await db.insert(couponApplicableProducts).values( + updates.applicableProducts.map(productId => ({ + couponId: id, + productId, + })) + ); + } + } + + return result[0]; + }), + + delete: protectedProcedure + .input(z.object({ id: z.number() })) + .mutation(async ({ input }) => { + const { id } = input; + + const result = await db.update(coupons) + .set({ isInvalidated: true }) + .where(eq(coupons.id, id)) + .returning(); + + if (result.length === 0) { + throw new Error("Coupon not found"); + } + + return { message: "Coupon invalidated successfully" }; + }), + + validate: protectedProcedure + .input(validateCouponBodySchema) + .query(async ({ input }) => { + const { code, userId, orderAmount } = input; + + if (!code || typeof code !== 'string') { + return { valid: false, message: "Invalid coupon code" }; + } + + const coupon = await db.query.coupons.findFirst({ + where: and( + eq(coupons.couponCode, code.toUpperCase()), + eq(coupons.isInvalidated, false) + ), + }); + + if (!coupon) { + return { valid: false, message: "Coupon not found or invalidated" }; + } + + // Check expiry date + if (coupon.validTill && new Date(coupon.validTill) < new Date()) { + return { valid: false, message: "Coupon has expired" }; + } + + // Check if coupon applies to all users or specific user + if (!coupon.isApplyForAll && !coupon.isUserBased) { + return { valid: false, message: "Coupon is not available for use" }; + } + + // Check minimum order amount + const minOrderValue = coupon.minOrder ? parseFloat(coupon.minOrder) : 0; + if (minOrderValue > 0 && orderAmount < minOrderValue) { + return { valid: false, message: `Minimum order amount is ${minOrderValue}` }; + } + + // Calculate discount + let discountAmount = 0; + if (coupon.discountPercent) { + const percent = parseFloat(coupon.discountPercent); + discountAmount = (orderAmount * percent) / 100; + } else if (coupon.flatDiscount) { + discountAmount = parseFloat(coupon.flatDiscount); + } + + // Apply max value limit + const maxValueLimit = coupon.maxValue ? parseFloat(coupon.maxValue) : 0; + if (maxValueLimit > 0 && discountAmount > maxValueLimit) { + discountAmount = maxValueLimit; + } + + return { + valid: true, + discountAmount, + coupon: { + id: coupon.id, + discountPercent: coupon.discountPercent, + flatDiscount: coupon.flatDiscount, + maxValue: coupon.maxValue, + } + }; + }), + + generateCancellationCoupon: protectedProcedure + .input( + z.object({ + orderId: z.number(), + }) + ) + .mutation(async ({ input, ctx }) => { + const { orderId } = input; + + // Get staff user ID from auth middleware + const staffUserId = ctx.staffUser?.id; + if (!staffUserId) { + throw new Error("Unauthorized"); + } + + // Find the order with user and order status information + const order = await db.query.orders.findFirst({ + where: eq(orders.id, orderId), + with: { + user: true, + orderStatus: true, + }, + }); + + if (!order) { + throw new Error("Order not found"); + } + + // Check if order is cancelled (check if any status entry has isCancelled: true) + // const isOrderCancelled = order.orderStatus?.some(status => status.isCancelled) || false; + // if (!isOrderCancelled) { + // throw new Error("Order is not cancelled"); + // } + + // // Check if payment method is COD + // if (order.isCod) { + // throw new Error("Can't generate refund coupon for CoD Order"); + // } + + // Verify user exists + if (!order.user) { + throw new Error("User not found for this order"); + } + + // Generate coupon code: first 3 letters of user name or mobile + orderId + const userNamePrefix = (order.user.name || order.user.mobile || 'USR').substring(0, 3).toUpperCase(); + const couponCode = `${userNamePrefix}${orderId}`; + + // Check if coupon code already exists + const existingCoupon = await db.query.coupons.findFirst({ + where: eq(coupons.couponCode, couponCode), + }); + + if (existingCoupon) { + throw new Error("Coupon code already exists"); + } + + // Get order total amount + const orderAmount = parseFloat(order.totalAmount); + + // Calculate expiry date (30 days from now) + const expiryDate = new Date(); + expiryDate.setDate(expiryDate.getDate() + 30); + + // Create the coupon and update order status in a transaction + const coupon = await db.transaction(async (tx) => { + // Create the coupon + const result = await tx.insert(coupons).values({ + couponCode, + isUserBased: true, + flatDiscount: orderAmount.toString(), + minOrder: orderAmount.toString(), + maxValue: orderAmount.toString(), + validTill: expiryDate, + maxLimitForUser: 1, + createdBy: staffUserId, + isApplyForAll: false, + }).returning(); + + const coupon = result[0]; + + // Insert applicable users + await tx.insert(couponApplicableUsers).values({ + couponId: coupon.id, + userId: order.userId, + }); + + // Update order_status with refund coupon ID + await tx.update(orderStatus) + .set({ refundCouponId: coupon.id }) + .where(eq(orderStatus.orderId, orderId)); + + return coupon; + }); + + return coupon; + }), + + getReservedCoupons: protectedProcedure + .input(z.object({ + cursor: z.number().optional(), + limit: z.number().default(50), + search: z.string().optional(), + })) + .query(async ({ input }) => { + const { cursor, limit, search } = input; + + let whereCondition = undefined; + const conditions = []; + + if (cursor) { + conditions.push(lt(reservedCoupons.id, cursor)); + } + + if (search && search.trim()) { + conditions.push(or( + like(reservedCoupons.secretCode, `%${search}%`), + like(reservedCoupons.couponCode, `%${search}%`) + )); + } + + if (conditions.length > 0) { + whereCondition = and(...conditions); + } + + const result = await db.query.reservedCoupons.findMany({ + where: whereCondition, + with: { + redeemedUser: true, + creator: true, + }, + orderBy: (reservedCoupons, { desc }) => [desc(reservedCoupons.createdAt)], + limit: limit + 1, // Fetch one extra to check if there's more + }); + + const hasMore = result.length > limit; + const coupons = hasMore ? result.slice(0, limit) : result; + const nextCursor = hasMore ? result[result.length - 1].id : undefined; + + return { + coupons, + nextCursor, + }; + }), + + createReservedCoupon: protectedProcedure + .input(createCouponBodySchema) + .mutation(async ({ input, ctx }) => { + const { couponCode, isUserBased, discountPercent, flatDiscount, minOrder, productIds, applicableUsers, applicableProducts, maxValue, isApplyForAll, validTill, maxLimitForUser, exclusiveApply } = input; + + // Validation: ensure at least one discount type is provided + if ((!discountPercent && !flatDiscount) || (discountPercent && flatDiscount)) { + throw new Error("Either discountPercent or flatDiscount must be provided (but not both)"); + } + + // For reserved coupons, applicableUsers is not used, as it's redeemed by one user + + // Get staff user ID from auth middleware + const staffUserId = ctx.staffUser?.id; + if (!staffUserId) { + throw new Error("Unauthorized"); + } + + // Generate secret code if not provided (use couponCode as base) + let secretCode = couponCode || `SECRET${Date.now().toString().slice(-6)}${Math.random().toString(36).substring(2, 8).toUpperCase()}`; + + // Check if secret code already exists + const existing = await db.query.reservedCoupons.findFirst({ + where: eq(reservedCoupons.secretCode, secretCode), + }); + + if (existing) { + throw new Error("Secret code already exists"); + } + + const result = await db.insert(reservedCoupons).values({ + secretCode, + couponCode: couponCode || `RESERVED${Date.now().toString().slice(-6)}`, + discountPercent: discountPercent?.toString(), + flatDiscount: flatDiscount?.toString(), + minOrder: minOrder?.toString(), + productIds, + maxValue: maxValue?.toString(), + validTill: validTill ? dayjs(validTill).toDate() : undefined, + maxLimitForUser, + exclusiveApply: exclusiveApply || false, + createdBy: staffUserId, + }).returning(); + + const coupon = result[0]; + + // Insert applicable products if provided + if (applicableProducts && applicableProducts.length > 0) { + await db.insert(couponApplicableProducts).values( + applicableProducts.map(productId => ({ + couponId: coupon.id, + productId, + })) + ); + } + + return coupon; + }), + + getUsersMiniInfo: protectedProcedure + .input(z.object({ + search: z.string().optional(), + limit: z.number().min(1).max(50).default(20), + offset: z.number().min(0).default(0), + })) + .query(async ({ input }) => { + const { search, limit } = input; + + let whereCondition = undefined; + if (search && search.trim()) { + whereCondition = or( + like(users.name, `%${search}%`), + like(users.mobile, `%${search}%`) + ); + } + + const userList = await db.query.users.findMany({ + where: whereCondition, + columns: { + id: true, + name: true, + mobile: true, + }, + limit: limit, + offset: input.offset, + orderBy: (users, { asc }) => [asc(users.name)], + }); + + return { + users: userList.map(user => ({ + id: user.id, + name: user.name || 'Unknown', + mobile: user.mobile, + })) + }; + }), + + createCoupon: protectedProcedure + .input(z.object({ + mobile: z.string().min(1, 'Mobile number is required'), + })) + .mutation(async ({ input, ctx }) => { + const { mobile } = input; + + // Get staff user ID from auth middleware + const staffUserId = ctx.staffUser?.id; + if (!staffUserId) { + throw new Error("Unauthorized"); + } + + // Clean mobile number (remove non-digits) + const cleanMobile = mobile.replace(/\D/g, ''); + + // Validate: exactly 10 digits + if (cleanMobile.length !== 10) { + throw new Error("Mobile number must be exactly 10 digits"); + } + + // Check if user exists, create if not + let user = await db.query.users.findFirst({ + where: eq(users.mobile, cleanMobile), + }); + + if (!user) { + // Create new user + const [newUser] = await db.insert(users).values({ + name: null, + email: null, + mobile: cleanMobile, + }).returning(); + user = newUser; + } + + // Generate unique coupon code + const timestamp = Date.now().toString().slice(-6); + const random = Math.random().toString(36).substring(2, 6).toUpperCase(); + const couponCode = `MF${cleanMobile.slice(-4)}${timestamp}${random}`; + + // Check if coupon code already exists (very unlikely but safe) + const existingCode = await db.query.coupons.findFirst({ + where: eq(coupons.couponCode, couponCode), + }); + + if (existingCode) { + throw new Error("Generated coupon code already exists - please try again"); + } + + // Create the coupon + const [coupon] = await db.insert(coupons).values({ + couponCode, + isUserBased: true, + discountPercent: "20", // 20% discount + minOrder: "1000", // ₹1000 minimum order + maxValue: "500", // ₹500 maximum discount + maxLimitForUser: 1, // One-time use + isApplyForAll: false, + exclusiveApply: false, + createdBy: staffUserId, + validTill: dayjs().add(90, 'days').toDate(), // 90 days from now + }).returning(); + + // Associate coupon with user + await db.insert(couponApplicableUsers).values({ + couponId: coupon.id, + userId: user.id, + }); + + return { + success: true, + coupon: { + id: coupon.id, + couponCode: coupon.couponCode, + userId: user.id, + userMobile: user.mobile, + discountPercent: 20, + minOrder: 1000, + maxValue: 500, + maxLimitForUser: 1, + }, + }; + }), +}); diff --git a/apps/backend/src/trpc/admin-apis/order.ts b/apps/backend/src/trpc/admin-apis/order.ts new file mode 100644 index 0000000..a41ed23 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/order.ts @@ -0,0 +1,961 @@ +import { router, protectedProcedure } from "../trpc-index"; +import { z } from "zod"; +import { db } from "../../db/db_index"; +import { + orders, + orderItems, + orderStatus, + users, + addresses, + refunds, + coupons, + couponUsage, +} from "../../db/schema"; +import { eq, and, gte, lt, desc, SQL, inArray } from "drizzle-orm"; +import dayjs from "dayjs"; +import utc from "dayjs/plugin/utc"; +import { ApiError } from "../../lib/api-error"; +import { + sendOrderPackagedNotification, + sendOrderDeliveredNotification, +} from "../../lib/notif-job"; + +const updateOrderNotesSchema = z.object({ + orderId: z.number(), + adminNotes: z.string(), +}); + +const getFullOrderSchema = z.object({ + orderId: z.number(), +}); + +const getOrderDetailsSchema = z.object({ + orderId: z.number(), +}); + +const updatePackagedSchema = z.object({ + orderId: z.string(), + isPackaged: z.boolean(), +}); + +const updateDeliveredSchema = z.object({ + orderId: z.string(), + isDelivered: z.boolean(), +}); + +const updateOrderItemPackagingSchema = z.object({ + orderItemId: z.number(), + isPackaged: z.boolean().optional(), + isPackageVerified: z.boolean().optional(), +}); + +const getSlotOrdersSchema = z.object({ + slotId: z.string(), +}); + +const getTodaysOrdersSchema = z.object({ + slotId: z.string().optional(), +}); + +const getAllOrdersSchema = z.object({ + cursor: z.number().optional(), + limit: z.number().default(20), + slotId: z.number().optional().nullable(), + packagedFilter: z + .enum(["all", "packaged", "not_packaged"]) + .optional() + .default("all"), + deliveredFilter: z + .enum(["all", "delivered", "not_delivered"]) + .optional() + .default("all"), + cancellationFilter: z + .enum(["all", "cancelled", "not_cancelled"]) + .optional() + .default("all"), + flashDeliveryFilter: z + .enum(["all", "flash", "regular"]) + .optional() + .default("all"), +}); + +export const orderRouter = router({ + updateNotes: protectedProcedure + .input(updateOrderNotesSchema) + .mutation(async ({ input }) => { + const { orderId, adminNotes } = input; + + const result = await db + .update(orders) + .set({ + adminNotes: adminNotes || null, + }) + .where(eq(orders.id, orderId)) + .returning(); + + if (result.length === 0) { + throw new Error("Order not found"); + } + + return result[0]; + }), + + getFullOrder: protectedProcedure + .input(getFullOrderSchema) + .query(async ({ input }) => { + const { orderId } = input; + + const orderData = await db.query.orders.findFirst({ + where: eq(orders.id, orderId), + with: { + user: true, + address: true, + slot: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + payment: true, + paymentInfo: true, + }, + }); + + if (!orderData) { + throw new Error("Order not found"); + } + + // Get order status separately + const statusRecord = await db.query.orderStatus.findFirst({ + where: eq(orderStatus.orderId, orderId), + }); + + let status: "pending" | "delivered" | "cancelled" = "pending"; + if (statusRecord?.isCancelled) { + status = "cancelled"; + } else if (statusRecord?.isDelivered) { + status = "delivered"; + } + + // Get refund details if order is cancelled + let refund = null; + if (status === "cancelled") { + refund = await db.query.refunds.findFirst({ + where: eq(refunds.orderId, orderId), + }); + } + + return { + id: orderData.id, + readableId: orderData.readableId, + customerName: `${orderData.user.name}`, + customerEmail: orderData.user.email, + customerMobile: orderData.user.mobile, + address: { + line1: orderData.address.addressLine1, + line2: orderData.address.addressLine2, + city: orderData.address.city, + state: orderData.address.state, + pincode: orderData.address.pincode, + phone: orderData.address.phone, + }, + slotInfo: orderData.slot + ? { + time: orderData.slot.deliveryTime.toISOString(), + sequence: orderData.slot.deliverySequence, + } + : null, + isCod: orderData.isCod, + isOnlinePayment: orderData.isOnlinePayment, + totalAmount: orderData.totalAmount, + adminNotes: orderData.adminNotes, + userNotes: orderData.userNotes, + createdAt: orderData.createdAt, + status, + isPackaged: + orderData.orderItems.every((item) => item.is_packaged) || false, + isDelivered: statusRecord?.isDelivered || false, + items: orderData.orderItems.map((item) => ({ + id: item.id, + name: item.product.name, + quantity: item.quantity, + price: item.price, + unit: item.product.unit?.shortNotation, + amount: + parseFloat(item.price.toString()) * + parseFloat(item.quantity || "0"), + })), + payment: orderData.payment + ? { + status: orderData.payment.status, + gateway: orderData.payment.gateway, + merchantOrderId: orderData.payment.merchantOrderId, + } + : null, + paymentInfo: orderData.paymentInfo + ? { + status: orderData.paymentInfo.status, + gateway: orderData.paymentInfo.gateway, + merchantOrderId: orderData.paymentInfo.merchantOrderId, + } + : null, + // Cancellation details (only present for cancelled orders) + cancelReason: statusRecord?.cancelReason || null, + cancellationReviewed: statusRecord?.cancellationReviewed || false, + isRefundDone: refund?.refundStatus === "processed" || false, + }; + }), + + getOrderDetails: protectedProcedure + .input(getOrderDetailsSchema) + .query(async ({ input }) => { + const { orderId } = input; + + // Single optimized query with all relations + const orderData = await db.query.orders.findFirst({ + where: eq(orders.id, orderId), + with: { + user: true, + address: true, + slot: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + payment: true, + paymentInfo: true, + orderStatus: true, // Include in main query + refunds: true, // Include in main query + }, + }); + + if (!orderData) { + throw new Error("Order not found"); + } + + // Get coupon usage for this specific order using new orderId field + const couponUsageData = await db.query.couponUsage.findMany({ + where: eq(couponUsage.orderId, orderData.id), // Use new orderId field + with: { + coupon: true, + }, + }); + + let couponData = null; + if (couponUsageData.length > 0) { + // Calculate total discount from multiple coupons + let totalDiscountAmount = 0; + const orderTotal = parseFloat(orderData.totalAmount.toString()); + + for (const usage of couponUsageData) { + let discountAmount = 0; + + if (usage.coupon.discountPercent) { + discountAmount = + (orderTotal * + parseFloat(usage.coupon.discountPercent.toString())) / + 100; + } else if (usage.coupon.flatDiscount) { + discountAmount = parseFloat(usage.coupon.flatDiscount.toString()); + } + + // Apply max value limit if set + if ( + usage.coupon.maxValue && + discountAmount > parseFloat(usage.coupon.maxValue.toString()) + ) { + discountAmount = parseFloat(usage.coupon.maxValue.toString()); + } + + totalDiscountAmount += discountAmount; + } + + couponData = { + couponCode: couponUsageData + .map((u) => u.coupon.couponCode) + .join(", "), + couponDescription: `${couponUsageData.length} coupons applied`, + discountAmount: totalDiscountAmount, + }; + } + + // Status determination from included relation + const statusRecord = orderData.orderStatus?.[0]; + let status: "pending" | "delivered" | "cancelled" = "pending"; + if (statusRecord?.isCancelled) { + status = "cancelled"; + } else if (statusRecord?.isDelivered) { + status = "delivered"; + } + + // Always include refund data (will be null/undefined if not cancelled) + const refund = orderData.refunds?.[0]; + + return { + id: orderData.id, + readableId: orderData.readableId, + customerName: `${orderData.user.name}`, + customerEmail: orderData.user.email, + customerMobile: orderData.user.mobile, + address: { + line1: orderData.address.addressLine1, + line2: orderData.address.addressLine2, + city: orderData.address.city, + state: orderData.address.state, + pincode: orderData.address.pincode, + phone: orderData.address.phone, + }, + slotInfo: orderData.slot + ? { + time: orderData.slot.deliveryTime.toISOString(), + sequence: orderData.slot.deliverySequence, + } + : null, + isCod: orderData.isCod, + isOnlinePayment: orderData.isOnlinePayment, + totalAmount: orderData.totalAmount, + adminNotes: orderData.adminNotes, + userNotes: orderData.userNotes, + createdAt: orderData.createdAt, + status, + isPackaged: statusRecord?.isPackaged || false, + isDelivered: statusRecord?.isDelivered || false, + items: orderData.orderItems.map((item) => ({ + id: item.id, + name: item.product.name, + quantity: item.quantity, + price: item.price, + unit: item.product.unit?.shortNotation, + amount: + parseFloat(item.price.toString()) * + parseFloat(item.quantity || "0"), + isPackaged: item.is_packaged, + isPackageVerified: item.is_package_verified, + })), + payment: orderData.payment + ? { + status: orderData.payment.status, + gateway: orderData.payment.gateway, + merchantOrderId: orderData.payment.merchantOrderId, + } + : null, + paymentInfo: orderData.paymentInfo + ? { + status: orderData.paymentInfo.status, + gateway: orderData.paymentInfo.gateway, + merchantOrderId: orderData.paymentInfo.merchantOrderId, + } + : null, + // Cancellation details (always included, null if not cancelled) + cancelReason: statusRecord?.cancelReason || null, + cancellationReviewed: statusRecord?.cancellationReviewed || false, + isRefundDone: refund?.refundStatus === "processed" || false, + refundStatus: refund?.refundStatus as RefundStatus, + refundAmount: refund?.refundAmount + ? parseFloat(refund.refundAmount.toString()) + : null, + // Coupon information + couponData: couponData, + couponCode: couponData?.couponCode || null, + couponDescription: couponData?.couponDescription || null, + discountAmount: couponData?.discountAmount || null, + orderStatus: statusRecord, + refundRecord: refund, + isFlashDelivery: orderData.isFlashDelivery, + }; + }), + + updatePackaged: protectedProcedure + .input(updatePackagedSchema) + .mutation(async ({ input }) => { + const { orderId, isPackaged } = input; + + // Update all order items to the specified packaged state + await db + .update(orderItems) + .set({ is_packaged: isPackaged }) + .where(eq(orderItems.orderId, parseInt(orderId))); + + // Also update the order status table for backward compatibility + if (!isPackaged) { + await db + .update(orderStatus) + .set({ isPackaged, isDelivered: false }) + .where(eq(orderStatus.orderId, parseInt(orderId))); + } else { + await db + .update(orderStatus) + .set({ isPackaged }) + .where(eq(orderStatus.orderId, parseInt(orderId))); + } + + const order = await db.query.orders.findFirst({ + where: eq(orders.id, parseInt(orderId)), + }); + if (order) await sendOrderPackagedNotification(order.userId, orderId); + + return { success: true }; + }), + + updateDelivered: protectedProcedure + .input(updateDeliveredSchema) + .mutation(async ({ input }) => { + const { orderId, isDelivered } = input; + + await db + .update(orderStatus) + .set({ isDelivered }) + .where(eq(orderStatus.orderId, parseInt(orderId))); + + const order = await db.query.orders.findFirst({ + where: eq(orders.id, parseInt(orderId)), + }); + if (order) await sendOrderDeliveredNotification(order.userId, orderId); + + return { success: true }; + }), + + updateOrderItemPackaging: protectedProcedure + .input(updateOrderItemPackagingSchema) + .mutation(async ({ input }) => { + const { orderItemId, isPackaged, isPackageVerified } = input; + console.log({ orderItemId, isPackaged, isPackageVerified }); + + // Validate that orderItem exists + const orderItem = await db.query.orderItems.findFirst({ + where: eq(orderItems.id, orderItemId), + }); + + if (!orderItem) { + throw new ApiError("Order item not found", 404); + } + + // Build update object with only provided fields + const updateData: any = {}; + if (isPackaged !== undefined) { + updateData.is_packaged = isPackaged; + } + if (isPackageVerified !== undefined) { + updateData.is_package_verified = isPackageVerified; + } + + // Update the order item + await db + .update(orderItems) + .set(updateData) + .where(eq(orderItems.id, orderItemId)); + + return { success: true }; + }), + + getSlotOrders: protectedProcedure + .input(getSlotOrdersSchema) + .query(async ({ input }) => { + const { slotId } = input; + + const slotOrders = await db.query.orders.findMany({ + where: eq(orders.slotId, parseInt(slotId)), + with: { + user: true, + address: true, + slot: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + orderStatus: true, + }, + }); + + const filteredOrders = slotOrders.filter((order) => { + const statusRecord = order.orderStatus[0]; + return ( + order.isCod || + (statusRecord && statusRecord.paymentStatus === "success") + ); + }); + + const formattedOrders = filteredOrders.map((order) => { + const statusRecord = order.orderStatus[0]; // assuming one status per order + let status: "pending" | "delivered" | "cancelled" = "pending"; + if (statusRecord?.isCancelled) { + status = "cancelled"; + } else if (statusRecord?.isDelivered) { + status = "delivered"; + } + + const items = order.orderItems.map((item) => ({ + id: item.id, + name: item.product.name, + quantity: parseFloat(item.quantity), + price: parseFloat(item.price.toString()), + amount: parseFloat(item.quantity) * parseFloat(item.price.toString()), + unit: item.product.unit?.shortNotation || "", + isPackaged: item.is_packaged, + isPackageVerified: item.is_package_verified, + })); + + return { + id: order.id, + readableId: order.readableId, + customerName: order.user.name, + address: `${order.address.addressLine1}${ + order.address.addressLine2 ? `, ${order.address.addressLine2}` : "" + }, ${order.address.city}, ${order.address.state} - ${ + order.address.pincode + }, Phone: ${order.address.phone}`, + addressId: order.addressId, + latitude: order.address.latitude, + longitude: order.address.longitude, + totalAmount: parseFloat(order.totalAmount), + items, + deliveryTime: order.slot?.deliveryTime.toISOString() || null, + status, + isPackaged: + order.orderItems.every((item) => item.is_packaged) || false, + isDelivered: statusRecord?.isDelivered || false, + isCod: order.isCod, + paymentMode: order.isCod ? "COD" : "Online", + paymentStatus: statusRecord?.paymentStatus || "pending", + slotId: order.slotId, + adminNotes: order.adminNotes, + userNotes: order.userNotes, + }; + }); + + return { success: true, data: formattedOrders }; + }), + + getTodaysOrders: protectedProcedure + .input(getTodaysOrdersSchema) + .query(async ({ input }) => { + const { slotId } = input; + const start = dayjs().startOf("day").toDate(); + const end = dayjs().endOf("day").toDate(); + + let whereCondition = and( + gte(orders.createdAt, start), + lt(orders.createdAt, end) + ); + + if (slotId) { + whereCondition = and( + whereCondition, + eq(orders.slotId, parseInt(slotId)) + ); + } + + const todaysOrders = await db.query.orders.findMany({ + where: whereCondition, + with: { + user: true, + address: true, + slot: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + orderStatus: true, + }, + }); + + const filteredOrders = todaysOrders.filter((order) => { + const statusRecord = order.orderStatus[0]; + return ( + order.isCod || + (statusRecord && statusRecord.paymentStatus === "success") + ); + }); + + const formattedOrders = filteredOrders.map((order) => { + const statusRecord = order.orderStatus[0]; // assuming one status per order + let status: "pending" | "delivered" | "cancelled" = "pending"; + if (statusRecord?.isCancelled) { + status = "cancelled"; + } else if (statusRecord?.isDelivered) { + status = "delivered"; + } + + const items = order.orderItems.map((item) => ({ + name: item.product.name, + quantity: parseFloat(item.quantity), + price: parseFloat(item.price.toString()), + amount: parseFloat(item.quantity) * parseFloat(item.price.toString()), + unit: item.product.unit?.shortNotation || "", + })); + + return { + orderId: order.id.toString(), + readableId: order.readableId, + customerName: order.user.name, + address: `${order.address.addressLine1}${ + order.address.addressLine2 ? `, ${order.address.addressLine2}` : "" + }, ${order.address.city}, ${order.address.state} - ${ + order.address.pincode + }`, + totalAmount: parseFloat(order.totalAmount), + items, + deliveryTime: order.slot?.deliveryTime.toISOString() || null, + status, + isPackaged: + order.orderItems.every((item) => item.is_packaged) || false, + isDelivered: statusRecord?.isDelivered || false, + isCod: order.isCod, + paymentMode: order.isCod ? "COD" : "Online", + paymentStatus: statusRecord?.paymentStatus || "pending", + slotId: order.slotId, + adminNotes: order.adminNotes, + userNotes: order.userNotes, + }; + }); + + return { success: true, data: formattedOrders }; + }), + + updateAddressCoords: protectedProcedure + .input( + z.object({ + addressId: z.number(), + latitude: z.number(), + longitude: z.number(), + }) + ) + .mutation(async ({ input }) => { + const { addressId, latitude, longitude } = input; + + const result = await db + .update(addresses) + .set({ + latitude, + longitude, + }) + .where(eq(addresses.id, addressId)) + .returning(); + + if (result.length === 0) { + throw new ApiError("Address not found", 404); + } + + return { success: true }; + }), + + getAll: protectedProcedure + .input(getAllOrdersSchema) + .query(async ({ input }) => { + try { + const { + cursor, + limit, + slotId, + packagedFilter, + deliveredFilter, + cancellationFilter, + flashDeliveryFilter, + } = input; + + let whereCondition: SQL | undefined = eq(orders.id, orders.id); // always true + if (cursor) { + whereCondition = and(whereCondition, lt(orders.id, cursor)); + } + if (slotId) { + whereCondition = and(whereCondition, eq(orders.slotId, slotId)); + } + if (packagedFilter === "packaged") { + whereCondition = and( + whereCondition, + eq(orderStatus.isPackaged, true) + ); + } else if (packagedFilter === "not_packaged") { + whereCondition = and( + whereCondition, + eq(orderStatus.isPackaged, false) + ); + } + if (deliveredFilter === "delivered") { + whereCondition = and( + whereCondition, + eq(orderStatus.isDelivered, true) + ); + } else if (deliveredFilter === "not_delivered") { + whereCondition = and( + whereCondition, + eq(orderStatus.isDelivered, false) + ); + } + if (cancellationFilter === "cancelled") { + whereCondition = and( + whereCondition, + eq(orderStatus.isCancelled, true) + ); + } else if (cancellationFilter === "not_cancelled") { + whereCondition = and( + whereCondition, + eq(orderStatus.isCancelled, false) + ); + } + if (flashDeliveryFilter === "flash") { + whereCondition = and( + whereCondition, + eq(orders.isFlashDelivery, true) + ); + } else if (flashDeliveryFilter === "regular") { + whereCondition = and( + whereCondition, + eq(orders.isFlashDelivery, false) + ); + } + + const allOrders = await db.query.orders.findMany({ + where: whereCondition, + orderBy: desc(orders.createdAt), + limit: limit + 1, // fetch one extra to check if there's more + with: { + user: true, + address: true, + slot: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + orderStatus: true, + }, + }); + + const hasMore = allOrders.length > limit; + const ordersToReturn = hasMore ? allOrders.slice(0, limit) : allOrders; + + const filteredOrders = ordersToReturn.filter((order) => { + const statusRecord = order.orderStatus[0]; + return ( + order.isCod || + (statusRecord && statusRecord.paymentStatus === "success") + ); + }); + + const formattedOrders = filteredOrders.map((order) => { + const statusRecord = order.orderStatus[0]; + let status: "pending" | "delivered" | "cancelled" = "pending"; + if (statusRecord?.isCancelled) { + status = "cancelled"; + } else if (statusRecord?.isDelivered) { + status = "delivered"; + } + + const items = order.orderItems + .map((item) => ({ + id: item.id, + name: item.product.name, + quantity: parseFloat(item.quantity), + price: parseFloat(item.price.toString()), + amount: + parseFloat(item.quantity) * parseFloat(item.price.toString()), + unit: item.product.unit?.shortNotation || "", + isPackaged: item.is_packaged, + isPackageVerified: item.is_package_verified, + })) + .sort((first, second) => first.id - second.id); + dayjs.extend(utc); + return { + id: order.id, + orderId: order.id.toString(), + readableId: order.readableId, + customerName: order.user.name, + address: `${order.address.addressLine1}${ + order.address.addressLine2 + ? `, ${order.address.addressLine2}` + : "" + }, ${order.address.city}, ${order.address.state} - ${ + order.address.pincode + }, Phone: ${order.address.phone}`, + addressId: order.addressId, + latitude: order.address.latitude, + longitude: order.address.longitude, + totalAmount: parseFloat(order.totalAmount), + deliveryCharge: parseFloat(order.deliveryCharge || "0"), + items, + createdAt: order.createdAt, + // deliveryTime: order.slot ? dayjs.utc(order.slot.deliveryTime).format('ddd, MMM D • h:mm A') : 'Not scheduled', + deliveryTime: order.slot?.deliveryTime.toISOString() || null, + status, + isPackaged: + order.orderItems.every((item) => item.is_packaged) || false, + isDelivered: statusRecord?.isDelivered || false, + isCod: order.isCod, + isFlashDelivery: order.isFlashDelivery, + userNotes: order.userNotes, + adminNotes: order.adminNotes, + }; + }); + + return { + orders: formattedOrders, + nextCursor: hasMore + ? ordersToReturn[ordersToReturn.length - 1].id + : undefined, + }; + } catch (e) { + console.log({ e }); + } + }), + + rebalanceSlots: protectedProcedure + .input(z.object({ slotIds: z.array(z.number()).min(1).max(50) })) + .mutation(async ({ input }) => { + const slotIds = input.slotIds; + + const ordersList = await db.query.orders.findMany({ + where: inArray(orders.slotId, slotIds), + with: { + orderItems: { + with: { + product: true + } + }, + couponUsages: { + with: { + coupon: true + } + }, + } + }); + + const processedOrdersData = ordersList.map((order) => { + + let newTotal = order.orderItems.reduce((acc,item) => { + const latestPrice = +item.product.price; + const amount = (latestPrice * Number(item.quantity)); + return acc+amount; + },0) + + order.orderItems.forEach(item => { + item.price = item.product.price; + item.discountedPrice = item.product.price + }) + + const coupon = order.couponUsages[0]?.coupon; + + let discount = 0; + if(coupon && !coupon.isInvalidated && (!coupon.validTill || new Date(coupon.validTill) > new Date())) { + const proportion = Number(order.orderGroupProportion || 1); + if(coupon.discountPercent) { + const maxDiscount = Number(coupon.maxValue || Infinity) * proportion; + discount = Math.min((newTotal * parseFloat(coupon.discountPercent)) / 100, maxDiscount); + } + else { + discount = Number(coupon.flatDiscount) * proportion; + } + } + newTotal -= discount + + const { couponUsages, orderItems: orderItemsRaw, ...rest} = order; + const updatedOrderItems = orderItemsRaw.map(item => { + const { product, ...rawOrderItem } = item; + return rawOrderItem; + }) + return {order: rest, updatedOrderItems, newTotal } + }) + + const updatedOrderIds: number[] = []; + await db.transaction(async (tx) => { + for (const { order, updatedOrderItems, newTotal } of processedOrdersData) { + await tx.update(orders).set({ totalAmount: newTotal.toString() }).where(eq(orders.id, order.id)); + updatedOrderIds.push(order.id); + + for (const item of updatedOrderItems) { + await tx.update(orderItems).set({ + price: item.price, + discountedPrice: item.discountedPrice + }).where(eq(orderItems.id, item.id)); + } + } + }); + + return { success: true, updatedOrders: updatedOrderIds, message: `Rebalanced ${updatedOrderIds.length} orders.` }; + }), + + cancelOrder: protectedProcedure + .input(z.object({ + orderId: z.number(), + reason: z.string().min(1, "Cancellation reason is required"), + })) + .mutation(async ({ input }) => { + const { orderId, reason } = input; + + const order = await db.query.orders.findFirst({ + where: eq(orders.id, orderId), + with: { + orderStatus: true, + }, + }); + + if (!order) { + throw new ApiError("Order not found", 404); + } + + const status = order.orderStatus[0]; + if (!status) { + throw new ApiError("Order status not found", 400); + } + + if (status.isCancelled) { + throw new ApiError("Order is already cancelled", 400); + } + + if (status.isDelivered) { + throw new ApiError("Cannot cancel delivered order", 400); + } + + const result = await db.transaction(async (tx) => { + await tx + .update(orderStatus) + .set({ + isCancelled: true, + isCancelledByAdmin: true, + cancelReason: reason, + cancellationAdminNotes: reason, + cancellationReviewed: true, + cancellationReviewedAt: new Date(), + }) + .where(eq(orderStatus.id, status.id)); + + const refundStatus = order.isCod ? "na" : "pending"; + + await tx.insert(refunds).values({ + orderId: order.id, + refundStatus, + }); + + return { orderId: order.id, userId: order.userId }; + }); + + return { success: true, message: "Order cancelled successfully" }; + }), +}); + +// {"id": "order_Rhh00qJNdjUp8o", "notes": {"retry": "true", "customerOrderId": "14"}, "amount": 21000, "entity": "order", "status": "created", "receipt": "order_14_retry", "attempts": 0, "currency": "INR", "offer_id": null, "signature": "6df20655021f1d6841340f2a2ef2ef9378cb3d43495ab09e85f08aea1a851583", "amount_due": 21000, "created_at": 1763575791, "payment_id": "pay_Rhh15cLL28YM7j", "amount_paid": 0} + +type RefundStatus = "success" | "pending" | "failed" | "none" | "na"; diff --git a/apps/backend/src/trpc/admin-apis/payments.ts b/apps/backend/src/trpc/admin-apis/payments.ts new file mode 100644 index 0000000..23ca16e --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/payments.ts @@ -0,0 +1,146 @@ +import { router, protectedProcedure } from "../trpc-index"; +import { z } from "zod"; +import { db } from "../../db/db_index"; +import { + orders, + orderStatus, + payments, + refunds, +} from "../../db/schema"; +import { and, eq } from "drizzle-orm"; +import { ApiError } from "../../lib/api-error"; +import { RazorpayPaymentService } from "../../lib/payments-utils"; + +const initiateRefundSchema = z + .object({ + orderId: z.number(), + refundPercent: z.number().min(0).max(100).optional(), + refundAmount: z.number().min(0).optional(), + }) + .refine( + (data) => { + const hasPercent = data.refundPercent !== undefined; + const hasAmount = data.refundAmount !== undefined; + return (hasPercent && !hasAmount) || (!hasPercent && hasAmount); + }, + { + message: + "Provide either refundPercent or refundAmount, not both or neither", + } + ); + +export const adminPaymentsRouter = router({ + initiateRefund: protectedProcedure + .input(initiateRefundSchema) + .mutation(async ({ input }) => { + try { + const { orderId, refundPercent, refundAmount } = input; + + // Validate order exists + const order = await db.query.orders.findFirst({ + where: eq(orders.id, orderId), + }); + + if (!order) { + throw new ApiError("Order not found", 404); + } + + // Check if order is paid + const orderStatusRecord = await db.query.orderStatus.findFirst({ + where: eq(orderStatus.orderId, orderId), + }); + + if(order.isCod) { + throw new ApiError("Order is a Cash On Delivery. Not eligible for refund") + } + + if ( + !orderStatusRecord || + (orderStatusRecord.paymentStatus !== "success" && + !(order.isCod && orderStatusRecord.isDelivered)) + ) { + throw new ApiError("Order payment not verified or not eligible for refund", 400); + } + + // Calculate refund amount + let calculatedRefundAmount: number; + if (refundPercent !== undefined) { + calculatedRefundAmount = + (parseFloat(order.totalAmount) * refundPercent) / 100; + } else if (refundAmount !== undefined) { + calculatedRefundAmount = refundAmount; + if (calculatedRefundAmount > parseFloat(order.totalAmount)) { + throw new ApiError("Refund amount cannot exceed order total", 400); + } + } else { + throw new ApiError("Invalid refund parameters", 400); + } + + let razorpayRefund = null; + let merchantRefundId = null; + + // Get payment record for online payments + const payment = await db.query.payments.findFirst({ + where: and( + eq(payments.orderId, orderId), + eq(payments.status, "success") + ), + }); + + if (!payment || payment.status !== "success") { + throw new ApiError("Payment not found or not successful", 404); + } + + const payload = payment.payload as any; + // Initiate Razorpay refund + razorpayRefund = await RazorpayPaymentService.initiateRefund( + payload.payment_id, + Math.round(calculatedRefundAmount * 100) // Convert to paisa + ); + merchantRefundId = razorpayRefund.id; + + + + // Check if refund already exists for this order + const existingRefund = await db.query.refunds.findFirst({ + where: eq(refunds.orderId, orderId), + }); + + const refundStatus = "initiated"; + + if (existingRefund) { + // Update existing refund + await db + .update(refunds) + .set({ + refundAmount: calculatedRefundAmount.toString(), + refundStatus, + merchantRefundId, + refundProcessedAt: order.isCod ? new Date() : null, + }) + .where(eq(refunds.id, existingRefund.id)); + } else { + // Insert new refund + await db + .insert(refunds) + .values({ + orderId, + refundAmount: calculatedRefundAmount.toString(), + refundStatus, + merchantRefundId, + }); + } + + return { + refundId: merchantRefundId || `cod_${orderId}`, + amount: calculatedRefundAmount, + status: refundStatus, + message: order.isCod ? "COD refund processed successfully" : "Refund initiated successfully", + }; + } + catch(e) { + console.log(e); + throw new ApiError("Failed to initiate refund") + } + }), +}); diff --git a/apps/backend/src/trpc/admin-apis/product.ts b/apps/backend/src/trpc/admin-apis/product.ts new file mode 100644 index 0000000..8c3d0a6 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/product.ts @@ -0,0 +1,512 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { productInfo, units, specialDeals, productSlots, productTags, productReviews, users, productGroupInfo, productGroupMembership } from '../../db/schema'; +import { eq, and, inArray, desc, sql } from 'drizzle-orm'; +import { ApiError } from '../../lib/api-error'; +import { imageUploadS3, generateSignedUrlsFromS3Urls, getOriginalUrlFromSignedUrl, claimUploadUrl } from '../../lib/s3-client'; +import { deleteS3Image } from '../../lib/delete-image'; +import type { SpecialDeal } from '../../db/types'; + +type CreateDeal = { + quantity: number; + price: number; + validTill: string; +}; + +export const productRouter = router({ + getProducts: protectedProcedure + .query(async ({ ctx }) => { + const products = await db.query.productInfo.findMany({ + orderBy: productInfo.name, + with: { + unit: true, + store: true, + }, + }); + + // Generate signed URLs for all product images + const productsWithSignedUrls = await Promise.all( + products.map(async (product) => ({ + ...product, + images: await generateSignedUrlsFromS3Urls((product.images as string[]) || []), + })) + ); + + return { + products: productsWithSignedUrls, + count: productsWithSignedUrls.length, + }; + }), + + getProductById: protectedProcedure + .input(z.object({ + id: z.number(), + })) + .query(async ({ input, ctx }) => { + const { id } = input; + + const product = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, id), + with: { + unit: true, + }, + }); + + if (!product) { + throw new ApiError("Product not found", 404); + } + + // Fetch special deals for this product + const deals = await db.query.specialDeals.findMany({ + where: eq(specialDeals.productId, id), + orderBy: specialDeals.quantity, + }); + + // Fetch associated tags for this product + const productTagsData = await db.query.productTags.findMany({ + where: eq(productTags.productId, id), + with: { + tag: true, + }, + }); + + // Generate signed URLs for product images + const productWithSignedUrls = { + ...product, + images: await generateSignedUrlsFromS3Urls((product.images as string[]) || []), + deals, + tags: productTagsData.map(pt => pt.tag), + }; + + return { + product: productWithSignedUrls, + }; + }), + + deleteProduct: protectedProcedure + .input(z.object({ + id: z.number(), + })) + .mutation(async ({ input, ctx }) => { + const { id } = input; + + const [deletedProduct] = await db + .delete(productInfo) + .where(eq(productInfo.id, id)) + .returning(); + + if (!deletedProduct) { + throw new ApiError("Product not found", 404); + } + + return { + message: "Product deleted successfully", + }; + }), + + toggleOutOfStock: protectedProcedure + .input(z.object({ + id: z.number(), + })) + .mutation(async ({ input, ctx }) => { + const { id } = input; + + const product = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, id), + }); + + if (!product) { + throw new ApiError("Product not found", 404); + } + + const [updatedProduct] = await db + .update(productInfo) + .set({ + isOutOfStock: !product.isOutOfStock, + }) + .where(eq(productInfo.id, id)) + .returning(); + + return { + product: updatedProduct, + message: `Product marked as ${updatedProduct.isOutOfStock ? 'out of stock' : 'in stock'}`, + }; + }), + + updateSlotProducts: protectedProcedure + .input(z.object({ + slotId: z.string(), + productIds: z.array(z.string()), + })) + .mutation(async ({ input, ctx }) => { + const { slotId, productIds } = input; + + if (!Array.isArray(productIds)) { + throw new ApiError("productIds must be an array", 400); + } + + // Get current associations + const currentAssociations = await db.query.productSlots.findMany({ + where: eq(productSlots.slotId, parseInt(slotId)), + columns: { + productId: true, + }, + }); + + const currentProductIds = currentAssociations.map(assoc => assoc.productId); + const newProductIds = productIds.map((id: string) => parseInt(id)); + + // Find products to add and remove + const productsToAdd = newProductIds.filter(id => !currentProductIds.includes(id)); + const productsToRemove = currentProductIds.filter(id => !newProductIds.includes(id)); + + // Remove associations for products that are no longer selected + if (productsToRemove.length > 0) { + await db.delete(productSlots).where( + and( + eq(productSlots.slotId, parseInt(slotId)), + inArray(productSlots.productId, productsToRemove) + ) + ); + } + + // Add associations for newly selected products + if (productsToAdd.length > 0) { + const newAssociations = productsToAdd.map(productId => ({ + productId, + slotId: parseInt(slotId), + })); + + await db.insert(productSlots).values(newAssociations); + } + + return { + message: "Slot products updated successfully", + added: productsToAdd.length, + removed: productsToRemove.length, + }; + }), + + getSlotProductIds: protectedProcedure + .input(z.object({ + slotId: z.string(), + })) + .query(async ({ input, ctx }) => { + const { slotId } = input; + + const associations = await db.query.productSlots.findMany({ + where: eq(productSlots.slotId, parseInt(slotId)), + columns: { + productId: true, + }, + }); + + const productIds = associations.map(assoc => assoc.productId); + + return { + productIds, + }; + }), + + getSlotsProductIds: protectedProcedure + .input(z.object({ + slotIds: z.array(z.number()), + })) + .query(async ({ input, ctx }) => { + const { slotIds } = input; + + if (!Array.isArray(slotIds)) { + throw new ApiError("slotIds must be an array", 400); + } + + if (slotIds.length === 0) { + return {}; + } + + // Fetch all associations for the requested slots + const associations = await db.query.productSlots.findMany({ + where: inArray(productSlots.slotId, slotIds), + columns: { + slotId: true, + productId: true, + }, + }); + + // Group by slotId + const result = associations.reduce((acc, assoc) => { + if (!acc[assoc.slotId]) { + acc[assoc.slotId] = []; + } + acc[assoc.slotId].push(assoc.productId); + return acc; + }, {} as Record); + + // Ensure all requested slots have entries (even if empty) + slotIds.forEach(slotId => { + if (!result[slotId]) { + result[slotId] = []; + } + }); + + return result; + }), + + getProductReviews: protectedProcedure + .input(z.object({ + productId: z.number().int().positive(), + limit: z.number().int().min(1).max(50).optional().default(10), + offset: z.number().int().min(0).optional().default(0), + })) + .query(async ({ input }) => { + const { productId, limit, offset } = input; + + const reviews = await db + .select({ + id: productReviews.id, + reviewBody: productReviews.reviewBody, + ratings: productReviews.ratings, + imageUrls: productReviews.imageUrls, + reviewTime: productReviews.reviewTime, + adminResponse: productReviews.adminResponse, + adminResponseImages: productReviews.adminResponseImages, + userName: users.name, + }) + .from(productReviews) + .innerJoin(users, eq(productReviews.userId, users.id)) + .where(eq(productReviews.productId, productId)) + .orderBy(desc(productReviews.reviewTime)) + .limit(limit) + .offset(offset); + + // Generate signed URLs for images + const reviewsWithSignedUrls = await Promise.all( + reviews.map(async (review) => ({ + ...review, + signedImageUrls: await generateSignedUrlsFromS3Urls((review.imageUrls as string[]) || []), + signedAdminImageUrls: await generateSignedUrlsFromS3Urls((review.adminResponseImages as string[]) || []), + })) + ); + + // Check if more reviews exist + const totalCountResult = await db + .select({ count: sql`count(*)` }) + .from(productReviews) + .where(eq(productReviews.productId, productId)); + + const totalCount = Number(totalCountResult[0].count); + const hasMore = offset + limit < totalCount; + + return { reviews: reviewsWithSignedUrls, hasMore }; + }), + + respondToReview: protectedProcedure + .input(z.object({ + reviewId: z.number().int().positive(), + adminResponse: z.string().optional(), + adminResponseImages: z.array(z.string()).optional().default([]), + uploadUrls: z.array(z.string()).optional().default([]), + })) + .mutation(async ({ input }) => { + const { reviewId, adminResponse, adminResponseImages, uploadUrls } = input; + + const [updatedReview] = await db + .update(productReviews) + .set({ + adminResponse, + adminResponseImages, + }) + .where(eq(productReviews.id, reviewId)) + .returning(); + + if (!updatedReview) { + throw new ApiError('Review not found', 404); + } + + // Claim upload URLs + if (uploadUrls && uploadUrls.length > 0) { + // const { claimUploadUrl } = await import('../../lib/s3-client'); + await Promise.all(uploadUrls.map(url => claimUploadUrl(url))); + } + + return { success: true, review: updatedReview }; + }), + + getGroups: protectedProcedure + .query(async ({ ctx }) => { + const groups = await db.query.productGroupInfo.findMany({ + with: { + memberships: { + with: { + product: true, + }, + }, + }, + orderBy: desc(productGroupInfo.createdAt), + }); + + return { + groups: groups.map(group => ({ + ...group, + products: group.memberships.map(m => m.product), + productCount: group.memberships.length, + })), + }; + }), + + createGroup: protectedProcedure + .input(z.object({ + group_name: z.string().min(1), + description: z.string().optional(), + product_ids: z.array(z.number()).default([]), + })) + .mutation(async ({ input, ctx }) => { + const { group_name, description, product_ids } = input; + + const [newGroup] = await db + .insert(productGroupInfo) + .values({ + groupName: group_name, + description, + }) + .returning(); + + if (product_ids.length > 0) { + const memberships = product_ids.map(productId => ({ + productId, + groupId: newGroup.id, + })); + + await db.insert(productGroupMembership).values(memberships); + } + + return { + group: newGroup, + message: 'Group created successfully', + }; + }), + + updateGroup: protectedProcedure + .input(z.object({ + id: z.number(), + group_name: z.string().optional(), + description: z.string().optional(), + product_ids: z.array(z.number()).optional(), + })) + .mutation(async ({ input, ctx }) => { + const { id, group_name, description, product_ids } = input; + + const updateData: any = {}; + if (group_name !== undefined) updateData.groupName = group_name; + if (description !== undefined) updateData.description = description; + + const [updatedGroup] = await db + .update(productGroupInfo) + .set(updateData) + .where(eq(productGroupInfo.id, id)) + .returning(); + + if (!updatedGroup) { + throw new ApiError('Group not found', 404); + } + + if (product_ids !== undefined) { + // Delete existing memberships + await db.delete(productGroupMembership).where(eq(productGroupMembership.groupId, id)); + + // Insert new memberships + if (product_ids.length > 0) { + const memberships = product_ids.map(productId => ({ + productId, + groupId: id, + })); + + await db.insert(productGroupMembership).values(memberships); + } + } + + return { + group: updatedGroup, + message: 'Group updated successfully', + }; + }), + + deleteGroup: protectedProcedure + .input(z.object({ + id: z.number(), + })) + .mutation(async ({ input, ctx }) => { + const { id } = input; + + // Delete memberships first + await db.delete(productGroupMembership).where(eq(productGroupMembership.groupId, id)); + + // Delete group + const [deletedGroup] = await db + .delete(productGroupInfo) + .where(eq(productGroupInfo.id, id)) + .returning(); + + if (!deletedGroup) { + throw new ApiError('Group not found', 404); + } + + return { + message: 'Group deleted successfully', + }; + }), + + updateProductPrices: protectedProcedure + .input(z.object({ + updates: z.array(z.object({ + productId: z.number(), + price: z.number().optional(), + marketPrice: z.number().nullable().optional(), + flashPrice: z.number().nullable().optional(), + isFlashAvailable: z.boolean().optional(), + })), + })) + .mutation(async ({ input, ctx }) => { + const { updates } = input; + + if (updates.length === 0) { + throw new ApiError('No updates provided', 400); + } + + // Validate that all productIds exist + const productIds = updates.map(u => u.productId); + const existingProducts = await db.query.productInfo.findMany({ + where: inArray(productInfo.id, productIds), + columns: { id: true }, + }); + + const existingIds = new Set(existingProducts.map(p => p.id)); + const invalidIds = productIds.filter(id => !existingIds.has(id)); + + if (invalidIds.length > 0) { + throw new ApiError(`Invalid product IDs: ${invalidIds.join(', ')}`, 400); + } + + // Perform batch update + const updatePromises = updates.map(async (update) => { + const { productId, price, marketPrice, flashPrice, isFlashAvailable } = update; + const updateData: any = {}; + if (price !== undefined) updateData.price = price; + if (marketPrice !== undefined) updateData.marketPrice = marketPrice; + if (flashPrice !== undefined) updateData.flashPrice = flashPrice; + if (isFlashAvailable !== undefined) updateData.isFlashAvailable = isFlashAvailable; + + return db + .update(productInfo) + .set(updateData) + .where(eq(productInfo.id, productId)); + }); + + await Promise.all(updatePromises); + + return { + message: `Updated prices for ${updates.length} product(s)`, + updatedCount: updates.length, + }; + }), + }); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/slots.ts b/apps/backend/src/trpc/admin-apis/slots.ts new file mode 100644 index 0000000..671c4c9 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/slots.ts @@ -0,0 +1,548 @@ +import { router, protectedProcedure } from "../trpc-index"; +import { TRPCError } from "@trpc/server"; +import { z } from "zod"; +import { db } from "../../db/db_index"; +import { deliverySlotInfo, productSlots, productInfo, vendorSnippets } from "../../db/schema"; +import { eq, inArray, and, desc } from "drizzle-orm"; +import { ApiError } from "../../lib/api-error"; +import { appUrl } from "../../lib/env-exporter"; +import redisClient from "../../lib/redis-client"; +import { getSlotSequenceKey } from "../../lib/redisKeyGetters"; + +interface CachedDeliverySequence { + [userId: string]: number[]; +} + +const cachedSequenceSchema = z.record(z.string(), z.array(z.number())); + +const createSlotSchema = z.object({ + deliveryTime: z.string(), + freezeTime: z.string(), + isActive: z.boolean().optional(), + productIds: z.array(z.number()).optional(), + vendorSnippets: z.array(z.object({ + name: z.string().min(1), + productIds: z.array(z.number().int().positive()).min(1), + validTill: z.string().optional(), + })).optional(), +}); + +const getSlotByIdSchema = z.object({ + id: z.number(), +}); + +const updateSlotSchema = z.object({ + id: z.number(), + deliveryTime: z.string(), + freezeTime: z.string(), + isActive: z.boolean().optional(), + productIds: z.array(z.number()).optional(), + vendorSnippets: z.array(z.object({ + name: z.string().min(1), + productIds: z.array(z.number().int().positive()).min(1), + validTill: z.string().optional(), + })).optional(), +}); + +const deleteSlotSchema = z.object({ + id: z.number(), +}); + +const getDeliverySequenceSchema = z.object({ + id: z.string(), +}); + +const updateDeliverySequenceSchema = z.object({ + id: z.number(), + // deliverySequence: z.array(z.number()), + deliverySequence: z.any(), +}); + +export const slotsRouter = router({ + // Exact replica of GET /av/slots + getAll: protectedProcedure.query(async ({ ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const slots = await db.query.deliverySlotInfo + .findMany({ + where: eq(deliverySlotInfo.isActive, true), + orderBy: desc(deliverySlotInfo.deliveryTime), + with: { + productSlots: { + with: { + product: { + columns: { + id: true, + name: true, + images: true, + }, + }, + }, + }, + }, + }) + .then((slots) => + slots.map((slot) => ({ + ...slot, + deliverySequence: slot.deliverySequence as number[], + products: slot.productSlots.map((ps) => ps.product), + })) + ); + + return { + slots, + count: slots.length, + }; + }), + + // Exact replica of POST /av/products/slots/product-ids + getSlotsProductIds: protectedProcedure + .input(z.object({ slotIds: z.array(z.number()) })) + .query(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const { slotIds } = input; + + if (!Array.isArray(slotIds)) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "slotIds must be an array", + }); + } + + if (slotIds.length === 0) { + return {}; + } + + // Fetch all associations for the requested slots + const associations = await db.query.productSlots.findMany({ + where: inArray(productSlots.slotId, slotIds), + columns: { + slotId: true, + productId: true, + }, + }); + + // Group by slotId + const result = associations.reduce((acc, assoc) => { + if (!acc[assoc.slotId]) { + acc[assoc.slotId] = []; + } + acc[assoc.slotId].push(assoc.productId); + return acc; + }, {} as Record); + + // Ensure all requested slots have entries (even if empty) + slotIds.forEach((slotId) => { + if (!result[slotId]) { + result[slotId] = []; + } + }); + + return result; + }), + + // Exact replica of PUT /av/products/slots/:slotId/products + updateSlotProducts: protectedProcedure + .input( + z.object({ + slotId: z.number(), + productIds: z.array(z.number()), + }) + ) + .mutation(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const { slotId, productIds } = input; + + if (!Array.isArray(productIds)) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "productIds must be an array", + }); + } + + // Get current associations + const currentAssociations = await db.query.productSlots.findMany({ + where: eq(productSlots.slotId, slotId), + columns: { + productId: true, + }, + }); + + const currentProductIds = currentAssociations.map( + (assoc) => assoc.productId + ); + const newProductIds = productIds; + + // Find products to add and remove + const productsToAdd = newProductIds.filter( + (id) => !currentProductIds.includes(id) + ); + const productsToRemove = currentProductIds.filter( + (id) => !newProductIds.includes(id) + ); + + // Remove associations for products that are no longer selected + if (productsToRemove.length > 0) { + await db + .delete(productSlots) + .where( + and( + eq(productSlots.slotId, slotId), + inArray(productSlots.productId, productsToRemove) + ) + ); + } + + // Add associations for newly selected products + if (productsToAdd.length > 0) { + const newAssociations = productsToAdd.map((productId) => ({ + productId, + slotId, + })); + + await db.insert(productSlots).values(newAssociations); + } + + return { + message: "Slot products updated successfully", + added: productsToAdd.length, + removed: productsToRemove.length, + }; + }), + + createSlot: protectedProcedure + .input(createSlotSchema) + .mutation(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const { deliveryTime, freezeTime, isActive, productIds, vendorSnippets: snippets } = input; + + // Validate required fields + if (!deliveryTime || !freezeTime) { + throw new ApiError("Delivery time and orders close time are required", 400); + } + + return await db.transaction(async (tx) => { + // Create slot + const [newSlot] = await tx + .insert(deliverySlotInfo) + .values({ + deliveryTime: new Date(deliveryTime), + freezeTime: new Date(freezeTime), + isActive: isActive !== undefined ? isActive : true, + }) + .returning(); + + // Insert product associations if provided + if (productIds && productIds.length > 0) { + const associations = productIds.map((productId) => ({ + productId, + slotId: newSlot.id, + })); + await tx.insert(productSlots).values(associations); + } + + // Create vendor snippets if provided + let createdSnippets: any[] = []; + if (snippets && snippets.length > 0) { + for (const snippet of snippets) { + // Validate products exist + const products = await tx.query.productInfo.findMany({ + where: inArray(productInfo.id, snippet.productIds), + }); + if (products.length !== snippet.productIds.length) { + throw new ApiError(`One or more invalid product IDs in snippet "${snippet.name}"`, 400); + } + + // Check if snippet name already exists + const existingSnippet = await tx.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.snippetCode, snippet.name), + }); + if (existingSnippet) { + throw new ApiError(`Snippet name "${snippet.name}" already exists`, 400); + } + + const [createdSnippet] = await tx.insert(vendorSnippets).values({ + snippetCode: snippet.name, + slotId: newSlot.id, + productIds: snippet.productIds, + validTill: snippet.validTill ? new Date(snippet.validTill) : undefined, + }).returning(); + + createdSnippets.push(createdSnippet); + } + } + + return { + slot: newSlot, + createdSnippets, + message: "Slot created successfully", + }; + }); + }), + + getSlots: protectedProcedure.query(async ({ ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const slots = await db.query.deliverySlotInfo.findMany({ + where: eq(deliverySlotInfo.isActive, true), + }); + + return { + slots, + count: slots.length, + }; + }), + + getSlotById: protectedProcedure + .input(getSlotByIdSchema) + .query(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const { id } = input; + + const slot = await db.query.deliverySlotInfo.findFirst({ + where: eq(deliverySlotInfo.id, id), + with: { + productSlots: { + with: { + product: { + columns: { + id: true, + name: true, + images: true, + }, + }, + }, + }, + vendorSnippets: true, + }, + }); + + if (!slot) { + throw new ApiError("Slot not found", 404); + } + + return { + slot: { + ...slot, + deliverySequence: slot.deliverySequence as number[], + products: slot.productSlots.map((ps) => ps.product), + vendorSnippets: slot.vendorSnippets?.map(snippet => ({ + ...snippet, + accessUrl: `${appUrl}/vendor-order-list?id=${snippet.snippetCode}` + })), + }, + }; + }), + + updateSlot: protectedProcedure + .input(updateSlotSchema) + .mutation(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + try{ + const { id, deliveryTime, freezeTime, isActive, productIds, vendorSnippets: snippets } = input; + + if (!deliveryTime || !freezeTime) { + throw new ApiError("Delivery time and orders close time are required", 400); + } + + return await db.transaction(async (tx) => { + const [updatedSlot] = await tx + .update(deliverySlotInfo) + .set({ + deliveryTime: new Date(deliveryTime), + freezeTime: new Date(freezeTime), + isActive: isActive !== undefined ? isActive : true, + }) + .where(eq(deliverySlotInfo.id, id)) + .returning(); + + if (!updatedSlot) { + throw new ApiError("Slot not found", 404); + } + + // Update product associations + if (productIds !== undefined) { + // Delete existing associations + await tx.delete(productSlots).where(eq(productSlots.slotId, id)); + + // Insert new associations + if (productIds.length > 0) { + const associations = productIds.map((productId) => ({ + productId, + slotId: id, + })); + await tx.insert(productSlots).values(associations); + } + } + + // Create vendor snippets if provided + let createdSnippets: any[] = []; + if (snippets && snippets.length > 0) { + for (const snippet of snippets) { + // Validate products exist + const products = await tx.query.productInfo.findMany({ + where: inArray(productInfo.id, snippet.productIds), + }); + if (products.length !== snippet.productIds.length) { + throw new ApiError(`One or more invalid product IDs in snippet "${snippet.name}"`, 400); + } + + // Check if snippet name already exists + const existingSnippet = await tx.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.snippetCode, snippet.name), + }); + if (existingSnippet) { + throw new ApiError(`Snippet name "${snippet.name}" already exists`, 400); + } + + const [createdSnippet] = await tx.insert(vendorSnippets).values({ + snippetCode: snippet.name, + slotId: id, + productIds: snippet.productIds, + validTill: snippet.validTill ? new Date(snippet.validTill) : undefined, + + }).returning(); + + createdSnippets.push(createdSnippet); + } + } + + return { + slot: updatedSlot, + createdSnippets, + message: "Slot updated successfully", + }; + }); + } + catch(e) { + console.log(e) + throw new ApiError("Unable to Update Slot"); + } + }), + + deleteSlot: protectedProcedure + .input(deleteSlotSchema) + .mutation(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const { id } = input; + + const [deletedSlot] = await db + .update(deliverySlotInfo) + .set({ isActive: false }) + .where(eq(deliverySlotInfo.id, id)) + .returning(); + + if (!deletedSlot) { + throw new ApiError("Slot not found", 404); + } + + return { + message: "Slot deleted successfully", + }; + }), + + getDeliverySequence: protectedProcedure + .input(getDeliverySequenceSchema) + .query(async ({ input, ctx }) => { + + const { id } = input; + const slotId = parseInt(id); + const cacheKey = getSlotSequenceKey(slotId); + + try { + const cached = await redisClient.get(cacheKey); + if (cached) { + const parsed = JSON.parse(cached); + const validated = cachedSequenceSchema.parse(parsed) as CachedDeliverySequence; + console.log('sending cached response') + + return { deliverySequence: validated }; + } + } catch (error) { + console.warn('Redis cache read/validation failed, falling back to DB:', error); + // Continue to DB fallback + } + + // Fallback to DB + const slot = await db.query.deliverySlotInfo.findFirst({ + where: eq(deliverySlotInfo.id, slotId), + }); + + if (!slot) { + throw new ApiError("Slot not found", 404); + } + + const sequence = (slot.deliverySequence || {}) as CachedDeliverySequence; + + // Cache the validated result + try { + const validated = cachedSequenceSchema.parse(sequence); + await redisClient.set(cacheKey, JSON.stringify(validated), 3600); + } catch (cacheError) { + console.warn('Redis cache write failed:', cacheError); + } + + return { deliverySequence: sequence }; + }), + + updateDeliverySequence: protectedProcedure + .input(updateDeliverySequenceSchema) + .mutation(async ({ input, ctx }) => { + if (!ctx.staffUser?.id) { + throw new TRPCError({ code: "UNAUTHORIZED", message: "Access denied" }); + } + + const { id, deliverySequence } = input; + + + console.log({deliverySequence}) + + const [updatedSlot] = await db + .update(deliverySlotInfo) + .set({ deliverySequence }) + .where(eq(deliverySlotInfo.id, id)) + .returning({ + id: deliverySlotInfo.id, + deliverySequence: deliverySlotInfo.deliverySequence, + }); + + if (!updatedSlot) { + throw new ApiError("Slot not found", 404); + } + + // Cache the updated sequence + const cacheKey = getSlotSequenceKey(id); + try { + const validated = cachedSequenceSchema.parse(deliverySequence); + await redisClient.set(cacheKey, JSON.stringify(validated), 3600); + } catch (cacheError) { + console.warn('Redis cache write failed:', cacheError); + } + + return { + slot: updatedSlot, + message: "Delivery sequence updated successfully", + }; + }), +}); diff --git a/apps/backend/src/trpc/admin-apis/staff-user.ts b/apps/backend/src/trpc/admin-apis/staff-user.ts new file mode 100644 index 0000000..c1d0bfd --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/staff-user.ts @@ -0,0 +1,243 @@ +import { router, publicProcedure, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { staffUsers, staffRoles, users, userDetails, orders } from '../../db/schema'; +import { eq, or, ilike, and, lt, desc } from 'drizzle-orm'; +import bcrypt from 'bcryptjs'; +import jwt from 'jsonwebtoken'; +import { ApiError } from '../../lib/api-error'; + +export const staffUserRouter = router({ + login: publicProcedure + .input(z.object({ + name: z.string(), + password: z.string(), + })) + .mutation(async ({ input }) => { + const { name, password } = input; + + if (!name || !password) { + throw new ApiError('Name and password are required', 400); + } + + const staff = await db.query.staffUsers.findFirst({ + where: eq(staffUsers.name, name), + }); + + if (!staff) { + throw new ApiError('Invalid credentials', 401); + } + + const isPasswordValid = await bcrypt.compare(password, staff.password); + if (!isPasswordValid) { + throw new ApiError('Invalid credentials', 401); + } + + const token = jwt.sign( + { staffId: staff.id, name: staff.name }, + process.env.JWT_SECRET || 'default-secret', + { expiresIn: '30d' } + ); + + return { + message: 'Login successful', + token, + staff: { id: staff.id, name: staff.name }, + }; + }), + + getStaff: protectedProcedure + .query(async ({ ctx }) => { + const staff = await db.query.staffUsers.findMany({ + columns: { + id: true, + name: true, + }, + with: { + role: { + with: { + rolePermissions: { + with: { + permission: true, + }, + }, + }, + }, + }, + }); + + // Transform the data to include role and permissions in a cleaner format + const transformedStaff = staff.map((user) => ({ + id: user.id, + name: user.name, + role: user.role ? { + id: user.role.id, + name: user.role.roleName, + } : null, + permissions: user.role?.rolePermissions.map((rp) => ({ + id: rp.permission.id, + name: rp.permission.permissionName, + })) || [], + })); + + return { + staff: transformedStaff, + }; + }), + + getUsers: protectedProcedure + .input(z.object({ + cursor: z.number().optional(), + limit: z.number().default(20), + search: z.string().optional(), + })) + .query(async ({ input }) => { + const { cursor, limit, search } = input; + + let whereCondition = undefined; + + if (search) { + whereCondition = or( + ilike(users.name, `%${search}%`), + ilike(users.email, `%${search}%`), + ilike(users.mobile, `%${search}%`) + ); + } + + if (cursor) { + const cursorCondition = lt(users.id, cursor); + whereCondition = whereCondition ? and(whereCondition, cursorCondition) : cursorCondition; + } + + const allUsers = await db.query.users.findMany({ + where: whereCondition, + with: { + userDetails: true, + }, + orderBy: desc(users.id), + limit: limit + 1, // fetch one extra to check if there's more + }); + + const hasMore = allUsers.length > limit; + const usersToReturn = hasMore ? allUsers.slice(0, limit) : allUsers; + + const formattedUsers = usersToReturn.map(user => ({ + id: user.id, + name: user.name, + email: user.email, + mobile: user.mobile, + image: user.userDetails?.profileImage || null, + })); + + return { + users: formattedUsers, + nextCursor: hasMore ? usersToReturn[usersToReturn.length - 1].id : undefined, + }; + }), + + getUserDetails: protectedProcedure + .input(z.object({ userId: z.number() })) + .query(async ({ input }) => { + const { userId } = input; + + const user = await db.query.users.findFirst({ + where: eq(users.id, userId), + with: { + userDetails: true, + orders: { + orderBy: desc(orders.createdAt), + limit: 1, + }, + }, + }); + + if (!user) { + throw new ApiError("User not found", 404); + } + + const lastOrder = user.orders[0]; + + return { + id: user.id, + name: user.name, + email: user.email, + mobile: user.mobile, + addedOn: user.createdAt, + lastOrdered: lastOrder?.createdAt || null, + isSuspended: user.userDetails?.isSuspended || false, + }; + }), + + updateUserSuspension: protectedProcedure + .input(z.object({ userId: z.number(), isSuspended: z.boolean() })) + .mutation(async ({ input }) => { + const { userId, isSuspended } = input; + + await db + .insert(userDetails) + .values({ userId, isSuspended }) + .onConflictDoUpdate({ + target: userDetails.userId, + set: { isSuspended }, + }); + + return { success: true }; + }), + + createStaffUser: protectedProcedure + .input(z.object({ + name: z.string().min(1, 'Name is required'), + password: z.string().min(6, 'Password must be at least 6 characters'), + roleId: z.number().int().positive('Role is required'), + })) + .mutation(async ({ input, ctx }) => { + const { name, password, roleId } = input; + + // Check if staff user already exists + const existingUser = await db.query.staffUsers.findFirst({ + where: eq(staffUsers.name, name), + }); + + if (existingUser) { + throw new ApiError('Staff user with this name already exists', 409); + } + + // Check if role exists + const role = await db.query.staffRoles.findFirst({ + where: eq(staffRoles.id, roleId), + }); + + if (!role) { + throw new ApiError('Invalid role selected', 400); + } + + // Hash password + const hashedPassword = await bcrypt.hash(password, 12); + + // Create staff user + const [newUser] = await db.insert(staffUsers).values({ + name: name.trim(), + password: hashedPassword, + staffRoleId: roleId, + }).returning(); + + return { success: true, user: { id: newUser.id, name: newUser.name } }; + }), + + getRoles: protectedProcedure + .query(async ({ ctx }) => { + const roles = await db.query.staffRoles.findMany({ + columns: { + id: true, + roleName: true, + }, + }); + + return { + roles: roles.map(role => ({ + id: role.id, + name: role.roleName, + })), + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/store.ts b/apps/backend/src/trpc/admin-apis/store.ts new file mode 100644 index 0000000..94f3021 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/store.ts @@ -0,0 +1,197 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { storeInfo, productInfo } from '../../db/schema'; +import { eq, inArray } from 'drizzle-orm'; +import { ApiError } from '../../lib/api-error'; + import { extractKeyFromPresignedUrl, deleteImageUtil, generateSignedUrlFromS3Url } from '../../lib/s3-client'; +import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; + +export const storeRouter = router({ + getStores: protectedProcedure + .query(async ({ ctx }) => { + const stores = await db.query.storeInfo.findMany({ + with: { + owner: true, + }, + }); + + Promise.all(stores.map(async store => { + if(store.imageUrl) + store.imageUrl = await generateSignedUrlFromS3Url(store.imageUrl) + })).catch((e) => { + throw new ApiError("Unable to find store image urls") + } + ) + return { + stores, + count: stores.length, + }; + }), + + getStoreById: protectedProcedure + .input(z.object({ + id: z.number(), + })) + .query(async ({ input, ctx }) => { + const { id } = input; + + const store = await db.query.storeInfo.findFirst({ + where: eq(storeInfo.id, id), + with: { + owner: true, + }, + }); + + if (!store) { + throw new ApiError("Store not found", 404); + } + store.imageUrl = await generateSignedUrlFromS3Url(store.imageUrl); + return { + store, + }; + }), + + createStore: protectedProcedure + .input(z.object({ + name: z.string().min(1, "Name is required"), + description: z.string().optional(), + imageUrl: z.string().optional(), + owner: z.number().min(1, "Owner is required"), + products: z.array(z.number()).optional(), + })) + .mutation(async ({ input, ctx }) => { + const { name, description, imageUrl, owner, products } = input; + + const imageKey = imageUrl ? extractKeyFromPresignedUrl(imageUrl) : undefined; + + const [newStore] = await db + .insert(storeInfo) + .values({ + name, + description, + imageUrl: imageKey, + owner, + }) + .returning(); + + // Assign selected products to this store + if (products && products.length > 0) { + await db + .update(productInfo) + .set({ storeId: newStore.id }) + .where(inArray(productInfo.id, products)); + } + + return { + store: newStore, + message: "Store created successfully", + }; + }), + + updateStore: protectedProcedure + .input(z.object({ + id: z.number(), + name: z.string().min(1, "Name is required"), + description: z.string().optional(), + imageUrl: z.string().optional(), + owner: z.number().min(1, "Owner is required"), + products: z.array(z.number()).optional(), + })) + .mutation(async ({ input, ctx }) => { + const { id, name, description, imageUrl, owner, products } = input; + + const existingStore = await db.query.storeInfo.findFirst({ + where: eq(storeInfo.id, id), + }); + + if (!existingStore) { + throw new ApiError("Store not found", 404); + } + + const oldImageKey = existingStore.imageUrl; + const newImageKey = imageUrl ? extractKeyFromPresignedUrl(imageUrl) : oldImageKey; + + // Delete old image only if: + // 1. New image provided and keys are different, OR + // 2. No new image but old exists (clearing the image) + if (oldImageKey && ( + (newImageKey && newImageKey !== oldImageKey) || + (!newImageKey) + )) { + try { + await deleteImageUtil({keys: [oldImageKey]}); + } catch (error) { + console.error('Failed to delete old image:', error); + // Continue with update even if deletion fails + } + } + + const [updatedStore] = await db + .update(storeInfo) + .set({ + name, + description, + imageUrl: newImageKey, + owner, + }) + .where(eq(storeInfo.id, id)) + .returning(); + + if (!updatedStore) { + throw new ApiError("Store not found", 404); + } + + // Update products if provided + if (products) { + // First, set storeId to null for products not in the list but currently assigned to this store + await db + .update(productInfo) + .set({ storeId: null }) + .where(eq(productInfo.storeId, id)); + + // Then, assign the selected products to this store + if (products.length > 0) { + await db + .update(productInfo) + .set({ storeId: id }) + .where(inArray(productInfo.id, products)); + } + } + + return { + store: updatedStore, + message: "Store updated successfully", + }; + }), + + deleteStore: protectedProcedure + .input(z.object({ + storeId: z.number(), + })) + .mutation(async ({ input, ctx }) => { + const { storeId } = input; + + return await db.transaction(async (tx) => { + // First, update all products of this store to set storeId to null + await tx + .update(productInfo) + .set({ storeId: null }) + .where(eq(productInfo.storeId, storeId)); + + // Then delete the store + const [deletedStore] = await tx + .delete(storeInfo) + .where(eq(storeInfo.id, storeId)) + .returning(); + + if (!deletedStore) { + throw new ApiError("Store not found", 404); + } + + return { + message: "Store deleted successfully", + }; + }); + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/user.ts b/apps/backend/src/trpc/admin-apis/user.ts new file mode 100644 index 0000000..74493ae --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/user.ts @@ -0,0 +1,54 @@ +import { protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { users } from '../../db/schema'; +import { eq } from 'drizzle-orm'; +import { ApiError } from '../../lib/api-error'; + +async function createUserByMobile(mobile: string): Promise { + // Clean mobile number (remove non-digits) + const cleanMobile = mobile.replace(/\D/g, ''); + + // Validate: exactly 10 digits + if (cleanMobile.length !== 10) { + throw new ApiError('Mobile number must be exactly 10 digits', 400); + } + + // Check if user already exists + const [existingUser] = await db + .select() + .from(users) + .where(eq(users.mobile, cleanMobile)) + .limit(1); + + if (existingUser) { + throw new ApiError('User with this mobile number already exists', 409); + } + + // Create user + const [newUser] = await db + .insert(users) + .values({ + name: null, + email: null, + mobile: cleanMobile, + }) + .returning(); + + return newUser; +} + +export const userRouter = { + createUserByMobile: protectedProcedure + .input(z.object({ + mobile: z.string().min(1, 'Mobile number is required'), + })) + .mutation(async ({ input }) => { + const newUser = await createUserByMobile(input.mobile); + + return { + success: true, + data: newUser, + }; + }), +}; \ No newline at end of file diff --git a/apps/backend/src/trpc/admin-apis/vendor-snippets.ts b/apps/backend/src/trpc/admin-apis/vendor-snippets.ts new file mode 100644 index 0000000..b798c10 --- /dev/null +++ b/apps/backend/src/trpc/admin-apis/vendor-snippets.ts @@ -0,0 +1,375 @@ +import { router, publicProcedure, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { vendorSnippets, deliverySlotInfo, productInfo, orders, orderItems, users } from '../../db/schema'; +import { eq, and, inArray } from 'drizzle-orm'; +import { appUrl } from '../../lib/env-exporter'; + +const createSnippetSchema = z.object({ + snippetCode: z.string().min(1, "Snippet code is required"), + slotId: z.number().int().positive("Valid slot ID is required"), + productIds: z.array(z.number().int().positive()).min(1, "At least one product is required"), + validTill: z.string().optional(), +}); + +const updateSnippetSchema = z.object({ + id: z.number().int().positive(), + updates: createSnippetSchema.partial().extend({ + snippetCode: z.string().min(1).optional(), + productIds: z.array(z.number().int().positive()).optional(), + }), +}); + +export const vendorSnippetsRouter = router({ + create: protectedProcedure + .input(createSnippetSchema) + .mutation(async ({ input, ctx }) => { + const { snippetCode, slotId, productIds, validTill } = input; + + // Get staff user ID from auth middleware + const staffUserId = ctx.staffUser?.id; + if (!staffUserId) { + throw new Error("Unauthorized"); + } + + // Validate slot exists + const slot = await db.query.deliverySlotInfo.findFirst({ + where: eq(deliverySlotInfo.id, slotId), + }); + if (!slot) { + throw new Error("Invalid slot ID"); + } + + // Validate products exist + const products = await db.query.productInfo.findMany({ + where: inArray(productInfo.id, productIds), + }); + if (products.length !== productIds.length) { + throw new Error("One or more invalid product IDs"); + } + + // Check if snippet code already exists + const existingSnippet = await db.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.snippetCode, snippetCode), + }); + if (existingSnippet) { + throw new Error("Snippet code already exists"); + } + + const result = await db.insert(vendorSnippets).values({ + snippetCode, + slotId, + productIds, + validTill: validTill ? new Date(validTill) : undefined, + }).returning(); + + return result[0]; + }), + + getAll: protectedProcedure + .query(async () => { + console.log('from the vendor snipptes methods') + + try { + + const result = await db.query.vendorSnippets.findMany({ + with: { + slot: true, + }, + orderBy: (vendorSnippets, { desc }) => [desc(vendorSnippets.createdAt)], + }); + return result.map(snippet => ({ + ...snippet, + accessUrl: `${appUrl}/vendor-order-list?id=${snippet.snippetCode}` + })); + } + catch(e) { + console.log(e) + } + return []; + }), + + getById: protectedProcedure + .input(z.object({ id: z.number().int().positive() })) + .query(async ({ input }) => { + const { id } = input; + + const result = await db.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.id, id), + with: { + slot: true, + }, + }); + + if (!result) { + throw new Error("Vendor snippet not found"); + } + + return result; + }), + + update: protectedProcedure + .input(updateSnippetSchema) + .mutation(async ({ input }) => { + const { id, updates } = input; + + // Check if snippet exists + const existingSnippet = await db.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.id, id), + }); + if (!existingSnippet) { + throw new Error("Vendor snippet not found"); + } + + // Validate slot if being updated + if (updates.slotId) { + const slot = await db.query.deliverySlotInfo.findFirst({ + where: eq(deliverySlotInfo.id, updates.slotId), + }); + if (!slot) { + throw new Error("Invalid slot ID"); + } + } + + // Validate products if being updated + if (updates.productIds) { + const products = await db.query.productInfo.findMany({ + where: inArray(productInfo.id, updates.productIds), + }); + if (products.length !== updates.productIds.length) { + throw new Error("One or more invalid product IDs"); + } + } + + // Check snippet code uniqueness if being updated + if (updates.snippetCode && updates.snippetCode !== existingSnippet.snippetCode) { + const duplicateSnippet = await db.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.snippetCode, updates.snippetCode), + }); + if (duplicateSnippet) { + throw new Error("Snippet code already exists"); + } + } + + const updateData: any = { ...updates }; + if (updates.validTill !== undefined) { + updateData.validTill = updates.validTill ? new Date(updates.validTill) : null; + } + + const result = await db.update(vendorSnippets) + .set(updateData) + .where(eq(vendorSnippets.id, id)) + .returning(); + + if (result.length === 0) { + throw new Error("Failed to update vendor snippet"); + } + + return result[0]; + }), + + delete: protectedProcedure + .input(z.object({ id: z.number().int().positive() })) + .mutation(async ({ input }) => { + const { id } = input; + + const result = await db.delete(vendorSnippets) + .where(eq(vendorSnippets.id, id)) + .returning(); + + if (result.length === 0) { + throw new Error("Vendor snippet not found"); + } + + return { message: "Vendor snippet deleted successfully" }; + }), + + getOrdersBySnippet: publicProcedure + .input(z.object({ + snippetCode: z.string().min(1, "Snippet code is required") + })) + .query(async ({ input }) => { + const { snippetCode } = input; + + // Find the snippet + const snippet = await db.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.snippetCode, snippetCode), + }); + + if (!snippet) { + throw new Error("Vendor snippet not found"); + } + + // Check if snippet is still valid + if (snippet.validTill && new Date(snippet.validTill) < new Date()) { + throw new Error("Vendor snippet has expired"); + } + + // Query orders that match the snippet criteria + const matchingOrders = await db.query.orders.findMany({ + where: and( + eq(orders.slotId, snippet.slotId), + // We'll filter by products in the application logic + ), + with: { + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + user: true, + slot: true, + }, + orderBy: (orders, { desc }) => [desc(orders.createdAt)], + }); + + // Filter orders that contain at least one of the snippet's products + const filteredOrders = matchingOrders.filter(order => { + const orderProductIds = order.orderItems.map(item => item.productId); + return snippet.productIds.some(productId => orderProductIds.includes(productId)); + }); + + // Format the response + const formattedOrders = filteredOrders.map(order => { + // Filter orderItems to only include products attached to the snippet + const attachedOrderItems = order.orderItems.filter(item => + snippet.productIds.includes(item.productId) + ); + + const products = attachedOrderItems.map(item => ({ + orderItemId: item.id, + productId: item.productId, + productName: item.product.name, + quantity: parseFloat(item.quantity), + price: parseFloat(item.price.toString()), + unit: item.product.unit?.shortNotation || 'unit', + subtotal: parseFloat(item.price.toString()) * parseFloat(item.quantity), + is_packaged: item.is_packaged, + is_package_verified: item.is_package_verified, + })); + + return { + orderId: `ORD${order.readableId.toString().padStart(3, '0')}`, + orderDate: order.createdAt.toISOString(), + customerName: order.user.name, + totalAmount: order.totalAmount, + slotInfo: order.slot ? { + time: order.slot.deliveryTime.toISOString(), + sequence: order.slot.deliverySequence, + } : null, + products, + matchedProducts: snippet.productIds, // All snippet products are considered matched + snippetCode: snippet.snippetCode, + }; + }); + + return { + success: true, + data: formattedOrders, + snippet: { + id: snippet.id, + snippetCode: snippet.snippetCode, + slotId: snippet.slotId, + productIds: snippet.productIds, + validTill: snippet.validTill?.toISOString(), + createdAt: snippet.createdAt.toISOString(), + }, + }; + }), + + getVendorOrders: protectedProcedure + .query(async () => { + const vendorOrders = await db.query.orders.findMany({ + with: { + user: true, + orderItems: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + }, + orderBy: (orders, { desc }) => [desc(orders.createdAt)], + }); + + return vendorOrders.map(order => ({ + id: order.id, + status: 'pending', // Default status since orders table may not have status field + orderDate: order.createdAt.toISOString(), + totalQuantity: order.orderItems.reduce((sum, item) => sum + parseFloat(item.quantity || '0'), 0), + products: order.orderItems.map(item => ({ + name: item.product.name, + quantity: parseFloat(item.quantity || '0'), + unit: item.product.unit?.shortNotation || 'unit', + })), + })); + }), + + updateOrderItemPackaging: publicProcedure + .input(z.object({ + orderItemId: z.number().int().positive("Valid order item ID required"), + is_packaged: z.boolean() + })) + .mutation(async ({ input, ctx }) => { + const { orderItemId, is_packaged } = input; + + // Get staff user ID from auth middleware + // const staffUserId = ctx.staffUser?.id; + // if (!staffUserId) { + // throw new Error("Unauthorized"); + // } + + // Check if order item exists and get related data + const orderItem = await db.query.orderItems.findFirst({ + where: eq(orderItems.id, orderItemId), + with: { + order: { + with: { + slot: true + } + } + } + }); + + if (!orderItem) { + throw new Error("Order item not found"); + } + + // Check if this order item belongs to a slot that has vendor snippets + // This ensures only order items from vendor-accessible orders can be updated + if (!orderItem.order.slotId) { + throw new Error("Order item not associated with a vendor slot"); + } + + const snippetExists = await db.query.vendorSnippets.findFirst({ + where: eq(vendorSnippets.slotId, orderItem.order.slotId), + }); + + if (!snippetExists) { + throw new Error("No vendor snippet found for this order's slot"); + } + + // Update the is_packaged field + const result = await db.update(orderItems) + .set({ is_packaged }) + .where(eq(orderItems.id, orderItemId)) + .returning(); + + if (result.length === 0) { + throw new Error("Failed to update packaging status"); + } + + return { + success: true, + orderItemId, + is_packaged + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/common-apis/common-trpc-index.ts b/apps/backend/src/trpc/common-apis/common-trpc-index.ts new file mode 100644 index 0000000..6e828db --- /dev/null +++ b/apps/backend/src/trpc/common-apis/common-trpc-index.ts @@ -0,0 +1,122 @@ +import { router, publicProcedure, protectedProcedure } from '../trpc-index'; +import { commonRouter } from './common'; +import { db } from '../../db/db_index'; +import { keyValStore, productInfo, storeInfo } from '../../db/schema'; +import * as turf from '@turf/turf'; +import { z } from 'zod'; +import { mbnrGeoJson } from '../../lib/mbnr-geojson'; +import { generateUploadUrl } from '../../lib/s3-client'; +import { ApiError } from '../../lib/api-error'; +import { getAllConstValues } from '../../lib/const-store'; +import { CONST_KEYS } from '../../lib/const-keys'; + +const polygon = turf.polygon(mbnrGeoJson.features[0].geometry.coordinates); + +export const commonApiRouter = router({ + product: commonRouter, + getStoresSummary: publicProcedure + .query(async () => { + const stores = await db.query.storeInfo.findMany({ + columns: { + id: true, + name: true, + description: true, + }, + }); + + return { + stores, + }; + }), + checkLocationInPolygon: publicProcedure + .input(z.object({ + lat: z.number().min(-90).max(90), + lng: z.number().min(-180).max(180), + })) + .query(({ input }) => { + try { + const { lat, lng } = input; + const point = turf.point([lng, lat]); // GeoJSON: [longitude, latitude] + const isInside = turf.booleanPointInPolygon(point, polygon); + return { isInside }; + } catch (error) { + throw new Error('Invalid coordinates or polygon data'); + } + }), + + generateUploadUrls: protectedProcedure + .input(z.object({ + contextString: z.enum(['review', 'product_info', 'store']), + mimeTypes: z.array(z.string()), + })) + .mutation(async ({ input }): Promise<{ uploadUrls: string[] }> => { + const { contextString, mimeTypes } = input; + + const uploadUrls: string[] = []; + const keys: string[] = []; + + for (const mimeType of mimeTypes) { + // Generate key based on context and mime type + let folder: string; + if (contextString === 'review') { + folder = 'review-images'; + } else if (contextString === 'product_info') { + folder = 'product-images'; + } else if (contextString === 'store') { + folder = 'store-images'; + } else if (contextString === 'review_response') { + folder = 'review-response-images'; + } else { + folder = ''; + } + + const extension = mimeType === 'image/jpeg' ? '.jpg' : + mimeType === 'image/png' ? '.png' : + mimeType === 'image/gif' ? '.gif' : '.jpg'; + const key = `${folder}/${Date.now()}${extension}`; + + try { + const uploadUrl = await generateUploadUrl(key, mimeType); + uploadUrls.push(uploadUrl); + keys.push(key); + + } catch (error) { + console.error('Error generating upload URL:', error); + throw new ApiError('Failed to generate upload URL', 500); + } + } + return { uploadUrls }; + }), + healthCheck: publicProcedure + .query(async () => { + // Test DB connection by selecting product names + // await db.select({ name: productInfo.name }).from(productInfo).limit(1); + await db.select({ key: keyValStore.key }).from(keyValStore).limit(1); + + return { + status: "ok", + }; + }), + essentialConsts: publicProcedure + .query(async () => { + const consts = await getAllConstValues(); + + return { + freeDeliveryThreshold: consts[CONST_KEYS.freeDeliveryThreshold] ?? 200, + deliveryCharge: consts[CONST_KEYS.deliveryCharge] ?? 0, + flashFreeDeliveryThreshold: consts[CONST_KEYS.flashFreeDeliveryThreshold] ?? 500, + flashDeliveryCharge: consts[CONST_KEYS.flashDeliveryCharge] ?? 69, + popularItems: consts[CONST_KEYS.popularItems] ?? '5,3,2,4,1', + versionNum: consts[CONST_KEYS.versionNum] ?? '1.1.0', + playStoreUrl: consts[CONST_KEYS.playStoreUrl] ?? 'https://play.google.com/store/apps/details?id=in.freshyo.app', + appStoreUrl: consts[CONST_KEYS.appStoreUrl] ?? 'https://play.google.com/store/apps/details?id=in.freshyo.app', + webViewHtml: null, + isWebviewClosable: true, + isFlashDeliveryEnabled: consts[CONST_KEYS.isFlashDeliveryEnabled] ?? true, + supportMobile: consts[CONST_KEYS.supportMobile] ?? '', + supportEmail: consts[CONST_KEYS.supportEmail] ?? '', + }; + }), +}); + +export type CommonApiRouter = typeof commonApiRouter; diff --git a/apps/backend/src/trpc/common-apis/common.ts b/apps/backend/src/trpc/common-apis/common.ts new file mode 100644 index 0000000..651cf21 --- /dev/null +++ b/apps/backend/src/trpc/common-apis/common.ts @@ -0,0 +1,165 @@ +import { router, publicProcedure } from '../trpc-index'; +import { db } from '../../db/db_index'; +import { productInfo, units, productSlots, deliverySlotInfo, storeInfo, productTags, productTagInfo } from '../../db/schema'; +import { eq, gt, and, sql, inArray } from 'drizzle-orm'; +import { generateSignedUrlsFromS3Urls, generateSignedUrlFromS3Url } from '../../lib/s3-client'; +import { z } from 'zod'; + +export const getNextDeliveryDate = async (productId: number): Promise => { + const result = await db + .select({ deliveryTime: deliverySlotInfo.deliveryTime }) + .from(productSlots) + .innerJoin(deliverySlotInfo, eq(productSlots.slotId, deliverySlotInfo.id)) + .where( + and( + eq(productSlots.productId, productId), + eq(deliverySlotInfo.isActive, true), + gt(deliverySlotInfo.deliveryTime, sql`NOW()`) + ) + ) + .orderBy(deliverySlotInfo.deliveryTime) + .limit(1); + + + return result[0]?.deliveryTime || null; +}; + + + + + +export const commonRouter = router({ + getDashboardTags: publicProcedure + .query(async () => { + const tags = await db + .select() + .from(productTagInfo) + .where(eq(productTagInfo.isDashboardTag, true)) + .orderBy(productTagInfo.tagName); + + // Generate signed URLs for tag images + const tagsWithSignedUrls = await Promise.all( + tags.map(async (tag) => ({ + ...tag, + imageUrl: tag.imageUrl ? await generateSignedUrlFromS3Url(tag.imageUrl) : null, + })) + ); + + return { + tags: tagsWithSignedUrls, + }; + }), + + getAllProductsSummary: publicProcedure + .input(z.object({ + searchQuery: z.string().optional(), + tagId: z.number().optional() + })) + .query(async ({ input }) => { + const { searchQuery, tagId } = input; + + let productIds: number[] | null = null; + + // If tagId is provided, get products that have this tag + if (tagId) { + const taggedProducts = await db + .select({ productId: productTags.productId }) + .from(productTags) + .where(eq(productTags.tagId, tagId)); + + productIds = taggedProducts.map(tp => tp.productId); + } + + let whereConditions = []; + + // Add tag filtering + if (productIds && productIds.length > 0) { + whereConditions.push(inArray(productInfo.id, productIds)); + } else if (tagId) { + // If tagId was provided but no products found, return empty array + return { + products: [], + count: 0, + }; + } + + // Add search filtering + if (searchQuery) { + whereConditions.push(sql`LOWER(${productInfo.name}) LIKE LOWER(${ '%' + searchQuery + '%' })`); + } + + // Filter out suspended products + whereConditions.push(eq(productInfo.isSuspended, false)); + + const whereCondition = whereConditions.length > 0 ? and(...whereConditions) : undefined; + + const productsWithUnits = await db + .select({ + id: productInfo.id, + name: productInfo.name, + shortDescription: productInfo.shortDescription, + price: productInfo.price, + marketPrice: productInfo.marketPrice, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + unitShortNotation: units.shortNotation, + incrementStep: productInfo.incrementStep, + productQuantity: productInfo.productQuantity, + storeId: productInfo.storeId, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)) + .where(whereCondition); + + // Generate signed URLs for product images + const formattedProducts = await Promise.all( + productsWithUnits.map(async (product) => { + const nextDeliveryDate = await getNextDeliveryDate(product.id); + return { + id: product.id, + name: product.name, + shortDescription: product.shortDescription, + price: product.price, + marketPrice: product.marketPrice, + unit: product.unitShortNotation, + incrementStep: product.incrementStep, + productQuantity: product.productQuantity, + storeId: product.storeId, + isOutOfStock: product.isOutOfStock, + nextDeliveryDate: nextDeliveryDate ? nextDeliveryDate.toISOString() : null, + images: await generateSignedUrlsFromS3Urls((product.images as string[]) || []), + }; + }) + ); + + return { + products: formattedProducts, + count: formattedProducts.length, + }; + }), + + getStoresSummary: publicProcedure + .query(async () => { + const stores = await db.query.storeInfo.findMany({ + columns: { + id: true, + name: true, + description: true, + }, + }); + + return { + stores, + }; + }), + + healthCheck: publicProcedure + .query(async () => { + // Test DB connection by selecting product names + await db.select({ name: productInfo.name }).from(productInfo).limit(1); + + return { + status: "ok", + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/router.ts b/apps/backend/src/trpc/router.ts new file mode 100644 index 0000000..e6471b5 --- /dev/null +++ b/apps/backend/src/trpc/router.ts @@ -0,0 +1,20 @@ +import { router, publicProcedure } from './trpc-index'; +import { z } from 'zod'; +import { adminRouter } from './admin-apis/admin-trpc-index'; +import { userRouter } from './user-apis/user-trpc-index'; +import { commonApiRouter } from './common-apis/common-trpc-index'; + +// Create the main app router +export const appRouter = router({ + hello: publicProcedure + .input(z.object({ name: z.string() })) + .query(({ input }) => { + return { greeting: `Hello ${input.name}!` }; + }), + admin: adminRouter, + user: userRouter, + common: commonApiRouter, +}); + +// Export type definition of API +export type AppRouter = typeof appRouter; \ No newline at end of file diff --git a/apps/backend/src/trpc/trpc-index.ts b/apps/backend/src/trpc/trpc-index.ts new file mode 100644 index 0000000..85c5457 --- /dev/null +++ b/apps/backend/src/trpc/trpc-index.ts @@ -0,0 +1,73 @@ +import { initTRPC, TRPCError } from '@trpc/server'; +import { type CreateExpressContextOptions } from '@trpc/server/adapters/express'; + +export interface Context { + req: CreateExpressContextOptions['req']; + res: CreateExpressContextOptions['res']; + user?: any; + staffUser?: { + id: number; + name: string; + } | null; +} + +const t = initTRPC.context().create(); + +export const middleware = t.middleware; +export const router = t.router; +export { TRPCError }; + +// Global error logger middleware +const errorLoggerMiddleware = middleware(async ({ path, type, next, ctx }) => { + const start = Date.now(); + + try { + const result = await next(); + const duration = Date.now() - start; + + // Log successful operations in development + if (process.env.NODE_ENV === 'development') { + console.log(`✅ ${type} ${path} - ${duration}ms`); + } + + return result; + } catch (error) { + const duration = Date.now() - start; + const err = error as any; // Type assertion for error object + + // Comprehensive error logging + console.error('🚨 tRPC Error:', { + timestamp: new Date().toISOString(), + path, + type, + duration: `${duration}ms`, + userId: ctx?.user?.userId || ctx?.staffUser?.id || 'anonymous', + error: { + name: err.name, + message: err.message, + code: err.code, + stack: err.stack, + }, + // Add SQL-specific details if available + ...(err.code && { sqlCode: err.code }), + ...(err.meta && { sqlMeta: err.meta }), + ...(err.sql && { sql: err.sql }), + }); + + throw error; // Re-throw to maintain error flow + } +}); + +export const publicProcedure = t.procedure.use(errorLoggerMiddleware); +export const protectedProcedure = t.procedure.use(errorLoggerMiddleware).use( + middleware(async ({ ctx, next }) => { + + if ((!ctx.user && !ctx.staffUser)) { + throw new TRPCError({ code: 'UNAUTHORIZED' }); + } + return next(); + }) +); + +export const createCallerFactory = t.createCallerFactory; +export const createTRPCRouter = t.router; \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/address.ts b/apps/backend/src/trpc/user-apis/address.ts new file mode 100644 index 0000000..71a0553 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/address.ts @@ -0,0 +1,154 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { addresses, orders, orderStatus, deliverySlotInfo } from '../../db/schema'; +import { eq, and, gte } from 'drizzle-orm'; +import dayjs from 'dayjs'; + +export const addressRouter = router({ + getDefaultAddress: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + + const [defaultAddress] = await db + .select() + .from(addresses) + .where(and(eq(addresses.userId, userId), eq(addresses.isDefault, true))) + .limit(1); + + return { success: true, data: defaultAddress || null }; + }), + + getUserAddresses: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + const userAddresses = await db.select().from(addresses).where(eq(addresses.userId, userId)); + return { success: true, data: userAddresses }; + }), + + createAddress: protectedProcedure + .input(z.object({ + name: z.string().min(1, 'Name is required'), + phone: z.string().min(1, 'Phone is required'), + addressLine1: z.string().min(1, 'Address line 1 is required'), + addressLine2: z.string().optional(), + city: z.string().min(1, 'City is required'), + state: z.string().min(1, 'State is required'), + pincode: z.string().min(1, 'Pincode is required'), + isDefault: z.boolean().optional(), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { name, phone, addressLine1, addressLine2, city, state, pincode, isDefault } = input; + + // Validate required fields + if (!name || !phone || !addressLine1 || !city || !state || !pincode) { + throw new Error('Missing required fields'); + } + + // If setting as default, unset other defaults + if (isDefault) { + await db.update(addresses).set({ isDefault: false }).where(eq(addresses.userId, userId)); + } + + const [newAddress] = await db.insert(addresses).values({ + userId, + name, + phone, + addressLine1, + addressLine2, + city, + state, + pincode, + isDefault: isDefault || false, + }).returning(); + + return { success: true, data: newAddress }; + }), + + updateAddress: protectedProcedure + .input(z.object({ + id: z.number().int().positive(), + name: z.string().min(1, 'Name is required'), + phone: z.string().min(1, 'Phone is required'), + addressLine1: z.string().min(1, 'Address line 1 is required'), + addressLine2: z.string().optional(), + city: z.string().min(1, 'City is required'), + state: z.string().min(1, 'State is required'), + pincode: z.string().min(1, 'Pincode is required'), + isDefault: z.boolean().optional(), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { id, name, phone, addressLine1, addressLine2, city, state, pincode, isDefault } = input; + + // Check if address exists and belongs to user + const existingAddress = await db.select().from(addresses).where(and(eq(addresses.id, id), eq(addresses.userId, userId))).limit(1); + if (existingAddress.length === 0) { + throw new Error('Address not found'); + } + + // If setting as default, unset other defaults + if (isDefault) { + await db.update(addresses).set({ isDefault: false }).where(eq(addresses.userId, userId)); + } + + const [updatedAddress] = await db.update(addresses).set({ + name, + phone, + addressLine1, + addressLine2, + city, + state, + pincode, + isDefault: isDefault || false, + }).where(and(eq(addresses.id, id), eq(addresses.userId, userId))).returning(); + + return { success: true, data: updatedAddress }; + }), + + deleteAddress: protectedProcedure + .input(z.object({ + id: z.number().int().positive(), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { id } = input; + + // Check if address exists and belongs to user + const existingAddress = await db.select().from(addresses).where(and(eq(addresses.id, id), eq(addresses.userId, userId))).limit(1); + if (existingAddress.length === 0) { + throw new Error('Address not found or does not belong to user'); + } + + // Check if address is attached to any ongoing orders using joins + const ongoingOrders = await db.select({ + order: orders, + status: orderStatus, + slot: deliverySlotInfo + }) + .from(orders) + .innerJoin(orderStatus, eq(orders.id, orderStatus.orderId)) + .innerJoin(deliverySlotInfo, eq(orders.slotId, deliverySlotInfo.id)) + .where(and( + eq(orders.addressId, id), + eq(orderStatus.isCancelled, false), + gte(deliverySlotInfo.deliveryTime, new Date()) + )) + .limit(1); + + if (ongoingOrders.length > 0) { + throw new Error('Address is attached to an ongoing order. Please cancel the order first.'); + } + + // Prevent deletion of default address + if (existingAddress[0].isDefault) { + throw new Error('Cannot delete default address. Please set another address as default first.'); + } + + // Delete the address + await db.delete(addresses).where(and(eq(addresses.id, id), eq(addresses.userId, userId))); + + return { success: true, message: 'Address deleted successfully' }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/auth.ts b/apps/backend/src/trpc/user-apis/auth.ts new file mode 100644 index 0000000..40b04a5 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/auth.ts @@ -0,0 +1,463 @@ +import { router, publicProcedure, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import bcrypt from 'bcryptjs'; +import jwt from 'jsonwebtoken'; +import { eq } from 'drizzle-orm'; +import { db } from '../../db/db_index'; +import { + users, userCreds, userDetails, addresses, cartItems, complaints, + couponApplicableUsers, couponUsage, notifCreds, notifications, + orderItems, orderStatus, orders, payments, refunds, + productReviews, reservedCoupons +} from '../../db/schema'; +import { generateSignedUrlFromS3Url } from '../../lib/s3-client'; +import { ApiError } from '../../lib/api-error'; +import catchAsync from '../../lib/catch-async'; +import { jwtSecret } from 'src/lib/env-exporter'; +import { sendOtp, verifyOtpUtil, getOtpCreds } from '../../lib/otp-utils'; + +interface LoginRequest { + identifier: string; // email or mobile + password: string; +} + +interface RegisterRequest { + name: string; + email: string; + mobile: string; + password: string; +} + +interface AuthResponse { + token: string; + user: { + id: number; + name?: string | null; + email: string | null; + mobile: string | null; + createdAt: string; + profileImage: string | null; + bio?: string | null; + dateOfBirth?: string | null; + gender?: string | null; + occupation?: string | null; + }; +} + +const generateToken = (userId: number): string => { + const secret = jwtSecret; + if (!secret) { + throw new ApiError('JWT secret not configured', 500); + } + + return jwt.sign({ userId }, secret, { expiresIn: '7d' }); +}; + + + +export const authRouter = router({ + login: publicProcedure + .input(z.object({ + identifier: z.string().min(1, 'Email/mobile is required'), + password: z.string().min(1, 'Password is required'), + })) + .mutation(async ({ input }) => { + const { identifier, password }: LoginRequest = input; + + if (!identifier || !password) { + throw new ApiError('Email/mobile and password are required', 400); + } + + // Find user by email or mobile + const [user] = await db + .select() + .from(users) + .where(eq(users.email, identifier.toLowerCase())) + .limit(1); + + let foundUser = user; + + if (!foundUser) { + // Try mobile if email didn't work + const [userByMobile] = await db + .select() + .from(users) + .where(eq(users.mobile, identifier)) + .limit(1); + foundUser = userByMobile; + } + + if (!foundUser) { + throw new ApiError('Invalid credentials', 401); + } + + // Get user credentials + const [userCredentials] = await db + .select() + .from(userCreds) + .where(eq(userCreds.userId, foundUser.id)) + .limit(1); + + if (!userCredentials) { + throw new ApiError('Account setup incomplete. Please contact support.', 401); + } + + // Get user details for profile image + const [userDetail] = await db + .select() + .from(userDetails) + .where(eq(userDetails.userId, foundUser.id)) + .limit(1); + + // Generate signed URL for profile image if it exists + const profileImageSignedUrl = userDetail?.profileImage + ? await generateSignedUrlFromS3Url(userDetail.profileImage) + : null; + + // Verify password + const isPasswordValid = await bcrypt.compare(password, userCredentials.userPassword); + if (!isPasswordValid) { + throw new ApiError('Invalid credentials', 401); + } + + // Check if user is suspended + if (userDetail?.isSuspended) { + throw new ApiError('Account suspended', 403); + } + + const token = generateToken(foundUser.id); + + const response: AuthResponse = { + token, + user: { + id: foundUser.id, + name: foundUser.name, + email: foundUser.email, + mobile: foundUser.mobile, + createdAt: foundUser.createdAt.toISOString(), + profileImage: profileImageSignedUrl, + bio: userDetail?.bio || null, + dateOfBirth: userDetail?.dateOfBirth || null, + gender: userDetail?.gender || null, + occupation: userDetail?.occupation || null, + }, + }; + + return { + success: true, + data: response, + }; + }), + + register: publicProcedure + .input(z.object({ + name: z.string().min(1, 'Name is required'), + email: z.string().email('Invalid email format'), + mobile: z.string().min(1, 'Mobile is required'), + password: z.string().min(1, 'Password is required'), + })) + .mutation(async ({ input }) => { + const { name, email, mobile, password }: RegisterRequest = input; + + if (!name || !email || !mobile || !password) { + throw new ApiError('All fields are required', 400); + } + + // Validate email format + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(email)) { + throw new ApiError('Invalid email format', 400); + } + + // Validate mobile format (Indian mobile numbers) + const cleanMobile = mobile.replace(/\D/g, ''); + if (cleanMobile.length !== 10 || !/^[6-9]/.test(cleanMobile)) { + throw new ApiError('Invalid mobile number', 400); + } + + // Check if email already exists + const [existingEmail] = await db + .select() + .from(users) + .where(eq(users.email, email.toLowerCase())) + .limit(1); + + if (existingEmail) { + throw new ApiError('Email already registered', 409); + } + + // Check if mobile already exists + const [existingMobile] = await db + .select() + .from(users) + .where(eq(users.mobile, cleanMobile)) + .limit(1); + + if (existingMobile) { + throw new ApiError('Mobile number already registered', 409); + } + + // Hash password + const hashedPassword = await bcrypt.hash(password, 12); + + // Create user and credentials in a transaction + const newUser = await db.transaction(async (tx) => { + // Create user + const [user] = await tx + .insert(users) + .values({ + name: name.trim(), + email: email.toLowerCase().trim(), + mobile: cleanMobile, + }) + .returning(); + + // Create user credentials + await tx + .insert(userCreds) + .values({ + userId: user.id, + userPassword: hashedPassword, + }); + + return user; + }); + + const token = generateToken(newUser.id); + + const response: AuthResponse = { + token, + user: { + id: newUser.id, + name: newUser.name, + email: newUser.email, + mobile: newUser.mobile, + createdAt: newUser.createdAt.toISOString(), + profileImage: null, + }, + }; + + return { + success: true, + data: response, + }; + }), + + sendOtp: publicProcedure + .input(z.object({ + mobile: z.string(), + })) + .mutation(async ({ input }) => { + + return await sendOtp(input.mobile); + }), + + verifyOtp: publicProcedure + .input(z.object({ + mobile: z.string(), + otp: z.string(), + })) + .mutation(async ({ input }) => { + const verificationId = getOtpCreds(input.mobile); + if (!verificationId) { + throw new ApiError("OTP not sent or expired", 400); + } + const isVerified = await verifyOtpUtil(input.mobile, input.otp, verificationId); + + if (!isVerified) { + throw new ApiError("Invalid OTP", 400); + } + + // Find user + let user = await db.query.users.findFirst({ + where: eq(users.mobile, input.mobile), + }); + + // If user doesn't exist, create one + if (!user) { + const [newUser] = await db + .insert(users) + .values({ + name: null, + email: null, + mobile: input.mobile, + }) + .returning(); + user = newUser; + } + + // Check if user is suspended (only if userDetails exists) + const [userDetail] = await db + .select() + .from(userDetails) + .where(eq(userDetails.userId, user.id)) + .limit(1); + + if (userDetail?.isSuspended) { + throw new ApiError('Account suspended', 403); + } + + // Generate JWT + const token = generateToken(user.id); + + return { + success: true, + token, + user: { + id: user.id, + name: user.name, + email: user.email, + mobile: user.mobile, + createdAt: user.createdAt.toISOString(), + profileImage: null, + }, + }; + }), + + updatePassword: protectedProcedure + .input(z.object({ + password: z.string().min(6, 'Password must be at least 6 characters'), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + const hashedPassword = await bcrypt.hash(input.password, 10); + + // Insert if not exists, then update if exists + try { + await db.insert(userCreds).values({ + userId: userId, + userPassword: hashedPassword, + }); + // Insert succeeded - new credentials created + } catch (error: any) { + // Insert failed - check if it's a unique constraint violation + if (error.code === '23505') { // PostgreSQL unique constraint violation + // Update existing credentials + await db.update(userCreds).set({ + userPassword: hashedPassword, + }).where(eq(userCreds.userId, userId)); + } else { + // Re-throw if it's a different error + throw error; + } + } + + return { success: true, message: 'Password updated successfully' }; + }), + + getProfile: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + const [user] = await db + .select() + .from(users) + .where(eq(users.id, userId)) + .limit(1); + + if (!user) { + throw new ApiError('User not found', 404); + } + + return { + success: true, + data: { + id: user.id, + name: user.name, + email: user.email, + mobile: user.mobile, + }, + }; + }), + + deleteAccount: protectedProcedure + .input(z.object({ + mobile: z.string().min(10, 'Mobile number is required'), + })) + .mutation(async ({ ctx, input }) => { + const userId = ctx.user.userId; + const { mobile } = input; + + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + // Double-check: verify user exists and is the authenticated user + const existingUser = await db.query.users.findFirst({ + where: eq(users.id, userId), + columns: { id: true, mobile: true }, + }); + + if (!existingUser) { + throw new ApiError('User not found', 404); + } + + // Additional verification: ensure we're not deleting someone else's data + // The JWT token should already ensure this, but double-checking + if (existingUser.id !== userId) { + throw new ApiError('Unauthorized: Cannot delete another user\'s account', 403); + } + + // Verify mobile number matches user's registered mobile + const cleanInputMobile = mobile.replace(/\D/g, ''); + const cleanUserMobile = existingUser.mobile?.replace(/\D/g, ''); + + if (cleanInputMobile !== cleanUserMobile) { + throw new ApiError('Mobile number does not match your registered number', 400); + } + + // Use transaction for atomic deletion + await db.transaction(async (tx) => { + // Phase 1: Direct references (safe to delete first) + await tx.delete(notifCreds).where(eq(notifCreds.userId, userId)); + await tx.delete(couponApplicableUsers).where(eq(couponApplicableUsers.userId, userId)); + await tx.delete(couponUsage).where(eq(couponUsage.userId, userId)); + await tx.delete(complaints).where(eq(complaints.userId, userId)); + await tx.delete(cartItems).where(eq(cartItems.userId, userId)); + await tx.delete(notifications).where(eq(notifications.userId, userId)); + await tx.delete(productReviews).where(eq(productReviews.userId, userId)); + + // Update reserved coupons (set redeemedBy to null) + await tx.update(reservedCoupons) + .set({ redeemedBy: null }) + .where(eq(reservedCoupons.redeemedBy, userId)); + + // Phase 2: Order dependencies + const userOrders = await tx + .select({ id: orders.id }) + .from(orders) + .where(eq(orders.userId, userId)); + + for (const order of userOrders) { + await tx.delete(orderItems).where(eq(orderItems.orderId, order.id)); + await tx.delete(orderStatus).where(eq(orderStatus.orderId, order.id)); + await tx.delete(payments).where(eq(payments.orderId, order.id)); + await tx.delete(refunds).where(eq(refunds.orderId, order.id)); + // Additional coupon usage entries linked to specific orders + await tx.delete(couponUsage).where(eq(couponUsage.orderId, order.id)); + await tx.delete(complaints).where(eq(complaints.orderId, order.id)); + } + + // Delete orders + await tx.delete(orders).where(eq(orders.userId, userId)); + + // Phase 3: Addresses (now safe since orders are deleted) + await tx.delete(addresses).where(eq(addresses.userId, userId)); + + // Phase 4: Core user data + await tx.delete(userDetails).where(eq(userDetails.userId, userId)); + await tx.delete(userCreds).where(eq(userCreds.userId, userId)); + await tx.delete(users).where(eq(users.id, userId)); + }); + + return { success: true, message: 'Account deleted successfully' }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/banners.ts b/apps/backend/src/trpc/user-apis/banners.ts new file mode 100644 index 0000000..beabbee --- /dev/null +++ b/apps/backend/src/trpc/user-apis/banners.ts @@ -0,0 +1,37 @@ +import { db } from '../../db/db_index'; +import { homeBanners } from '../../db/schema'; +import { publicProcedure, router } from '../trpc-index'; +import { generateSignedUrlFromS3Url } from '../../lib/s3-client'; +import { isNotNull, asc } from 'drizzle-orm'; + +export const bannerRouter = router({ + getBanners: publicProcedure + .query(async () => { + const banners = await db.query.homeBanners.findMany({ + where: isNotNull(homeBanners.serialNum), // Only show assigned banners + orderBy: asc(homeBanners.serialNum), // Order by slot number 1-4 + }); + + // Convert S3 keys to signed URLs for client + const bannersWithSignedUrls = await Promise.all( + banners.map(async (banner) => { + try { + return { + ...banner, + imageUrl: banner.imageUrl ? await generateSignedUrlFromS3Url(banner.imageUrl) : banner.imageUrl, + }; + } catch (error) { + console.error(`Failed to generate signed URL for banner ${banner.id}:`, error); + return { + ...banner, + imageUrl: banner.imageUrl, // Keep original on error + }; + } + }) + ); + + return { + banners: bannersWithSignedUrls, + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/cart.ts b/apps/backend/src/trpc/user-apis/cart.ts new file mode 100644 index 0000000..c4a8952 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/cart.ts @@ -0,0 +1,227 @@ +import { router, protectedProcedure, publicProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { cartItems, productInfo, units, productSlots, deliverySlotInfo } from '../../db/schema'; +import { eq, and, sql, inArray, gt } from 'drizzle-orm'; +import { ApiError } from '../../lib/api-error'; +import { generateSignedUrlsFromS3Urls } from '../../lib/s3-client'; + +interface CartResponse { + items: any[]; + totalItems: number; + totalAmount: number; +} + +const getCartData = async (userId: number): Promise => { + const cartItemsWithProducts = await db + .select({ + cartId: cartItems.id, + productId: productInfo.id, + productName: productInfo.name, + productPrice: productInfo.price, + productImages: productInfo.images, + productQuantity: productInfo.productQuantity, + isOutOfStock: productInfo.isOutOfStock, + unitShortNotation: units.shortNotation, + quantity: cartItems.quantity, + addedAt: cartItems.addedAt, + }) + .from(cartItems) + .innerJoin(productInfo, eq(cartItems.productId, productInfo.id)) + .innerJoin(units, eq(productInfo.unitId, units.id)) + .where(eq(cartItems.userId, userId)); + + // Generate signed URLs for images + const cartWithSignedUrls = await Promise.all( + cartItemsWithProducts.map(async (item) => ({ + id: item.cartId, + productId: item.productId, + quantity: parseFloat(item.quantity), + addedAt: item.addedAt, + product: { + id: item.productId, + name: item.productName, + price: item.productPrice, + productQuantity: item.productQuantity, + unit: item.unitShortNotation, + isOutOfStock: item.isOutOfStock, + images: await generateSignedUrlsFromS3Urls((item.productImages as string[]) || []), + }, + subtotal: parseFloat(item.productPrice.toString()) * parseFloat(item.quantity), + })) + ); + + const totalAmount = cartWithSignedUrls.reduce((sum, item) => sum + item.subtotal, 0); + + return { + items: cartWithSignedUrls, + totalItems: cartWithSignedUrls.length, + totalAmount, + }; +}; + +export const cartRouter = router({ + getCart: protectedProcedure + .query(async ({ ctx }): Promise => { + const userId = ctx.user.userId; + return await getCartData(userId); + }), + + addToCart: protectedProcedure + .input(z.object({ + productId: z.number().int().positive(), + quantity: z.number().int().positive(), + })) + .mutation(async ({ input, ctx }): Promise => { + const userId = ctx.user.userId; + const { productId, quantity } = input; + + // Validate input + if (!productId || !quantity || quantity <= 0) { + throw new ApiError("Product ID and positive quantity required", 400); + } + + // Check if product exists + const product = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, productId), + }); + + if (!product) { + throw new ApiError("Product not found", 404); + } + + // Check if item already exists in cart + const existingItem = await db.query.cartItems.findFirst({ + where: and(eq(cartItems.userId, userId), eq(cartItems.productId, productId)), + }); + + if (existingItem) { + // Update quantity + await db.update(cartItems) + .set({ + quantity: sql`${cartItems.quantity} + ${quantity}`, + }) + .where(eq(cartItems.id, existingItem.id)); + } else { + // Insert new item + await db.insert(cartItems).values({ + userId, + productId, + quantity: quantity.toString(), + }); + } + + // Return updated cart + return await getCartData(userId); + }), + + updateCartItem: protectedProcedure + .input(z.object({ + itemId: z.number().int().positive(), + quantity: z.number().int().min(0), + })) + .mutation(async ({ input, ctx }): Promise => { + const userId = ctx.user.userId; + const { itemId, quantity } = input; + + if (!quantity || quantity <= 0) { + throw new ApiError("Positive quantity required", 400); + } + + const [updatedItem] = await db.update(cartItems) + .set({ quantity: quantity.toString() }) + .where(and( + eq(cartItems.id, itemId), + eq(cartItems.userId, userId) + )) + .returning(); + + if (!updatedItem) { + throw new ApiError("Cart item not found", 404); + } + + // Return updated cart + return await getCartData(userId); + }), + + removeFromCart: protectedProcedure + .input(z.object({ + itemId: z.number().int().positive(), + })) + .mutation(async ({ input, ctx }): Promise => { + const userId = ctx.user.userId; + const { itemId } = input; + + const [deletedItem] = await db.delete(cartItems) + .where(and( + eq(cartItems.id, itemId), + eq(cartItems.userId, userId) + )) + .returning(); + + if (!deletedItem) { + throw new ApiError("Cart item not found", 404); + } + + // Return updated cart + return await getCartData(userId); + }), + + clearCart: protectedProcedure + .mutation(async ({ ctx }) => { + const userId = ctx.user.userId; + + await db.delete(cartItems).where(eq(cartItems.userId, userId)); + + return { + items: [], + totalItems: 0, + totalAmount: 0, + message: "Cart cleared successfully", + }; + }), + + getCartSlots: publicProcedure + .input(z.object({ + productIds: z.array(z.number().int().positive()) + })) + .query(async ({ input }) => { + const { productIds } = input; + + if (productIds.length === 0) { + return {}; + } + + // Get slots for these products where freeze time is after current time + const slotsData = await db + .select({ + productId: productSlots.productId, + slotId: deliverySlotInfo.id, + deliveryTime: deliverySlotInfo.deliveryTime, + freezeTime: deliverySlotInfo.freezeTime, + isActive: deliverySlotInfo.isActive, + }) + .from(productSlots) + .innerJoin(deliverySlotInfo, eq(productSlots.slotId, deliverySlotInfo.id)) + .where(and( + inArray(productSlots.productId, productIds), + gt(deliverySlotInfo.freezeTime, sql`NOW()`), + eq(deliverySlotInfo.isActive, true) + )); + + // Group by productId + const result: Record = {}; + slotsData.forEach(slot => { + if (!result[slot.productId]) { + result[slot.productId] = []; + } + result[slot.productId].push({ + id: slot.slotId, + deliveryTime: slot.deliveryTime, + freezeTime: slot.freezeTime, + }); + }); + + return result; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/complaint.ts b/apps/backend/src/trpc/user-apis/complaint.ts new file mode 100644 index 0000000..284d748 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/complaint.ts @@ -0,0 +1,63 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { complaints } from '../../db/schema'; +import { eq } from 'drizzle-orm'; + +export const complaintRouter = router({ + getAll: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + + const userComplaints = await db + .select({ + id: complaints.id, + complaintBody: complaints.complaintBody, + response: complaints.response, + isResolved: complaints.isResolved, + createdAt: complaints.createdAt, + orderId: complaints.orderId, + }) + .from(complaints) + .where(eq(complaints.userId, userId)) + .orderBy(complaints.createdAt); + + return { + complaints: userComplaints.map(c => ({ + id: c.id, + complaintBody: c.complaintBody, + response: c.response, + isResolved: c.isResolved, + createdAt: c.createdAt, + orderId: c.orderId, + })), + }; + }), + + raise: protectedProcedure + .input(z.object({ + orderId: z.string().optional(), + complaintBody: z.string().min(1, 'Complaint body is required'), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { orderId, complaintBody } = input; + + let orderIdNum: number | null = null; + + if (orderId) { + const readableIdMatch = orderId.match(/^ORD(\d+)$/); + if (readableIdMatch) { + orderIdNum = parseInt(readableIdMatch[1]); + } + } + + await db.insert(complaints).values({ + userId, + orderId: orderIdNum, + complaintBody: complaintBody.trim(), + }); + + return { success: true, message: 'Complaint raised successfully' }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/coupon.ts b/apps/backend/src/trpc/user-apis/coupon.ts new file mode 100644 index 0000000..d3a5555 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/coupon.ts @@ -0,0 +1,296 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { coupons, couponUsage, couponApplicableUsers, reservedCoupons, couponApplicableProducts } from '../../db/schema'; +import { eq, and, or, gt, isNull, sql } from 'drizzle-orm'; +import { ApiError } from 'src/lib/api-error'; + +import { users } from '../../db/schema'; + +type CouponWithRelations = typeof coupons.$inferSelect & { + applicableUsers: (typeof couponApplicableUsers.$inferSelect & { user: typeof users.$inferSelect })[]; + usages: typeof couponUsage.$inferSelect[]; +}; + +export interface EligibleCoupon { + id: number; + code: string; + discountType: 'percentage' | 'flat'; + discountValue: number; + maxValue?: number; + minOrder?: number; + description: string; + exclusiveApply?: boolean; + isEligible: boolean; + ineligibilityReason?: string; +} + +const generateCouponDescription = (coupon: any): string => { + let desc = ''; + + if (coupon.discountPercent) { + desc += `${coupon.discountPercent}% off`; + } else if (coupon.flatDiscount) { + desc += `₹${coupon.flatDiscount} off`; + } + + if (coupon.minOrder) { + desc += ` on orders above ₹${coupon.minOrder}`; + } + + if (coupon.maxValue) { + desc += ` (max discount ₹${coupon.maxValue})`; + } + + return desc; +}; + +export interface CouponDisplay { + id: number; + code: string; + discountType: 'percentage' | 'flat'; + discountValue: number; + maxValue?: number; + minOrder?: number; + description: string; + validTill?: Date; + usageCount: number; + maxLimitForUser?: number; + isExpired: boolean; + isUsedUp: boolean; +} + +export const userCouponRouter = router({ + getEligible: protectedProcedure + .query(async ({ ctx }) => { + try { + + const userId = ctx.user.userId; + + // Get all active, non-expired coupons + const allCoupons = await db.query.coupons.findMany({ + where: and( + eq(coupons.isInvalidated, false), + or( + isNull(coupons.validTill), + gt(coupons.validTill, new Date()) + ) + ), + with: { + usages: { + where: eq(couponUsage.userId, userId) + }, + applicableUsers: { + with: { + user: true + } + }, + applicableProducts: { + with: { + product: true + } + }, + } + }); + + // Filter to only coupons applicable to current user + const applicableCoupons = allCoupons.filter(coupon => { + if(!coupon.isUserBased) return true; + const applicableUsers = coupon.applicableUsers || []; + return applicableUsers.some(au => au.userId === userId); + }); + + return { success: true, data: applicableCoupons }; + } + catch(e) { + console.log(e) + throw new ApiError("Unable to get coupons") + } + }), + + getProductCoupons: protectedProcedure + .input(z.object({ productId: z.number().int().positive() })) + .query(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { productId } = input; + + // Get all active, non-expired coupons + const allCoupons = await db.query.coupons.findMany({ + where: and( + eq(coupons.isInvalidated, false), + or( + isNull(coupons.validTill), + gt(coupons.validTill, new Date()) + ) + ), + with: { + usages: { + where: eq(couponUsage.userId, userId) + }, + applicableUsers: { + with: { + user: true + } + }, + applicableProducts: { + with: { + product: true + } + }, + } + }); + + // Filter to only coupons applicable to current user and product + const applicableCoupons = allCoupons.filter(coupon => { + const applicableUsers = coupon.applicableUsers || []; + const userApplicable = !coupon.isUserBased || applicableUsers.some(au => au.userId === userId); + + const applicableProducts = coupon.applicableProducts || []; + const productApplicable = applicableProducts.length === 0 || applicableProducts.some(ap => ap.productId === productId); + + return userApplicable && productApplicable; + }); + + return { success: true, data: applicableCoupons }; + }), + + getMyCoupons: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + + // Get all coupons + const allCoupons = await db.query.coupons.findMany({ + with: { + usages: { + where: eq(couponUsage.userId, userId) + }, + applicableUsers: { + with: { + user: true + } + } + } + }); + + // Filter coupons in JS: not invalidated, applicable to user, and not expired + const applicableCoupons = (allCoupons as CouponWithRelations[]).filter(coupon => { + const isNotInvalidated = !coupon.isInvalidated; + const applicableUsers = coupon.applicableUsers || []; + const isApplicable = coupon.isApplyForAll || applicableUsers.some(au => au.userId === userId); + const isNotExpired = !coupon.validTill || new Date(coupon.validTill) > new Date(); + return isNotInvalidated && isApplicable && isNotExpired; + }); + + // Categorize coupons + const personalCoupons: CouponDisplay[] = []; + const generalCoupons: CouponDisplay[] = []; + + applicableCoupons.forEach(coupon => { + const usageCount = coupon.usages.length; + const isExpired = false; // Already filtered out expired coupons + const isUsedUp = Boolean(coupon.maxLimitForUser && usageCount >= coupon.maxLimitForUser); + + const couponDisplay: CouponDisplay = { + id: coupon.id, + code: coupon.couponCode, + discountType: coupon.discountPercent ? 'percentage' : 'flat', + discountValue: parseFloat(coupon.discountPercent || coupon.flatDiscount || '0'), + maxValue: coupon.maxValue ? parseFloat(coupon.maxValue) : undefined, + minOrder: coupon.minOrder ? parseFloat(coupon.minOrder) : undefined, + description: generateCouponDescription(coupon), + validTill: coupon.validTill ? new Date(coupon.validTill) : undefined, + usageCount, + maxLimitForUser: coupon.maxLimitForUser ? parseInt(coupon.maxLimitForUser.toString()) : undefined, + isExpired, + isUsedUp, + }; + + if ((coupon.applicableUsers || []).some(au => au.userId === userId) && !coupon.isApplyForAll) { + // Personal coupon + personalCoupons.push(couponDisplay); + } else if (coupon.isApplyForAll) { + // General coupon + generalCoupons.push(couponDisplay); + } + }); + + return { + success: true, + data: { + personal: personalCoupons, + general: generalCoupons, + } + }; + }), + + redeemReservedCoupon: protectedProcedure + .input(z.object({ secretCode: z.string() })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { secretCode } = input; + + // Find the reserved coupon + const reservedCoupon = await db.query.reservedCoupons.findFirst({ + where: and( + eq(reservedCoupons.secretCode, secretCode.toUpperCase()), + eq(reservedCoupons.isRedeemed, false) + ), + }); + + if (!reservedCoupon) { + throw new ApiError("Invalid or already redeemed coupon code", 400); + } + + // Check if already redeemed by this user (in case of multiple attempts) + if (reservedCoupon.redeemedBy === userId) { + throw new ApiError("You have already redeemed this coupon", 400); + } + + // Create the coupon in the main table + const couponResult = await db.transaction(async (tx) => { + // Insert into coupons + const couponInsert = await tx.insert(coupons).values({ + couponCode: reservedCoupon.couponCode, + isUserBased: true, + discountPercent: reservedCoupon.discountPercent, + flatDiscount: reservedCoupon.flatDiscount, + minOrder: reservedCoupon.minOrder, + productIds: reservedCoupon.productIds, + maxValue: reservedCoupon.maxValue, + isApplyForAll: false, + validTill: reservedCoupon.validTill, + maxLimitForUser: reservedCoupon.maxLimitForUser, + exclusiveApply: reservedCoupon.exclusiveApply, + createdBy: reservedCoupon.createdBy, + }).returning(); + + const coupon = couponInsert[0]; + + // Insert into couponApplicableUsers + await tx.insert(couponApplicableUsers).values({ + couponId: coupon.id, + userId, + }); + + // Copy applicable products + if (reservedCoupon.productIds && Array.isArray(reservedCoupon.productIds) && reservedCoupon.productIds.length > 0) { + // Assuming productIds are the IDs, but wait, in schema, productIds is jsonb, but in relations, couponApplicableProducts has productId + // For simplicity, since reservedCoupons has productIds as jsonb, but to match, perhaps insert into couponApplicableProducts if needed + // But in createReservedCoupon, I inserted applicableProducts into couponApplicableProducts + // So for reserved, perhaps do the same, but since it's jsonb, maybe not. + // For now, skip, as the coupon will have productIds in coupons table. + } + + // Update reserved coupon as redeemed + await tx.update(reservedCoupons).set({ + isRedeemed: true, + redeemedBy: userId, + redeemedAt: new Date(), + }).where(eq(reservedCoupons.id, reservedCoupon.id)); + + return coupon; + }); + + return { success: true, coupon: couponResult }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/file-upload.ts b/apps/backend/src/trpc/user-apis/file-upload.ts new file mode 100644 index 0000000..f5c5d9d --- /dev/null +++ b/apps/backend/src/trpc/user-apis/file-upload.ts @@ -0,0 +1,51 @@ +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { generateUploadUrl } from '../../lib/s3-client'; +import { ApiError } from '../../lib/api-error'; + +export const fileUploadRouter = router({ + generateUploadUrls: protectedProcedure + .input(z.object({ + contextString: z.enum(['review', 'product_info']), + mimeTypes: z.array(z.string()), + })) + .mutation(async ({ input }): Promise<{ uploadUrls: string[] }> => { + const { contextString, mimeTypes } = input; + + const uploadUrls: string[] = []; + const keys: string[] = []; + + for (const mimeType of mimeTypes) { + // Generate key based on context and mime type + let folder: string; + if (contextString === 'review') { + folder = 'review-images'; + } else if(contextString === 'product_info') { + folder = 'product-images'; + } else if(contextString === 'review_response') { + folder = 'review-response-images' + } else { + folder = ''; + } + + const extension = mimeType === 'image/jpeg' ? '.jpg' : + mimeType === 'image/png' ? '.png' : + mimeType === 'image/gif' ? '.gif' : '.jpg'; + const key = `${folder}/${Date.now()}${extension}`; + + try { + const uploadUrl = await generateUploadUrl(key, mimeType); + uploadUrls.push(uploadUrl); + keys.push(key); + + } catch (error) { + console.error('Error generating upload URL:', error); + throw new ApiError('Failed to generate upload URL', 500); + } + } + + return { uploadUrls }; + }), +}); + +export type FileUploadRouter = typeof fileUploadRouter; \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/order.ts b/apps/backend/src/trpc/user-apis/order.ts new file mode 100644 index 0000000..7582559 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/order.ts @@ -0,0 +1,972 @@ +import { router, protectedProcedure } from "../trpc-index"; +import { z } from "zod"; +import { db } from "../../db/db_index"; +import { + orders, + orderItems, + orderStatus, + addresses, + productInfo, + paymentInfoTable, + keyValStore, + coupons, + couponUsage, + payments, + cartItems, + refunds, + units, +} from "../../db/schema"; +import { eq, and, inArray, desc, gte, lte } from "drizzle-orm"; +import { generateSignedUrlsFromS3Urls } from "../../lib/s3-client"; +import { ApiError } from "../../lib/api-error"; +import { + sendOrderPlacedNotification, + sendOrderCancelledNotification, +} from "../../lib/notif-job"; +import { RazorpayPaymentService } from "../../lib/payments-utils"; +import { deliveryCharge, minOrderValue } from "../../lib/env-exporter"; +import { getNextDeliveryDate } from "../common-apis/common"; +import { CONST_KEYS, getConstant } from "../../lib/const-store"; + + +const validateAndGetCoupon = async ( + couponId: number | undefined, + userId: number, + totalAmount: number +) => { + if (!couponId) return null; + + const coupon = await db.query.coupons.findFirst({ + where: eq(coupons.id, couponId), + with: { + usages: { where: eq(couponUsage.userId, userId) }, + }, + }); + + if (!coupon) throw new ApiError("Invalid coupon", 400); + if (coupon.isInvalidated) + throw new ApiError("Coupon is no longer valid", 400); + if (coupon.validTill && new Date(coupon.validTill) < new Date()) + throw new ApiError("Coupon has expired", 400); + if ( + coupon.maxLimitForUser && + coupon.usages.length >= coupon.maxLimitForUser + ) + throw new ApiError("Coupon usage limit exceeded", 400); + if ( + coupon.minOrder && + parseFloat(coupon.minOrder.toString()) > totalAmount + ) + throw new ApiError( + "Order amount does not meet coupon minimum requirement", + 400 + ); + + return coupon; +}; + +const applyDiscountToOrder = ( + orderTotal: number, + totalAmount: number, + appliedCoupon: typeof coupons.$inferSelect | null, + proportion: number +) => { + let finalOrderTotal = orderTotal; + // const proportion = totalAmount / orderTotal; + if (appliedCoupon) { + if (appliedCoupon.discountPercent) { + const discount = Math.min( + (orderTotal * + parseFloat(appliedCoupon.discountPercent.toString())) / + 100, + appliedCoupon.maxValue + ? parseFloat(appliedCoupon.maxValue.toString()) * proportion + : Infinity + ); + finalOrderTotal -= discount; + } else if (appliedCoupon.flatDiscount) { + const discount = Math.min( + parseFloat(appliedCoupon.flatDiscount.toString()) * proportion, + appliedCoupon.maxValue + ? parseFloat(appliedCoupon.maxValue.toString()) * proportion + : finalOrderTotal + ); + finalOrderTotal -= discount; + } + } + + // let orderDeliveryCharge = 0; + // if (isFirstOrder && finalOrderTotal < minOrderValue) { + // orderDeliveryCharge = deliveryCharge; + // finalOrderTotal += deliveryCharge; + // } + + + return { finalOrderTotal, orderGroupProportion: proportion }; +}; + +const placeOrderUtil = async (params: { + userId: number; + selectedItems: Array<{ + productId: number; + quantity: number; + slotId: number | null; + }>; + addressId: number; + paymentMethod: "online" | "cod"; + couponId?: number; + userNotes?: string; + deliveryPrice?: number; + isFlash?: boolean; +}) => { + const { + userId, + selectedItems, + addressId, + paymentMethod, + couponId, + userNotes, + deliveryPrice, + } = params; + + const orderGroupId = `${Date.now()}-${userId}`; + // Validate address belongs to user + const address = await db.query.addresses.findFirst({ + where: and(eq(addresses.userId, userId), eq(addresses.id, addressId)), + }); + if (!address) { + throw new ApiError("Invalid address", 400); + } + + // Group items by slotId and validate products + const ordersBySlot = new Map< + number | null, + Array<{ + productId: number; + quantity: number; + slotId: number | null; + product: any; + }> + >(); + + for (const item of selectedItems) { + const product = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, item.productId), + }); + if (!product) { + throw new ApiError(`Product ${item.productId} not found`, 400); + } + + if (!ordersBySlot.has(item.slotId)) { + ordersBySlot.set(item.slotId, []); + } + ordersBySlot.get(item.slotId)!.push({ ...item, product }); + } + + // Validate flash delivery product availability if isFlash is true + if (params.isFlash) { + // Check if all products are flash-available (flashPrice is optional - fallback to regular price) + for (const item of selectedItems) { + const product = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, item.productId), + }); + if (!product?.isFlashAvailable) { + throw new ApiError(`Product ${item.productId} is not available for flash delivery`, 400); + } + // Note: flashPrice validation removed - frontend falls back to regular price if not set + } + } + + // Calculate total amount across all orders + let totalAmount = 0; + for (const [slotId, items] of ordersBySlot) { + const orderTotal = items.reduce( + (sum, item) => { + const itemPrice = params.isFlash + ? parseFloat((item.product.flashPrice || item.product.price).toString()) + : parseFloat(item.product.price.toString()); + return sum + itemPrice * item.quantity; + }, + 0 + ); + totalAmount += orderTotal; + } + + const appliedCoupon = await validateAndGetCoupon(couponId, userId, totalAmount); + + // Calculate and verify delivery charge + const expectedDeliveryCharge = + totalAmount < minOrderValue ? deliveryCharge : 0; + if ( + deliveryPrice !== undefined && + deliveryPrice !== expectedDeliveryCharge + ) { + throw new ApiError("Invalid delivery charge amount", 400); + } + + // Create orders in transaction + const createdOrders = await db.transaction(async (tx) => { + // Get and increment readable order ID counter + let currentReadableId = 1; + const existing = await tx.query.keyValStore.findFirst({ + where: eq(keyValStore.key, CONST_KEYS.readableOrderId), + }); + if (existing?.value != null) { + const storedValue = existing.value; + const parsedValue = typeof storedValue === 'number' + ? storedValue + : parseInt(String(storedValue), 10) || 0; + currentReadableId = parsedValue + 1; + } + + // Create shared payment info for all orders + let sharedPaymentInfoId: number | null = null; + if (paymentMethod === "online") { + const [paymentInfo] = await tx + .insert(paymentInfoTable) + .values({ + status: "pending", + gateway: "razorpay", + merchantOrderId: `multi_order_${Date.now()}`, + }) + .returning(); + sharedPaymentInfoId = paymentInfo.id; + } + + const createdOrders: any[] = []; + let isFirstOrder = true; + + // Create separate order for each slot group + for (const [slotId, items] of ordersBySlot) { + // Calculate order-specific total + const orderTotal = items.reduce( + (sum, item) => { + const itemPrice = params.isFlash + ? parseFloat((item.product.flashPrice || item.product.price).toString()) + : parseFloat(item.product.price.toString()); + return sum + itemPrice * item.quantity; + }, + 0 + ); + + const orderGroupProportion = orderTotal / totalAmount; + const { finalOrderTotal } = applyDiscountToOrder( + orderTotal, + totalAmount, + appliedCoupon, + orderGroupProportion + ); + + // const orderGroupProportion = orderTotal / totalAmount; + + // Create order record + const [order] = await tx + .insert(orders) + .values({ + userId, + addressId, + slotId: params.isFlash ? null : slotId, // No slot assignment for flash delivery + isCod: paymentMethod === "cod", + isOnlinePayment: paymentMethod === "online", + paymentInfoId: sharedPaymentInfoId, + totalAmount: finalOrderTotal.toString(), + deliveryCharge: isFirstOrder ? expectedDeliveryCharge.toString() : '0', + readableId: currentReadableId++, + userNotes: userNotes || null, + orderGroupId, + orderGroupProportion: orderGroupProportion.toString(), + isFlashDelivery: params.isFlash, + }) + .returning(); + + // Create order items + const orderItemsData = items.map((item) => ({ + orderId: order.id as number, + productId: item.productId, + quantity: item.quantity.toString(), + price: params.isFlash ? (item.product.flashPrice || item.product.price) : item.product.price, + discountedPrice: (params.isFlash ? (item.product.flashPrice || item.product.price) : item.product.price).toString(), + })); + + await tx.insert(orderItems).values(orderItemsData); + + // Create order status + await tx.insert(orderStatus).values({ + userId, + orderId: order.id as number, + paymentStatus: paymentMethod === "cod" ? "cod" : "pending", + }); + + createdOrders.push(order); + isFirstOrder = false; + } + + // Update readable ID counter + await tx + .insert(keyValStore) + .values({ + key: CONST_KEYS.readableOrderId, + value: currentReadableId, + }) + .onConflictDoUpdate({ + target: keyValStore.key, + set: { value: currentReadableId }, + }); + + // Create Razorpay order for online payments + if (paymentMethod === "online" && sharedPaymentInfoId) { + const razorpayOrder = await RazorpayPaymentService.createOrder( + sharedPaymentInfoId, + (totalAmount+expectedDeliveryCharge).toString() + ); + await RazorpayPaymentService.insertPaymentRecord( + sharedPaymentInfoId, + razorpayOrder, + tx + ); + } + + // Remove ordered items from cart + await tx.delete(cartItems).where( + and( + eq(cartItems.userId, userId), + inArray( + cartItems.productId, + selectedItems.map((item) => item.productId) + ) + ) + ); + + return createdOrders; + }); + + // Record single coupon usage if applied (regardless of number of orders) + if (appliedCoupon && createdOrders.length > 0) { + await db.insert(couponUsage).values({ + userId, + couponId: appliedCoupon.id, + orderId: createdOrders[0].id as number, // Use first order ID + orderItemId: null, + usedAt: new Date(), + }); + } + + // Send notifications for each order + for (const order of createdOrders) { + sendOrderPlacedNotification(userId, order.id.toString()); + } + + return { success: true, data: createdOrders }; +}; + +export const orderRouter = router({ + placeOrder: protectedProcedure + .input( + z.object({ + selectedItems: z.array( + z.object({ + productId: z.number().int().positive(), + quantity: z.number().int().positive(), + slotId: z.union([z.number().int(), z.null()]), + }) + ), + addressId: z.number().int().positive(), + paymentMethod: z.enum(["online", "cod"]), + couponId: z.number().int().positive().optional(), + userNotes: z.string().optional(), + deliveryPrice: z.number().min(0).optional(), + isFlashDelivery: z.boolean().optional().default(false), + }) + ) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { + selectedItems, + addressId, + paymentMethod, + couponId, + userNotes, + deliveryPrice, + isFlashDelivery, + } = input; + + // Check if flash delivery is enabled when placing a flash delivery order + if (isFlashDelivery) { + const isFlashDeliveryEnabled = await getConstant(CONST_KEYS.isFlashDeliveryEnabled); + if (!isFlashDeliveryEnabled) { + throw new ApiError("Flash delivery is currently unavailable. Please opt for scheduled delivery.", 403); + } + } + + let processedItems = selectedItems; + + // Handle flash delivery slot resolution + if (isFlashDelivery) { + // For flash delivery, set slotId to null (no specific slot assigned) + processedItems = selectedItems.map(item => ({ + ...item, + slotId: null as any, // Type override for flash delivery + })); + } + + console.log({isFlashDelivery, processedItems}) + + return await placeOrderUtil({ + userId, + selectedItems: processedItems, + addressId, + paymentMethod, + couponId, + userNotes, + deliveryPrice, + isFlash: isFlashDelivery, + }); + }), + + getOrders: protectedProcedure + .input( + z + .object({ + page: z.number().min(1).default(1), + pageSize: z.number().min(1).max(50).default(10), + }) + .optional() + ) + .query(async ({ input, ctx }) => { + const { page = 1, pageSize = 10 } = input || {}; + const userId = ctx.user.userId; + const offset = (page - 1) * pageSize; + + // Get total count for pagination + const totalCountResult = await db.$count( + orders, + eq(orders.userId, userId) + ); + const totalCount = totalCountResult; + + const userOrders = await db.query.orders.findMany({ + where: eq(orders.userId, userId), + with: { + orderItems: { + with: { + product: true, + }, + }, + slot: true, + paymentInfo: true, + orderStatus: true, + refunds: true, + }, + orderBy: (orders, { desc }) => [desc(orders.createdAt)], + limit: pageSize, + offset: offset, + }); + + const mappedOrders = await Promise.all( + userOrders.map(async (order) => { + const status = order.orderStatus[0]; + const refund = order.refunds[0]; + + type DeliveryStatus = "cancelled" | "success" | "pending" | "packaged"; + type OrderStatus = "cancelled" | "success"; + + let deliveryStatus: DeliveryStatus; + let orderStatus: OrderStatus; + + const allItemsPackaged = order.orderItems.every( + (item) => item.is_packaged + ); + + if (status?.isCancelled) { + deliveryStatus = "cancelled"; + orderStatus = "cancelled"; + } else if (status?.isDelivered) { + deliveryStatus = "success"; + orderStatus = "success"; + } else if (allItemsPackaged) { + deliveryStatus = "packaged"; + orderStatus = "success"; + } else { + deliveryStatus = "pending"; + orderStatus = "success"; + } + + const paymentMode = order.isCod ? "CoD" : "Online"; + const paymentStatus = status?.paymentStatus || "pending"; + const refundStatus = refund?.refundStatus || "none"; + const refundAmount = refund?.refundAmount + ? parseFloat(refund.refundAmount.toString()) + : null; + + const items = await Promise.all( + order.orderItems.map(async (item) => { + + const signedImages = item.product.images + ? await generateSignedUrlsFromS3Urls( + item.product.images as string[] + ) + : []; + return { + productName: item.product.name, + quantity: parseFloat(item.quantity), + price: parseFloat(item.price.toString()), + discountedPrice: parseFloat( + item.discountedPrice?.toString() || item.price.toString() + ), + amount: + parseFloat(item.price.toString()) * parseFloat(item.quantity), + image: signedImages[0] || null, + }; + }) + ); + + return { + id: order.id, + orderId: `ORD${order.readableId.toString().padStart(3, "0")}`, + orderDate: order.createdAt.toISOString(), + deliveryStatus, + deliveryDate: order.slot?.deliveryTime.toISOString(), + orderStatus, + cancelReason: status?.cancelReason || null, + paymentMode, + totalAmount: Number(order.totalAmount), + deliveryCharge: Number(order.deliveryCharge), + paymentStatus, + refundStatus, + refundAmount, + userNotes: order.userNotes || null, + items, + isFlashDelivery: order.isFlashDelivery, + createdAt: order.createdAt.toISOString(), + }; + }) + ); + + return { + success: true, + data: mappedOrders, + pagination: { + page, + pageSize, + totalCount, + totalPages: Math.ceil(totalCount / pageSize), + }, + }; + }), + + getOrderById: protectedProcedure + .input(z.object({ orderId: z.string() })) + .query(async ({ input, ctx }) => { + const { orderId } = input; + const userId = ctx.user.userId; + + const order = await db.query.orders.findFirst({ + where: and(eq(orders.id, parseInt(orderId)), eq(orders.userId, userId)), + with: { + orderItems: { + with: { + product: true, + }, + }, + slot: true, + paymentInfo: true, + orderStatus: { + with: { + refundCoupon: true, + }, + }, + refunds: true, + }, + }); + + if (!order) { + throw new Error("Order not found"); + } + + // Get coupon usage for this specific order using new orderId field + const couponUsageData = await db.query.couponUsage.findMany({ + where: eq(couponUsage.orderId, order.id), // Use new orderId field + with: { + coupon: true, + }, + }); + + let couponData = null; + if (couponUsageData.length > 0) { + // Calculate total discount from multiple coupons + let totalDiscountAmount = 0; + const orderTotal = parseFloat(order.totalAmount.toString()); + + for (const usage of couponUsageData) { + let discountAmount = 0; + + if (usage.coupon.discountPercent) { + discountAmount = + (orderTotal * + parseFloat(usage.coupon.discountPercent.toString())) / + 100; + } else if (usage.coupon.flatDiscount) { + discountAmount = parseFloat(usage.coupon.flatDiscount.toString()); + } + + // Apply max value limit if set + if ( + usage.coupon.maxValue && + discountAmount > parseFloat(usage.coupon.maxValue.toString()) + ) { + discountAmount = parseFloat(usage.coupon.maxValue.toString()); + } + + totalDiscountAmount += discountAmount; + } + + couponData = { + couponCode: couponUsageData + .map((u) => u.coupon.couponCode) + .join(", "), + couponDescription: `${couponUsageData.length} coupons applied`, + discountAmount: totalDiscountAmount, + }; + } + + const status = order.orderStatus[0]; + const refund = order.refunds[0]; + + type DeliveryStatus = "cancelled" | "success" | "pending" | "packaged"; + type OrderStatus = "cancelled" | "success"; + + let deliveryStatus: DeliveryStatus; + let orderStatus: OrderStatus; + + const allItemsPackaged = order.orderItems.every( + (item) => item.is_packaged + ); + + if (status?.isCancelled) { + deliveryStatus = "cancelled"; + orderStatus = "cancelled"; + } else if (status?.isDelivered) { + deliveryStatus = "success"; + orderStatus = "success"; + } else if (allItemsPackaged) { + deliveryStatus = "packaged"; + orderStatus = "success"; + } else { + deliveryStatus = "pending"; + orderStatus = "success"; + } + + const paymentMode = order.isCod ? "CoD" : "Online"; + const paymentStatus = status?.paymentStatus || "pending"; + const refundStatus = refund?.refundStatus || "none"; + const refundAmount = refund?.refundAmount + ? parseFloat(refund.refundAmount.toString()) + : null; + + const items = await Promise.all( + order.orderItems.map(async (item) => { + const signedImages = item.product.images + ? await generateSignedUrlsFromS3Urls( + item.product.images as string[] + ) + : []; + return { + productName: item.product.name, + quantity: parseFloat(item.quantity), + price: parseFloat(item.price.toString()), + discountedPrice: parseFloat( + item.discountedPrice?.toString() || item.price.toString() + ), + amount: + parseFloat(item.price.toString()) * parseFloat(item.quantity), + image: signedImages[0] || null, + }; + }) + ); + + return { + id: order.id, + orderId: `ORD${order.readableId.toString().padStart(3, "0")}`, + orderDate: order.createdAt.toISOString(), + deliveryStatus, + deliveryDate: order.slot?.deliveryTime.toISOString(), + orderStatus: order.orderStatus, + cancellationStatus: orderStatus, + cancelReason: status?.cancelReason || null, + paymentMode, + paymentStatus, + refundStatus, + refundAmount, + userNotes: order.userNotes || null, + items, + couponCode: couponData?.couponCode || null, + couponDescription: couponData?.couponDescription || null, + discountAmount: couponData?.discountAmount || null, + orderAmount: parseFloat(order.totalAmount.toString()), + isFlashDelivery: order.isFlashDelivery, + createdAt: order.createdAt.toISOString(), + }; + }), + + cancelOrder: protectedProcedure + .input( + z.object({ + // id: z.string().regex(/^ORD\d+$/, "Invalid order ID format"), + id: z.string(), + reason: z.string().min(1, "Cancellation reason is required"), + }) + ) + .mutation(async ({ input, ctx }) => { + try { + const userId = ctx.user.userId; + const { id, reason } = input; + + const readableId = Number(id); + + // Check if order exists and belongs to user + const order = await db.query.orders.findFirst({ + where: eq(orders.id, Number(id)), + with: { + orderStatus: true, + }, + }); + + if (!order) { + console.error("Order not found:", id); + throw new ApiError("Order not found", 404); + } + + if (order.userId !== userId) { + console.error("Order does not belong to user:", { + orderId: id, + orderUserId: order.userId, + requestUserId: userId, + }); + + throw new ApiError("Order not found", 404); + } + + const status = order.orderStatus[0]; + if (!status) { + console.error("Order status not found for order:", id); + throw new ApiError("Order status not found", 400); + } + + if (status.isCancelled) { + console.error("Order is already cancelled:", id); + throw new ApiError("Order is already cancelled", 400); + } + + if (status.isDelivered) { + console.error("Cannot cancel delivered order:", id); + throw new ApiError("Cannot cancel delivered order", 400); + } + + // Perform database operations in transaction + const result = await db.transaction(async (tx) => { + // Update order status + await tx + .update(orderStatus) + .set({ + isCancelled: true, + cancelReason: reason, + cancellationUserNotes: reason, + cancellationReviewed: false, + }) + .where(eq(orderStatus.id, status.id)); + + // Determine refund status based on payment method + const refundStatus = order.isCod ? "na" : "pending"; + + // Insert refund record + await tx.insert(refunds).values({ + orderId: order.id, + refundStatus, + }); + + return { orderId: order.id, userId }; + }); + + // Send notification outside transaction (idempotent operation) + await sendOrderCancelledNotification( + result.userId, + result.orderId.toString() + ); + + return { success: true, message: "Order cancelled successfully" }; + } catch (e) { + console.log(e); + throw new ApiError("failed to cancel order"); + } + }), + + updateUserNotes: protectedProcedure + .input( + z.object({ + id: z.string(), + userNotes: z.string(), + }) + ) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { id, userNotes } = input; + + // Extract readable ID from orderId (e.g., ORD001 -> 1) + // const readableIdMatch = id.match(/^ORD(\d+)$/); + // if (!readableIdMatch) { + // console.error("Invalid order ID format:", id); + // throw new ApiError("Invalid order ID format", 400); + // } + // const readableId = parseInt(readableIdMatch[1]); + + // Check if order exists and belongs to user + const order = await db.query.orders.findFirst({ + where: eq(orders.id, Number(id)), + with: { + orderStatus: true, + }, + }); + + if (!order) { + console.error("Order not found:", id); + throw new ApiError("Order not found", 404); + } + + if (order.userId !== userId) { + console.error("Order does not belong to user:", { + orderId: id, + orderUserId: order.userId, + requestUserId: userId, + }); + throw new ApiError("Order not found", 404); + } + + const status = order.orderStatus[0]; + if (!status) { + console.error("Order status not found for order:", id); + throw new ApiError("Order status not found", 400); + } + + // Only allow updating notes for orders that are not delivered or cancelled + if (status.isDelivered) { + console.error("Cannot update notes for delivered order:", id); + throw new ApiError("Cannot update notes for delivered order", 400); + } + + if (status.isCancelled) { + console.error("Cannot update notes for cancelled order:", id); + throw new ApiError("Cannot update notes for cancelled order", 400); + } + + // Update user notes + await db + .update(orders) + .set({ + userNotes: userNotes || null, + }) + .where(eq(orders.id, order.id)); + + return { success: true, message: "Notes updated successfully" }; + }), + + getRecentlyOrderedProducts: protectedProcedure + .input( + z + .object({ + limit: z.number().min(1).max(50).default(20), + }) + .optional() + ) + .query(async ({ input, ctx }) => { + const { limit = 20 } = input || {}; + const userId = ctx.user.userId; + + // Get user's recent delivered orders (last 30 days) + const thirtyDaysAgo = new Date(); + thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); + + const recentOrders = await db + .select({ id: orders.id }) + .from(orders) + .innerJoin(orderStatus, eq(orders.id, orderStatus.orderId)) + .where( + and( + eq(orders.userId, userId), + eq(orderStatus.isDelivered, true), + gte(orders.createdAt, thirtyDaysAgo) + ) + ) + .orderBy(desc(orders.createdAt)) + .limit(10); // Get last 10 orders + + if (recentOrders.length === 0) { + return { success: true, products: [] }; + } + + const orderIds = recentOrders.map((order) => order.id); + + // Get unique product IDs from recent orders + const orderItemsResult = await db + .select({ productId: orderItems.productId }) + .from(orderItems) + .where(inArray(orderItems.orderId, orderIds)); + + const productIds = [ + ...new Set(orderItemsResult.map((item) => item.productId)), + ]; + + if (productIds.length === 0) { + return { success: true, products: [] }; + } + + // Get product details + const productsWithUnits = await db + .select({ + id: productInfo.id, + name: productInfo.name, + shortDescription: productInfo.shortDescription, + price: productInfo.price, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + unitShortNotation: units.shortNotation, + incrementStep: productInfo.incrementStep, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)) + .where( + and( + inArray(productInfo.id, productIds), + eq(productInfo.isSuspended, false) + ) + ) + .orderBy(desc(productInfo.createdAt)) + .limit(limit); + + // Generate signed URLs for product images + const formattedProducts = await Promise.all( + productsWithUnits.map(async (product) => { + const nextDeliveryDate = await getNextDeliveryDate(product.id); + return { + id: product.id, + name: product.name, + shortDescription: product.shortDescription, + price: product.price, + unit: product.unitShortNotation, + incrementStep: product.incrementStep, + isOutOfStock: product.isOutOfStock, + nextDeliveryDate: nextDeliveryDate + ? nextDeliveryDate.toISOString() + : null, + images: await generateSignedUrlsFromS3Urls( + (product.images as string[]) || [] + ), + }; + }) + ); + + return { + success: true, + products: formattedProducts, + }; + }), +}); diff --git a/apps/backend/src/trpc/user-apis/payments.ts b/apps/backend/src/trpc/user-apis/payments.ts new file mode 100644 index 0000000..851f232 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/payments.ts @@ -0,0 +1,159 @@ + +import { router, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { orders, payments, orderStatus } from '../../db/schema'; +import { eq } from 'drizzle-orm'; +import { ApiError } from '../../lib/api-error'; +import crypto from 'crypto'; +import { razorpayId, razorpaySecret } from "../../lib/env-exporter"; +import { DiskPersistedSet } from "src/lib/disk-persisted-set"; +import { RazorpayPaymentService } from "../../lib/payments-utils"; + + + + +export const paymentRouter = router({ + createRazorpayOrder: protectedProcedure //either create a new payment order or return the existing one + .input(z.object({ + orderId: z.string(), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { orderId } = input; + + // Validate order exists and belongs to user + const order = await db.query.orders.findFirst({ + where: eq(orders.id, parseInt(orderId)), + }); + + if (!order) { + throw new ApiError("Order not found", 404); + } + + if (order.userId !== userId) { + throw new ApiError("Order does not belong to user", 403); + } + + // Check for existing pending payment + const existingPayment = await db.query.payments.findFirst({ + where: eq(payments.orderId, parseInt(orderId)), + }); + + if (existingPayment && existingPayment.status === 'pending') { + return { + razorpayOrderId: existingPayment.merchantOrderId, + key: razorpayId, + }; + } + + // Create Razorpay order and insert payment record + const razorpayOrder = await RazorpayPaymentService.createOrder(parseInt(orderId), order.totalAmount); + await RazorpayPaymentService.insertPaymentRecord(parseInt(orderId), razorpayOrder); + + return { + razorpayOrderId: razorpayOrder.id, + key: razorpayId, + }; + }), + + + + verifyPayment: protectedProcedure + .input(z.object({ + razorpay_payment_id: z.string(), + razorpay_order_id: z.string(), + razorpay_signature: z.string(), + })) + .mutation(async ({ input, ctx }) => { + const { razorpay_payment_id, razorpay_order_id, razorpay_signature } = input; + + // Verify signature + const expectedSignature = crypto + .createHmac('sha256', razorpaySecret) + .update(razorpay_order_id + '|' + razorpay_payment_id) + .digest('hex'); + + if (expectedSignature !== razorpay_signature) { + throw new ApiError("Invalid payment signature", 400); + } + + // Get current payment record + const currentPayment = await db.query.payments.findFirst({ + where: eq(payments.merchantOrderId, razorpay_order_id), + }); + + if (!currentPayment) { + throw new ApiError("Payment record not found", 404); + } + + // Update payment status and payload + const updatedPayload = { + ...((currentPayment.payload as any) || {}), + payment_id: razorpay_payment_id, + signature: razorpay_signature, + }; + + const [updatedPayment] = await db + .update(payments) + .set({ + status: 'success', + payload: updatedPayload, + }) + .where(eq(payments.merchantOrderId, razorpay_order_id)) + .returning(); + + // Update order status to mark payment as processed + await db + .update(orderStatus) + .set({ + paymentStatus: 'success', + }) + .where(eq(orderStatus.orderId, updatedPayment.orderId)); + + return { + success: true, + message: "Payment verified successfully", + }; + }), + + markPaymentFailed: protectedProcedure + .input(z.object({ + merchantOrderId: z.string(), + })) + .mutation(async ({ input, ctx }) => { + const userId = ctx.user.userId; + const { merchantOrderId } = input; + + // Find payment by merchantOrderId + const payment = await db.query.payments.findFirst({ + where: eq(payments.merchantOrderId, merchantOrderId), + }); + + if (!payment) { + throw new ApiError("Payment not found", 404); + } + + // Check if payment belongs to user's order + const order = await db.query.orders.findFirst({ + where: eq(orders.id, payment.orderId), + }); + + if (!order || order.userId !== userId) { + throw new ApiError("Payment does not belong to user", 403); + } + + // Update payment status to failed + await db + .update(payments) + .set({ status: 'failed' }) + .where(eq(payments.id, payment.id)); + + return { + success: true, + message: "Payment marked as failed", + }; + }), + +}); + diff --git a/apps/backend/src/trpc/user-apis/product.ts b/apps/backend/src/trpc/user-apis/product.ts new file mode 100644 index 0000000..d1380a1 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/product.ts @@ -0,0 +1,349 @@ +import { router, publicProcedure, protectedProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { productInfo, units, productSlots, deliverySlotInfo, specialDeals, storeInfo, productTagInfo, productTags, productReviews, users } from '../../db/schema'; +import { generateSignedUrlsFromS3Urls, generateSignedUrlFromS3Url, generateUploadUrl, claimUploadUrl, extractKeyFromPresignedUrl } from '../../lib/s3-client'; +import { ApiError } from '../../lib/api-error'; +import { eq, and, gt, sql, inArray, desc } from 'drizzle-orm'; + +export const productRouter = router({ + getDashboardTags: publicProcedure + .query(async () => { + const tags = await db + .select() + .from(productTagInfo) + .where(eq(productTagInfo.isDashboardTag, true)) + .orderBy(productTagInfo.tagName); + + // Generate signed URLs for tag images + const tagsWithSignedUrls = await Promise.all( + tags.map(async (tag) => ({ + ...tag, + imageUrl: tag.imageUrl ? await generateSignedUrlFromS3Url(tag.imageUrl) : null, + })) + ); + + return { + tags: tagsWithSignedUrls, + }; + }), + + getProductDetails: publicProcedure + .input(z.object({ + id: z.string().regex(/^\d+$/, 'Invalid product ID'), + })) + .query(async ({ input }) => { + const { id } = input; + const productId = parseInt(id); + + if (isNaN(productId)) { + throw new Error('Invalid product ID'); + } + + // Fetch product with unit information + const productData = await db + .select({ + id: productInfo.id, + name: productInfo.name, + shortDescription: productInfo.shortDescription, + longDescription: productInfo.longDescription, + price: productInfo.price, + marketPrice: productInfo.marketPrice, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + storeId: productInfo.storeId, + unitShortNotation: units.shortNotation, + isFlashAvailable: productInfo.isFlashAvailable, + flashPrice: productInfo.flashPrice, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)) + .where(eq(productInfo.id, productId)) + .limit(1); + + if (productData.length === 0) { + throw new Error('Product not found'); + } + + const product = productData[0]; + + // Fetch store info for this product + const storeData = product.storeId ? await db.query.storeInfo.findFirst({ + where: eq(storeInfo.id, product.storeId), + columns: { id: true, name: true, description: true }, + }) : null; + + // Fetch delivery slots for this product + const deliverySlotsData = await db + .select({ + id: deliverySlotInfo.id, + deliveryTime: deliverySlotInfo.deliveryTime, + freezeTime: deliverySlotInfo.freezeTime, + }) + .from(productSlots) + .innerJoin(deliverySlotInfo, eq(productSlots.slotId, deliverySlotInfo.id)) + .where( + and( + eq(productSlots.productId, productId), + eq(deliverySlotInfo.isActive, true), + gt(deliverySlotInfo.deliveryTime, sql`NOW()`) + ) + ) + .orderBy(deliverySlotInfo.deliveryTime); + + // Fetch special deals for this product + const specialDealsData = await db + .select({ + quantity: specialDeals.quantity, + price: specialDeals.price, + validTill: specialDeals.validTill, + }) + .from(specialDeals) + .where( + and( + eq(specialDeals.productId, productId), + gt(specialDeals.validTill, sql`NOW()`) + ) + ) + .orderBy(specialDeals.quantity); + + // Generate signed URLs for images + const signedImages = await generateSignedUrlsFromS3Urls((product.images as string[]) || []); + + const response = { + id: product.id, + name: product.name, + shortDescription: product.shortDescription, + longDescription: product.longDescription, + price: product.price, + marketPrice: product.marketPrice, + unit: product.unitShortNotation, + images: signedImages, + isOutOfStock: product.isOutOfStock, + isFlashAvailable: product.isFlashAvailable, + flashPrice: product.flashPrice, + store: storeData ? { + id: storeData.id, + name: storeData.name, + description: storeData.description, + } : null, + deliverySlots: deliverySlotsData, + specialPackageDeals: specialDealsData, + }; + + return response; + }), + + getProductReviews: publicProcedure + .input(z.object({ + productId: z.number().int().positive(), + limit: z.number().int().min(1).max(50).optional().default(10), + offset: z.number().int().min(0).optional().default(0), + })) + .query(async ({ input }) => { + const { productId, limit, offset } = input; + + const reviews = await db + .select({ + id: productReviews.id, + reviewBody: productReviews.reviewBody, + ratings: productReviews.ratings, + imageUrls: productReviews.imageUrls, + reviewTime: productReviews.reviewTime, + userName: users.name, + }) + .from(productReviews) + .innerJoin(users, eq(productReviews.userId, users.id)) + .where(eq(productReviews.productId, productId)) + .orderBy(desc(productReviews.reviewTime)) + .limit(limit) + .offset(offset); + + // Generate signed URLs for images + const reviewsWithSignedUrls = await Promise.all( + reviews.map(async (review) => ({ + ...review, + signedImageUrls: await generateSignedUrlsFromS3Urls((review.imageUrls as string[]) || []), + })) + ); + + // Check if more reviews exist + const totalCountResult = await db + .select({ count: sql`count(*)` }) + .from(productReviews) + .where(eq(productReviews.productId, productId)); + + const totalCount = Number(totalCountResult[0].count); + const hasMore = offset + limit < totalCount; + + return { reviews: reviewsWithSignedUrls, hasMore }; + }), + + createReview: protectedProcedure + .input(z.object({ + productId: z.number().int().positive(), + reviewBody: z.string().min(1, 'Review body is required'), + ratings: z.number().int().min(1).max(5), + imageUrls: z.array(z.string()).optional().default([]), + uploadUrls: z.array(z.string()).optional().default([]), + })) + .mutation(async ({ input, ctx }) => { + const { productId, reviewBody, ratings, imageUrls, uploadUrls } = input; + const userId = ctx.user.userId; + + // Optional: Check if product exists + const product = await db.query.productInfo.findFirst({ + where: eq(productInfo.id, productId), + }); + if (!product) { + throw new ApiError('Product not found', 404); + } + + // Insert review + const [newReview] = await db.insert(productReviews).values({ + userId, + productId, + reviewBody, + ratings, + imageUrls: uploadUrls.map(item => extractKeyFromPresignedUrl(item)), + }).returning(); + + // Claim upload URLs + if (uploadUrls && uploadUrls.length > 0) { + try { + await Promise.all(uploadUrls.map(url => claimUploadUrl(url))); + } catch (error) { + console.error('Error claiming upload URLs:', error); + // Don't fail the review creation + } + } + + return { success: true, review: newReview }; + }), + + getAllProductsSummary: publicProcedure + .query(async () => { + const products = await db + .select({ + id: productInfo.id, + name: productInfo.name, + price: productInfo.price, + marketPrice: productInfo.marketPrice, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + storeId: productInfo.storeId, + unitShortNotation: units.shortNotation, + incrementStep: productInfo.incrementStep, + isFlashAvailable: productInfo.isFlashAvailable, + flashPrice: productInfo.flashPrice, + productQuantity: productInfo.productQuantity, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)); + + // Generate signed URLs for images + const productsWithSignedUrls = await Promise.all( + products.map(async (product) => ({ + id: product.id, + name: product.name, + price: product.price, + marketPrice: product.marketPrice, + unit: product.unitShortNotation, + isOutOfStock: product.isOutOfStock, + storeId: product.storeId, + images: await generateSignedUrlsFromS3Urls((product.images as string[]) || []), + incrementStep: product.incrementStep, + isFlashAvailable: product.isFlashAvailable, + flashPrice: product.flashPrice, + productQuantity: product.productQuantity, + })) + ); + + return productsWithSignedUrls; + }), + + productMega: publicProcedure + .query(async () => { + // Fetch all products with unit info + const productsData = await db + .select({ + id: productInfo.id, + name: productInfo.name, + shortDescription: productInfo.shortDescription, + longDescription: productInfo.longDescription, + price: productInfo.price, + marketPrice: productInfo.marketPrice, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + storeId: productInfo.storeId, + unitShortNotation: units.shortNotation, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)); + + // Fetch all stores + const allStores = await db.query.storeInfo.findMany({ + columns: { id: true, name: true, description: true }, + }); + const storeMap = new Map(allStores.map(s => [s.id, s])); + + // Fetch all delivery slots for all products + const allDeliverySlots = await db + .select({ + productId: productSlots.productId, + id: deliverySlotInfo.id, + deliveryTime: deliverySlotInfo.deliveryTime, + freezeTime: deliverySlotInfo.freezeTime, + }) + .from(productSlots) + .innerJoin(deliverySlotInfo, eq(productSlots.slotId, deliverySlotInfo.id)) + .where( + and( + eq(deliverySlotInfo.isActive, true), + gt(deliverySlotInfo.deliveryTime, sql`NOW()`) + ) + ) + .orderBy(deliverySlotInfo.deliveryTime); + + // Group by productId + const deliverySlotsMap = new Map(); + for (const slot of allDeliverySlots) { + if (!deliverySlotsMap.has(slot.productId)) { + deliverySlotsMap.set(slot.productId, []); + } + deliverySlotsMap.get(slot.productId)!.push(slot); + } + + + + // Build the response + const response = await Promise.all( + productsData.map(async (product) => { + const signedImages = await generateSignedUrlsFromS3Urls((product.images as string[]) || []); + const store = product.storeId ? storeMap.get(product.storeId) || null : null; + const deliverySlots = deliverySlotsMap.get(product.id) || []; + + return { + id: product.id, + name: product.name, + shortDescription: product.shortDescription, + longDescription: product.longDescription, + price: product.price, + marketPrice: product.marketPrice, + unit: product.unitShortNotation, + images: signedImages, + isOutOfStock: product.isOutOfStock, + store: store ? { + id: store.id, + name: store.name, + description: store.description, + } : null, + deliverySlots: deliverySlots.map(s => ({ id: s.id, deliveryTime: s.deliveryTime, freezeTime: s.freezeTime })), + specialPackageDeals: [], // Empty since not fetching + }; + }) + ); + + return response; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/slots.ts b/apps/backend/src/trpc/user-apis/slots.ts new file mode 100644 index 0000000..c0511a8 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/slots.ts @@ -0,0 +1,148 @@ +import { router, publicProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { deliverySlotInfo, productSlots, productInfo, units } from '../../db/schema'; +import { eq, and, gt, asc } from 'drizzle-orm'; +import { generateSignedUrlsFromS3Urls } from '../../lib/s3-client'; + +// Helper method to get formatted slot data by ID +async function getSlotData(slotId: number) { + const slot = await db.query.deliverySlotInfo.findFirst({ + where: eq(deliverySlotInfo.id, slotId), + with: { + productSlots: { + with: { + product: { + with: { + unit: true, + store: true, + }, + }, + }, + }, + }, + }); + + if (!slot) { + return null; // Slot not found + } + + // Filter out out-of-stock products and format to match home page display structure + const products = await Promise.all( + slot.productSlots + .filter(productSlot => !productSlot.product.isOutOfStock) + .map(async (productSlot) => ({ + id: productSlot.product.id, + name: productSlot.product.name, + price: productSlot.product.price, + unit: productSlot.product.unit?.shortNotation || 'unit', + images: await generateSignedUrlsFromS3Urls( + (productSlot.product.images as string[]) || [] + ), + isOutOfStock: productSlot.product.isOutOfStock, + storeId: productSlot.product.storeId, + nextDeliveryDate: slot.deliveryTime, // For home page compatibility + })) + ); + + return { + deliveryTime: slot.deliveryTime, + freezeTime: slot.freezeTime, + slotId: slot.id, + products, + }; +} + +export const slotsRouter = router({ + getSlots: publicProcedure + .query(async () => { + const slots = await db.query.deliverySlotInfo.findMany({ + where: eq(deliverySlotInfo.isActive, true), + }); + return { + slots, + count: slots.length, + }; + }), + + getSlotsWithProducts: publicProcedure + .query(async () => { + const now = new Date(); + + // Fetch active delivery slots with future delivery times + const slots = await db.query.deliverySlotInfo.findMany({ + where: and( + eq(deliverySlotInfo.isActive, true), + gt(deliverySlotInfo.deliveryTime, now) // Only future slots + ), + with: { + productSlots: { + with: { + product: { + with: { + unit: true, + }, + }, + }, + }, + }, + orderBy: asc(deliverySlotInfo.deliveryTime), + }); + + // Transform data for frontend + const slotsWithProducts = await Promise.all( + slots.map(async (slot) => ({ + id: slot.id, + deliveryTime: slot.deliveryTime, + freezeTime: slot.freezeTime, + isActive: slot.isActive, + products: await Promise.all( + slot.productSlots.map(async (productSlot) => ({ + id: productSlot.product.id, + name: productSlot.product.name, + shortDescription: productSlot.product.shortDescription, + price: productSlot.product.price, + marketPrice: productSlot.product.marketPrice, + unit: productSlot.product.unit?.shortNotation, + images: await generateSignedUrlsFromS3Urls( + (productSlot.product.images as string[]) || [] + ), + isOutOfStock: productSlot.product.isOutOfStock, + })) + ), + })) + ); + + return { + slots: slotsWithProducts, + count: slotsWithProducts.length, + }; + }), + + nextMajorDelivery: publicProcedure + .query(async () => { + const now = new Date(); + + // Find the next upcoming active delivery slot ID + const nextSlot = await db.query.deliverySlotInfo.findFirst({ + where: and( + eq(deliverySlotInfo.isActive, true), + gt(deliverySlotInfo.deliveryTime, now) + ), + orderBy: asc(deliverySlotInfo.deliveryTime), + }); + + if (!nextSlot) { + return null; // No upcoming delivery slots + } + + // Get formatted data using helper method + return await getSlotData(nextSlot.id); + }), + + getSlotById: publicProcedure + .input(z.object({ slotId: z.number() })) + .query(async ({ input }) => { + return await getSlotData(input.slotId); + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/stores.ts b/apps/backend/src/trpc/user-apis/stores.ts new file mode 100644 index 0000000..4a25a0c --- /dev/null +++ b/apps/backend/src/trpc/user-apis/stores.ts @@ -0,0 +1,141 @@ +import { router, publicProcedure } from '../trpc-index'; +import { z } from 'zod'; +import { db } from '../../db/db_index'; +import { storeInfo, productInfo, units } from '../../db/schema'; +import { eq, and, sql } from 'drizzle-orm'; +import { generateSignedUrlsFromS3Urls, generateSignedUrlFromS3Url } from '../../lib/s3-client'; +import { ApiError } from '../../lib/api-error'; + +export const storesRouter = router({ + getStores: publicProcedure + .query(async () => { + const storesData = await db + .select({ + id: storeInfo.id, + name: storeInfo.name, + description: storeInfo.description, + imageUrl: storeInfo.imageUrl, + productCount: sql`count(${productInfo.id})`.as('productCount'), + }) + .from(storeInfo) + .leftJoin( + productInfo, + and(eq(productInfo.storeId, storeInfo.id), eq(productInfo.isSuspended, false)) + ) + .groupBy(storeInfo.id); + + // Generate signed URLs for store images and fetch sample products + const storesWithDetails = await Promise.all( + storesData.map(async (store) => { + const signedImageUrl = store.imageUrl ? await generateSignedUrlFromS3Url(store.imageUrl) : null; + + // Fetch up to 3 products for this store + const sampleProducts = await db + .select({ + id: productInfo.id, + name: productInfo.name, + images: productInfo.images, + }) + .from(productInfo) + .where(and(eq(productInfo.storeId, store.id), eq(productInfo.isSuspended, false))) + .limit(3); + + // Generate signed URLs for product images + const productsWithSignedUrls = await Promise.all( + sampleProducts.map(async (product) => { + const images = product.images as string[]; + return { + id: product.id, + name: product.name, + signedImageUrl: (images && images.length > 0) ? await generateSignedUrlFromS3Url(images[0]) : null, + }; + }) + ); + + return { + id: store.id, + name: store.name, + description: store.description, + signedImageUrl, + productCount: store.productCount, + sampleProducts: productsWithSignedUrls, + }; + }) + ); + + return { + stores: storesWithDetails, + }; + }), + + getStoreWithProducts: publicProcedure + .input(z.object({ + storeId: z.number(), + })) + .query(async ({ input }) => { + const { storeId } = input; + + // Fetch store info + const storeData = await db.query.storeInfo.findFirst({ + where: eq(storeInfo.id, storeId), + columns: { + id: true, + name: true, + description: true, + imageUrl: true, + }, + }); + + if (!storeData) { + throw new ApiError('Store not found', 404); + } + + // Generate signed URL for store image + const signedImageUrl = storeData.imageUrl ? await generateSignedUrlFromS3Url(storeData.imageUrl) : null; + + // Fetch products for this store + const productsData = await db + .select({ + id: productInfo.id, + name: productInfo.name, + shortDescription: productInfo.shortDescription, + price: productInfo.price, + marketPrice: productInfo.marketPrice, + images: productInfo.images, + isOutOfStock: productInfo.isOutOfStock, + incrementStep: productInfo.incrementStep, + unitShortNotation: units.shortNotation, + productQuantity: productInfo.productQuantity, + }) + .from(productInfo) + .innerJoin(units, eq(productInfo.unitId, units.id)) + .where(and(eq(productInfo.storeId, storeId), eq(productInfo.isSuspended, false))); + + + // Generate signed URLs for product images + const productsWithSignedUrls = await Promise.all( + productsData.map(async (product) => ({ + id: product.id, + name: product.name, + shortDescription: product.shortDescription, + price: product.price, + marketPrice: product.marketPrice, + incrementStep: product.incrementStep, + unit: product.unitShortNotation, + images: await generateSignedUrlsFromS3Urls((product.images as string[]) || []), + isOutOfStock: product.isOutOfStock, + productQuantity: product.productQuantity + })) + ); + + return { + store: { + id: storeData.id, + name: storeData.name, + description: storeData.description, + signedImageUrl, + }, + products: productsWithSignedUrls, + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/user-trpc-index.ts b/apps/backend/src/trpc/user-apis/user-trpc-index.ts new file mode 100644 index 0000000..247edee --- /dev/null +++ b/apps/backend/src/trpc/user-apis/user-trpc-index.ts @@ -0,0 +1,32 @@ +import { router } from '../trpc-index'; +import { addressRouter } from './address'; +import { authRouter } from './auth'; +import { bannerRouter } from './banners'; +import { cartRouter } from './cart'; +import { complaintRouter } from './complaint'; +import { orderRouter } from './order'; +import { productRouter } from './product'; +import { slotsRouter } from './slots'; +import { userRouter as userDataRouter } from './user'; +import { userCouponRouter } from './coupon'; +import { paymentRouter } from './payments'; +import { storesRouter } from './stores'; +import { fileUploadRouter } from './file-upload'; + +export const userRouter = router({ + address: addressRouter, + auth: authRouter, + banner: bannerRouter, + cart: cartRouter, + complaint: complaintRouter, + order: orderRouter, + product: productRouter, + slots: slotsRouter, + user: userDataRouter, + coupon: userCouponRouter, + payment: paymentRouter, + stores: storesRouter, + fileUpload: fileUploadRouter, +}); + +export type UserRouter = typeof userRouter; \ No newline at end of file diff --git a/apps/backend/src/trpc/user-apis/user.ts b/apps/backend/src/trpc/user-apis/user.ts new file mode 100644 index 0000000..1d7de74 --- /dev/null +++ b/apps/backend/src/trpc/user-apis/user.ts @@ -0,0 +1,110 @@ +import { router, protectedProcedure } from '../trpc-index'; +import jwt from 'jsonwebtoken'; +import { eq } from 'drizzle-orm'; +import { db } from '../../db/db_index'; +import { users, userDetails, userCreds } from '../../db/schema'; +import { ApiError } from '../../lib/api-error'; +import { jwtSecret } from 'src/lib/env-exporter'; +import { generateSignedUrlFromS3Url } from '../../lib/s3-client'; + +interface AuthResponse { + token: string; + user: { + id: number; + name: string | null; + email: string | null; + mobile: string | null; + profileImage?: string | null; + bio?: string | null; + dateOfBirth?: string | null; + gender?: string | null; + occupation?: string | null; + }; +} + +const generateToken = (userId: number): string => { + const secret = jwtSecret; + if (!secret) { + throw new ApiError('JWT secret not configured', 500); + } + + return jwt.sign({ userId }, secret, { expiresIn: '7d' }); +}; + +export const userRouter = router({ + getSelfData: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + const [user] = await db + .select() + .from(users) + .where(eq(users.id, userId)) + .limit(1); + + if (!user) { + throw new ApiError('User not found', 404); + } + + // Get user details for profile image + const [userDetail] = await db + .select() + .from(userDetails) + .where(eq(userDetails.userId, userId)) + .limit(1); + + // Generate signed URL for profile image if it exists + const profileImageSignedUrl = userDetail?.profileImage + ? await generateSignedUrlFromS3Url(userDetail.profileImage) + : null; + + const response: Omit = { + user: { + id: user.id, + name: user.name, + email: user.email, + mobile: user.mobile, + profileImage: profileImageSignedUrl, + bio: userDetail?.bio || null, + dateOfBirth: userDetail?.dateOfBirth || null, + gender: userDetail?.gender || null, + occupation: userDetail?.occupation || null, + }, + }; + + return { + success: true, + data: response, + }; + }), + + checkProfileComplete: protectedProcedure + .query(async ({ ctx }) => { + const userId = ctx.user.userId; + + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + const result = await db + .select() + .from(users) + .leftJoin(userCreds, eq(users.id, userCreds.userId)) + .where(eq(users.id, userId)) + .limit(1); + + if (result.length === 0) { + throw new ApiError('User not found', 404); + } + + const { users: user, user_creds: creds } = result[0]; + + return { + isComplete: !!(user.name && user.email && creds), + }; + }), +}); \ No newline at end of file diff --git a/apps/backend/src/uv-apis/auth.controller.ts b/apps/backend/src/uv-apis/auth.controller.ts new file mode 100644 index 0000000..6bb54f9 --- /dev/null +++ b/apps/backend/src/uv-apis/auth.controller.ts @@ -0,0 +1,321 @@ +import { Request, Response, NextFunction } from 'express'; +import bcrypt from 'bcryptjs'; +import jwt from 'jsonwebtoken'; +import { eq } from 'drizzle-orm'; +import { db } from '../db/db_index'; +import { users, userCreds, userDetails } from '../db/schema'; +import { ApiError } from '../lib/api-error'; +import catchAsync from '../lib/catch-async'; +import { jwtSecret } from 'src/lib/env-exporter'; +import uploadHandler from '../lib/upload-handler'; +import { imageUploadS3, generateSignedUrlFromS3Url } from '../lib/s3-client'; + +interface RegisterRequest { + name: string; + email: string; + mobile: string; + password: string; + profileImage?: string; +} + +interface UpdateProfileRequest { + name?: string; + email?: string; + mobile?: string; + password?: string; + bio?: string; + dateOfBirth?: string; + gender?: string; + occupation?: string; +} + +interface AuthResponse { + token: string; + user: { + id: number; + name: string | null; + email: string | null; + mobile: string | null; + profileImage?: string | null; + bio?: string | null; + dateOfBirth?: string | null; + gender?: string | null; + occupation?: string | null; + }; +} + +const generateToken = (userId: number): string => { + const secret = jwtSecret; + if (!secret) { + throw new ApiError('JWT secret not configured', 500); + } + + return jwt.sign({ userId }, secret, { expiresIn: '7d' }); +}; + +export const register = catchAsync(async (req: Request, res: Response, next: NextFunction) => { + const { name, email, mobile, password }: RegisterRequest = req.body; + + // Handle profile image upload + let profileImageUrl: string | undefined; + if (req.file) { + const key = `profile-images/${Date.now()}-${req.file.originalname}`; + profileImageUrl = await imageUploadS3(req.file.buffer, req.file.mimetype, key); + } + + if (!name || !email || !mobile || !password) { + throw new ApiError('All fields are required', 400); + } + + // Validate email format + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(email)) { + throw new ApiError('Invalid email format', 400); + } + + // Validate mobile format (Indian mobile numbers) + const cleanMobile = mobile.replace(/\D/g, ''); + if (cleanMobile.length !== 10 || !/^[6-9]/.test(cleanMobile)) { + throw new ApiError('Invalid mobile number', 400); + } + + // Check if email already exists + const [existingEmail] = await db + .select() + .from(users) + .where(eq(users.email, email.toLowerCase())) + .limit(1); + + if (existingEmail) { + throw new ApiError('Email already registered', 409); + } + + // Check if mobile already exists + const [existingMobile] = await db + .select() + .from(users) + .where(eq(users.mobile, cleanMobile)) + .limit(1); + + if (existingMobile) { + throw new ApiError('Mobile number already registered', 409); + } + + // Hash password + const hashedPassword = await bcrypt.hash(password, 12); + + // Create user and credentials in a transaction + const newUser = await db.transaction(async (tx) => { + // Create user + const [user] = await tx + .insert(users) + .values({ + name: name.trim(), + email: email.toLowerCase().trim(), + mobile: cleanMobile, + }) + .returning(); + + // Create user credentials + await tx + .insert(userCreds) + .values({ + userId: user.id, + userPassword: hashedPassword, + }); + + // Create user details with profile image + await tx + .insert(userDetails) + .values({ + userId: user.id, + profileImage: profileImageUrl, + }); + + return user; + }); + + const token = generateToken(newUser.id); + + // Generate signed URL for profile image if it was uploaded + const profileImageSignedUrl = profileImageUrl + ? await generateSignedUrlFromS3Url(profileImageUrl) + : null; + + const response: AuthResponse = { + token, + user: { + id: newUser.id, + name: newUser.name, + email: newUser.email, + mobile: newUser.mobile, + profileImage: profileImageSignedUrl, + bio: null, + dateOfBirth: null, + gender: null, + occupation: null, + }, + }; + + res.status(201).json({ + success: true, + data: response, + }); +}); + +export const updateProfile = catchAsync(async (req: Request, res: Response, next: NextFunction) => { + const userId = req.user?.userId; + + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + const { name, email, mobile, password, bio, dateOfBirth, gender, occupation }: UpdateProfileRequest = req.body; + + // Handle profile image upload + let profileImageUrl: string | undefined; + if (req.file) { + const key = `profile-images/${Date.now()}-${req.file.originalname}`; + profileImageUrl = await imageUploadS3(req.file.buffer, req.file.mimetype, key); + } + + // Validate email format if provided + if (email) { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(email)) { + throw new ApiError('Invalid email format', 400); + } + } + + // Validate mobile format if provided + if (mobile) { + const cleanMobile = mobile.replace(/\D/g, ''); + if (cleanMobile.length !== 10 || !/^[6-9]/.test(cleanMobile)) { + throw new ApiError('Invalid mobile number', 400); + } + } + + // Check if email already exists (if changing email) + if (email) { + const [existingEmail] = await db + .select() + .from(users) + .where(eq(users.email, email.toLowerCase())) + .limit(1); + + if (existingEmail && existingEmail.id !== userId) { + throw new ApiError('Email already registered', 409); + } + } + + // Check if mobile already exists (if changing mobile) + if (mobile) { + const cleanMobile = mobile.replace(/\D/g, ''); + const [existingMobile] = await db + .select() + .from(users) + .where(eq(users.mobile, cleanMobile)) + .limit(1); + + if (existingMobile && existingMobile.id !== userId) { + throw new ApiError('Mobile number already registered', 409); + } + } + + // Update user and user details in a transaction + const updatedUser = await db.transaction(async (tx) => { + // Update user table + const updateData: any = {}; + if (name) updateData.name = name.trim(); + if (email) updateData.email = email.toLowerCase().trim(); + if (mobile) updateData.mobile = mobile.replace(/\D/g, ''); + + if (Object.keys(updateData).length > 0) { + await tx + .update(users) + .set(updateData) + .where(eq(users.id, userId)); + } + + // Update password if provided + if (password) { + const hashedPassword = await bcrypt.hash(password, 12); + await tx + .update(userCreds) + .set({ userPassword: hashedPassword }) + .where(eq(userCreds.userId, userId)); + } + + // Update or insert user details + const userDetailsUpdate: any = {}; + if (bio !== undefined) userDetailsUpdate.bio = bio; + if (dateOfBirth !== undefined) userDetailsUpdate.dateOfBirth = dateOfBirth ? new Date(dateOfBirth) : null; + if (gender !== undefined) userDetailsUpdate.gender = gender; + if (occupation !== undefined) userDetailsUpdate.occupation = occupation; + if (profileImageUrl) userDetailsUpdate.profileImage = profileImageUrl; + userDetailsUpdate.updatedAt = new Date(); + + // Check if user details record exists + const [existingDetails] = await tx + .select() + .from(userDetails) + .where(eq(userDetails.userId, userId)) + .limit(1); + + if (existingDetails) { + // Update existing record + await tx + .update(userDetails) + .set(userDetailsUpdate) + .where(eq(userDetails.userId, userId)); + } else { + // Create new record + userDetailsUpdate.userId = userId; + userDetailsUpdate.createdAt = new Date(); + await tx + .insert(userDetails) + .values(userDetailsUpdate); + } + + // Return updated user data + const [user] = await tx + .select() + .from(users) + .where(eq(users.id, userId)) + .limit(1); + + return user; + }); + + // Get updated user details for response + const [userDetail] = await db + .select() + .from(userDetails) + .where(eq(userDetails.userId, userId)) + .limit(1); + + // Generate signed URL for profile image if it exists + const profileImageSignedUrl = userDetail?.profileImage + ? await generateSignedUrlFromS3Url(userDetail.profileImage) + : null; + + const response: AuthResponse = { + token: req.headers.authorization?.replace('Bearer ', '') || '', // Keep existing token + user: { + id: updatedUser.id, + name: updatedUser.name, + email: updatedUser.email, + mobile: updatedUser.mobile, + profileImage: profileImageSignedUrl, + bio: userDetail?.bio || null, + dateOfBirth: userDetail?.dateOfBirth || null, + gender: userDetail?.gender || null, + occupation: userDetail?.occupation || null, + }, + }; + + res.status(200).json({ + success: true, + data: response, + }); +}); \ No newline at end of file diff --git a/apps/backend/src/uv-apis/auth.router.ts b/apps/backend/src/uv-apis/auth.router.ts new file mode 100644 index 0000000..829e5cd --- /dev/null +++ b/apps/backend/src/uv-apis/auth.router.ts @@ -0,0 +1,12 @@ +import { Router } from 'express'; +import { register, updateProfile } from './auth.controller'; +import { verifyToken } from '../middleware/auth'; +import uploadHandler from '../lib/upload-handler'; + +const router = Router(); + +router.post('/register', uploadHandler.single('profileImage'), register); +router.put('/profile', verifyToken, uploadHandler.single('profileImage'), updateProfile); + +const authRouter = router; +export default authRouter; \ No newline at end of file diff --git a/apps/backend/src/uv-apis/user-rest.controller.ts b/apps/backend/src/uv-apis/user-rest.controller.ts new file mode 100644 index 0000000..c4e08c2 --- /dev/null +++ b/apps/backend/src/uv-apis/user-rest.controller.ts @@ -0,0 +1,57 @@ +import { Request, Response, NextFunction } from 'express'; +import { db } from '../db/db_index'; +import { complaints } from '../db/schema'; +import { ApiError } from '../lib/api-error'; +import catchAsync from '../lib/catch-async'; +import { imageUploadS3 } from '../lib/s3-client'; + +interface RaiseComplaintRequest { + orderId?: string; + complaintBody: string; +} + +export const raiseComplaint = catchAsync(async (req: Request, res: Response, next: NextFunction) => { + console.log('raising complaint') + + const userId = req.user?.userId; + + if (!userId) { + throw new ApiError('User not authenticated', 401); + } + + const { orderId, complaintBody }: RaiseComplaintRequest = req.body; + + let orderIdNum: number | null = null; + + if (orderId) { + const readableIdMatch = orderId.match(/^ORD(\d+)$/); + if (readableIdMatch) { + orderIdNum = parseInt(readableIdMatch[1]); + } + } + + // Handle image uploads + const images = (req.files as Express.Multer.File[])?.filter(item => item.fieldname === 'images'); + let uploadedImageUrls: string[] = []; + + if (images && Array.isArray(images)) { + const imageUploadPromises = images.map((file, index) => { + const key = `complaint-images/${Date.now()}-${index}`; + return imageUploadS3(file.buffer, file.mimetype, key); + }); + + uploadedImageUrls = await Promise.all(imageUploadPromises); + } + + await db.insert(complaints).values({ + userId, + orderId: orderIdNum, + complaintBody: complaintBody.trim(), + images: uploadedImageUrls.length > 0 ? uploadedImageUrls : null, + }); + + res.status(200).json({ + success: true, + message: 'Complaint raised successfully' + }); +}); \ No newline at end of file diff --git a/apps/backend/src/uv-apis/uv-router.ts b/apps/backend/src/uv-apis/uv-router.ts new file mode 100644 index 0000000..28a71fe --- /dev/null +++ b/apps/backend/src/uv-apis/uv-router.ts @@ -0,0 +1,12 @@ +import { Router } from "express"; +import authRouter from "./auth.router"; +import { raiseComplaint } from "./user-rest.controller"; +import uploadHandler from "src/lib/upload-handler"; + +const router = Router(); + +router.use("/auth", authRouter); +router.use("/complaints/raise", uploadHandler.array('images'),raiseComplaint) + +const uvRouter = router; +export default uvRouter; \ No newline at end of file diff --git a/apps/backend/src/v1-router.ts b/apps/backend/src/v1-router.ts new file mode 100644 index 0000000..8af0e58 --- /dev/null +++ b/apps/backend/src/v1-router.ts @@ -0,0 +1,15 @@ + import { Router } from "express"; + import avRouter from "./admin-apis/av-router"; + import commonRouter from "./common-apis/common.router"; + import uvRouter from "./uv-apis/uv-router"; + +const router = Router(); + + router.use('/av', avRouter); + router.use('/cm', commonRouter); + router.use('/uv', uvRouter); + + +const v1Router = router; + +export default v1Router; \ No newline at end of file diff --git a/apps/backend/tsconfig.json b/apps/backend/tsconfig.json new file mode 100755 index 0000000..c6bb974 --- /dev/null +++ b/apps/backend/tsconfig.json @@ -0,0 +1,119 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "libReplacement": true, /* Enable lib replacement. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", + "baseUrl": ".", + "paths": { + "shared-types": ["../shared-types"], + "@commonTypes": ["../../packages/ui/shared-types"], + "@commonTypes/*": ["../../packages/ui/shared-types/*"] + }, + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [""], /* Specify multiple folders that act like './node_modules/@types'. */ + "typeRoots": ["./node_modules/@types", "../shared-types"], + + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "strictNullChecks": false, /* When type checking, take into account 'null' and 'undefined'. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": ["src", "types", "index.ts", "../shared-types"] +} diff --git a/apps/fallback-ui/components.json b/apps/fallback-ui/components.json new file mode 100644 index 0000000..07bc023 --- /dev/null +++ b/apps/fallback-ui/components.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "new-york", + "rsc": false, + "tsx": true, + "tailwind": { + "config": "tailwind.config.ts", + "css": "src/index.css", + "baseColor": "slate", + "cssVariables": true + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils" + } +} diff --git a/apps/fallback-ui/env.d.ts b/apps/fallback-ui/env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/apps/fallback-ui/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/apps/fallback-ui/eslint.config.js b/apps/fallback-ui/eslint.config.js new file mode 100644 index 0000000..21c8f61 --- /dev/null +++ b/apps/fallback-ui/eslint.config.js @@ -0,0 +1,34 @@ +import eslint from '@eslint/js' +import tseslint from 'typescript-eslint' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' + +export default tseslint.config( + { + ignores: ['dist'] + }, + { + extends: [ + eslint.configs.recommended, + ...tseslint.configs.recommended + ], + files: ['src/**/*.{ts,tsx}'], + languageOptions: { + parserOptions: { + project: false + } + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh + }, + rules: { + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true } + ] + } + } +) diff --git a/apps/fallback-ui/index.html b/apps/fallback-ui/index.html new file mode 100644 index 0000000..375e39a --- /dev/null +++ b/apps/fallback-ui/index.html @@ -0,0 +1,13 @@ + + + + + + + Freshyo Admin + + +
+ + + diff --git a/apps/fallback-ui/package.json b/apps/fallback-ui/package.json new file mode 100644 index 0000000..4d7aa7b --- /dev/null +++ b/apps/fallback-ui/package.json @@ -0,0 +1,49 @@ +{ + "name": "fallback-ui", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "lint": "eslint \"src/**/*.{ts,tsx}\"" + }, + "dependencies": { + "@radix-ui/react-slot": "^1.1.2", + "@tanstack/react-query": "^5.59.16", + "@tanstack/react-router": "^1.92.8", + "@tanstack/router-devtools": "^1.92.8", + "@trpc/client": "^11.6.0", + "@trpc/react-query": "^11.6.0", + "axios": "^1.7.9", + "class-variance-authority": "^0.7.0", + "clsx": "^2.1.1", + "formik": "^2.4.9", + "jwt-decode": "^4.0.0", + "react": "19.0.0", + "react-dom": "19.0.0", + "superjson": "^2.2.1", + "tailwind-merge": "^2.5.5", + "yup": "^1.7.1", + "zod": "^3.24.1", + "zustand": "^5.0.10" + }, + "devDependencies": { + "@types/node": "^20.17.10", + "@types/react": "~19.0.10", + "@types/react-dom": "~19.0.4", + "@typescript-eslint/eslint-plugin": "^8.18.1", + "@typescript-eslint/parser": "^8.18.1", + "@vitejs/plugin-react-swc": "^3.7.2", + "autoprefixer": "^10.4.20", + "eslint": "^9.25.0", + "eslint-plugin-react-hooks": "^5.1.0", + "eslint-plugin-react-refresh": "^0.4.9", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.16", + "tailwindcss-animate": "^1.0.7", + "typescript": "~5.8.3", + "vite": "^6.0.5" + } +} diff --git a/apps/fallback-ui/postcss.config.cjs b/apps/fallback-ui/postcss.config.cjs new file mode 100644 index 0000000..85f717c --- /dev/null +++ b/apps/fallback-ui/postcss.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {} + } +} diff --git a/apps/fallback-ui/src/components/AuthWrapper.tsx b/apps/fallback-ui/src/components/AuthWrapper.tsx new file mode 100644 index 0000000..4af3353 --- /dev/null +++ b/apps/fallback-ui/src/components/AuthWrapper.tsx @@ -0,0 +1,65 @@ +import { useEffect } from 'react' +import { useNavigate } from '@tanstack/react-router' +import { trpc } from '@/trpc/client' +import { useUserStore } from '@/stores/userStore' +import { getCurrentUserId } from '@/services/auth' + +interface AuthWrapperProps { + children: React.ReactNode +} + +export function AuthWrapper({ children }: AuthWrapperProps) { + const navigate = useNavigate() + const { setUser, setLoading, setError, user, isLoading } = useUserStore() + + const { data: staffData, isLoading: isStaffLoading, error: staffError } = trpc.admin.staffUser.getStaff.useQuery() + + useEffect(() => { + const initializeAuth = async () => { + const userId = await getCurrentUserId() + + if (!userId) { + navigate({ to: '/login' as any }) + return + } + + if (staffData && !isStaffLoading && !staffError) { + const currentUser = staffData.staff.find((staff: any) => staff.id === userId) + + if (currentUser) { + setUser({ + id: currentUser.id, + name: currentUser.name, + role: currentUser.role, + permissions: currentUser.permissions, + }) + } else { + setError('User not found in staff list') + navigate({ to: '/login' as any }) + } + } else if (staffError) { + setError('Failed to load user data') + navigate({ to: '/login' as any }) + } + } + + initializeAuth() + }, [staffData, isStaffLoading, staffError, navigate, setUser, setError]) + + if (isLoading || isStaffLoading) { + return ( +
+
+
+

Loading user data...

+
+
+ ) + } + + if (!user) { + return null // Will redirect + } + + return <>{children} +} \ No newline at end of file diff --git a/apps/fallback-ui/src/components/StaffUserForm.tsx b/apps/fallback-ui/src/components/StaffUserForm.tsx new file mode 100644 index 0000000..d83ba12 --- /dev/null +++ b/apps/fallback-ui/src/components/StaffUserForm.tsx @@ -0,0 +1,115 @@ +import { useState } from 'react'; +import { Formik, Form, Field, ErrorMessage } from 'formik'; +import * as Yup from 'yup'; +import { trpc } from '@/trpc/client'; +import { Button } from '@/components/ui/button'; + +const validationSchema = Yup.object({ + name: Yup.string() + .min(2, 'Name must be at least 2 characters') + .required('Name is required'), + password: Yup.string() + .min(6, 'Password must be at least 6 characters') + .required('Password is required'), + roleId: Yup.number() + .required('Role is required'), +}); + +interface StaffUserFormProps { + onSuccess?: () => void; +} + +export function StaffUserForm({ onSuccess }: StaffUserFormProps) { + const createStaffMutation = trpc.admin.staffUser.createStaffUser.useMutation({ + onSuccess: (data) => { + alert(`Staff user "${data.user.name}" created successfully!`); + onSuccess?.(); + }, + onError: (error: any) => { + alert(`Error: ${error.message}`); + } + }); + + // Fetch available roles + const { data: rolesData } = trpc.admin.staffUser.getRoles.useQuery(); + + // Filter out super_admin role from dropdown + const availableRoles = rolesData?.roles?.filter(role => role.name !== 'super_admin') || []; + + return ( +
+

Add New Staff User

+ + { + createStaffMutation.mutate({ + name: values.name, + password: values.password, + roleId: parseInt(values.roleId), + }); + resetForm(); + }} + > + {({ isSubmitting }) => ( +
+
+ + + +
+ +
+ + + +
+ +
+ + + + {availableRoles.map((role) => ( + + ))} + + +
+ + +
+ )} +
+
+ ); +} \ No newline at end of file diff --git a/apps/fallback-ui/src/components/SuperAdminGuard.tsx b/apps/fallback-ui/src/components/SuperAdminGuard.tsx new file mode 100644 index 0000000..1c1231e --- /dev/null +++ b/apps/fallback-ui/src/components/SuperAdminGuard.tsx @@ -0,0 +1,28 @@ +import { useUserStore } from '@/stores/userStore'; + +interface SuperAdminGuardProps { + children: React.ReactNode; +} + +export function SuperAdminGuard({ children }: SuperAdminGuardProps) { + const { user } = useUserStore(); + const allowedRoles = ['super_admin']; // Only super_admin role can access super admin features + + if (!allowedRoles.includes(user?.role?.name || '')) { + return ( +
+
+
+ + + +
+

Access Denied

+

You don't have permission to access the super admin area.

+
+
+ ); + } + + return <>{children}; +} \ No newline at end of file diff --git a/apps/fallback-ui/src/components/ui/button.tsx b/apps/fallback-ui/src/components/ui/button.tsx new file mode 100644 index 0000000..63760a8 --- /dev/null +++ b/apps/fallback-ui/src/components/ui/button.tsx @@ -0,0 +1,55 @@ +import * as React from 'react' +import { Slot } from '@radix-ui/react-slot' +import { cva, type VariantProps } from 'class-variance-authority' +import { cn } from '@/lib/utils' + +const buttonVariants = cva( + 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', + { + variants: { + variant: { + default: + 'bg-slate-900 text-slate-50 shadow hover:bg-slate-900/90', + secondary: + 'bg-slate-100 text-slate-900 hover:bg-slate-200', + outline: + 'border border-slate-200 bg-white hover:bg-slate-100 hover:text-slate-900', + ghost: + 'hover:bg-slate-100 hover:text-slate-900', + destructive: + 'bg-red-500 text-white hover:bg-red-600', + link: 'text-slate-900 underline-offset-4 hover:underline' + }, + size: { + default: 'h-10 px-4 py-2', + sm: 'h-9 rounded-md px-3', + lg: 'h-11 rounded-md px-8', + icon: 'h-10 w-10' + } + }, + defaultVariants: { + variant: 'default', + size: 'default' + } + } +) + +export interface ButtonProps + extends React.ButtonHTMLAttributes, + VariantProps { + asChild?: boolean +} + +export const Button = React.forwardRef( + ({ className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : 'button' + return ( + + ) + } +) +Button.displayName = 'Button' diff --git a/apps/fallback-ui/src/constants.ts b/apps/fallback-ui/src/constants.ts new file mode 100644 index 0000000..242ed1b --- /dev/null +++ b/apps/fallback-ui/src/constants.ts @@ -0,0 +1,7 @@ +const webUiConstants = { + // baseUrl: 'http://localhost:4000/' + baseUrl: '/' +} + + +export default webUiConstants; \ No newline at end of file diff --git a/apps/fallback-ui/src/index.css b/apps/fallback-ui/src/index.css new file mode 100644 index 0000000..68b987d --- /dev/null +++ b/apps/fallback-ui/src/index.css @@ -0,0 +1,51 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +@layer base { + :root { + --background: 0 0% 100%; + --foreground: 222.2 47.4% 11.2%; + --card: 0 0% 100%; + --card-foreground: 222.2 47.4% 11.2%; + --popover: 0 0% 100%; + --popover-foreground: 222.2 47.4% 11.2%; + --primary: 222.2 47.4% 11.2%; + --primary-foreground: 210 40% 98%; + --secondary: 210 40% 96.1%; + --secondary-foreground: 222.2 47.4% 11.2%; + --muted: 210 40% 96.1%; + --muted-foreground: 215.4 16.3% 46.9%; + --accent: 210 40% 96.1%; + --accent-foreground: 222.2 47.4% 11.2%; + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 210 40% 98%; + --border: 214.3 31.8% 91.4%; + --input: 214.3 31.8% 91.4%; + --ring: 222.2 84% 4.9%; + --radius: 0.75rem; + } + + body { + @apply bg-slate-100 text-slate-900 antialiased; + } +} + +@layer base { + * { + @apply border-border; + } + + h1, + h2, + h3, + h4, + h5, + h6 { + @apply font-semibold; + } + + a { + @apply text-primary hover:text-primary/80; + } +} diff --git a/apps/fallback-ui/src/lib/http.ts b/apps/fallback-ui/src/lib/http.ts new file mode 100644 index 0000000..6143362 --- /dev/null +++ b/apps/fallback-ui/src/lib/http.ts @@ -0,0 +1,17 @@ +import webUiConstants from '@/constants' +import axios from 'axios' + +export const httpClient = axios.create({ + baseURL: webUiConstants.baseUrl+'api', + withCredentials: true +}) + +httpClient.interceptors.response.use( + (response) => response, + (error) => { + if (import.meta.env.DEV) { + console.error('HTTP error', error) + } + return Promise.reject(error) + } +) diff --git a/apps/fallback-ui/src/lib/jwt.ts b/apps/fallback-ui/src/lib/jwt.ts new file mode 100644 index 0000000..56df722 --- /dev/null +++ b/apps/fallback-ui/src/lib/jwt.ts @@ -0,0 +1,28 @@ +import { jwtDecode } from 'jwt-decode'; + +interface JWTPayload { + staffId?: number; + name?: string; + iat: number; + exp: number; +} + +export const parseJWT = (token: string): JWTPayload | null => { + try { + return jwtDecode(token); + } catch (error) { + console.error('Failed to parse JWT:', error); + return null; + } +}; + +export const getUserIdFromToken = (token: string): number | null => { + const payload = parseJWT(token); + return payload?.staffId || null; +}; + +export const isTokenExpired = (token: string): boolean => { + const payload = parseJWT(token); + if (!payload?.exp) return true; + return Date.now() >= payload.exp * 1000; +}; \ No newline at end of file diff --git a/apps/fallback-ui/src/lib/utils.ts b/apps/fallback-ui/src/lib/utils.ts new file mode 100644 index 0000000..fed2fe9 --- /dev/null +++ b/apps/fallback-ui/src/lib/utils.ts @@ -0,0 +1,6 @@ +import { clsx, type ClassValue } from 'clsx' +import { twMerge } from 'tailwind-merge' + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} diff --git a/apps/fallback-ui/src/main.tsx b/apps/fallback-ui/src/main.tsx new file mode 100644 index 0000000..002e7a8 --- /dev/null +++ b/apps/fallback-ui/src/main.tsx @@ -0,0 +1,27 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { RouterProvider } from '@tanstack/react-router' +import { trpc, createTRPCClient } from './trpc/client' +import { createAppRouter } from './router' +import './index.css' + +const queryClient = new QueryClient() +const trpcClient = createTRPCClient() +const router = createAppRouter() + +const container = document.getElementById('root') + +if (!container) { + throw new Error('Failed to find root element for the application') +} + +createRoot(container).render( + + + + + + + +) diff --git a/apps/fallback-ui/src/router.tsx b/apps/fallback-ui/src/router.tsx new file mode 100644 index 0000000..07aca3b --- /dev/null +++ b/apps/fallback-ui/src/router.tsx @@ -0,0 +1,136 @@ +import { Link, Outlet, RootRoute, Route, createRouter } from '@tanstack/react-router' +import { Suspense } from 'react' +import { TanStackRouterDevtools } from '@tanstack/router-devtools' +import { z } from 'zod' +import { HomeRoute } from './routes/home' +import { VendorOrderListRoute } from './routes/vendor-order-list' +import { LoginRoute } from './routes/login' +import { UserHomeRoute } from './routes/user-home' +import { SuperAdminRoute } from './routes/super-admin' +import { CreateCouponRoute } from './routes/create-coupon' +import { AuthWrapper } from './components/AuthWrapper' +import { SuperAdminGuard } from './components/SuperAdminGuard' +import { cn } from '@/lib/utils' + +const basepath = normalizeBasePath(import.meta.env.BASE_URL) + +const rootRoute = new RootRoute({ + component: RootComponent +}) + +const dashboardRoute = new Route({ + getParentRoute: () => rootRoute, + path: '/', + component: () => ( + Loading route…

}> + +
+ ) +}) + +const vendorOrderListRoute = new Route({ + getParentRoute: () => rootRoute, + path: '/vendor-order-list', + validateSearch: z.object({ + id: z.string().optional(), + }), + component: () => ( + Loading vendor orders…

}> + +
+ ) +}) + +const loginRoute = new Route({ + getParentRoute: () => rootRoute, + path: '/login', + component: () => ( + Loading login…

}> + +
+ ) +}) + +const userHomeRoute = new Route({ + getParentRoute: () => rootRoute, + path: '/user-home', + component: () => ( + Loading user home…

}> + + + +
+ ) +}) + +const superAdminRoute = new Route({ + getParentRoute: () => rootRoute, + path: '/super-admin', + component: () => ( + Loading super admin…

}> + + + + + +
+ ) +}) + +const createCouponRoute = new Route({ + getParentRoute: () => rootRoute, + path: '/create-coupon', + component: () => ( + Loading create coupon…

}> + + + +
+ ) +}) + +const routeTree = rootRoute.addChildren([dashboardRoute, vendorOrderListRoute, loginRoute, userHomeRoute, superAdminRoute, createCouponRoute]) + +export function createAppRouter() { + return createRouter({ + routeTree, + basepath + }) +} + +export type AppRouterInstance = ReturnType + +declare module '@tanstack/react-router' { + interface Register { + router: AppRouterInstance + } +} + +const navItems = [ + { to: '/', label: 'Dashboard', exact: true }, + { to: '/vendor-order-list', label: 'Vendor Order List' } +] as const + +function RootComponent() { + return ( +
+
+
+ +
+
+ © {new Date().getFullYear()} Meat Farmer. All rights reserved. +
+ {import.meta.env.DEV ? ( + + ) : null} +
+
+ ) +} + +function normalizeBasePath(value: string): string { + if (!value) return '/' + if (value === '/') return '/' + return value.endsWith('/') ? value.slice(0, -1) : value +} diff --git a/apps/fallback-ui/src/routes/create-coupon.tsx b/apps/fallback-ui/src/routes/create-coupon.tsx new file mode 100644 index 0000000..34e905e --- /dev/null +++ b/apps/fallback-ui/src/routes/create-coupon.tsx @@ -0,0 +1,102 @@ +import { useState } from 'react' +import { trpc } from '../trpc/client' + +export function CreateCouponRoute() { + const [mobileNumber, setMobileNumber] = useState('') + const [isLoading, setIsLoading] = useState(false) + const [success, setSuccess] = useState('') + const [error, setError] = useState('') + + const createCouponMutation = trpc.admin.coupon.createCoupon.useMutation() + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault() + setIsLoading(true) + setSuccess('') + setError('') + + try { + const result = await createCouponMutation.mutateAsync({ + mobile: mobileNumber.trim(), + }) + + if (result.success) { + setSuccess(`Coupon created successfully! Code: ${result.coupon.couponCode} for mobile: ${result.coupon.userMobile}`) + setMobileNumber('') + } + } catch (err: any) { + setError(err.message || 'Failed to create coupon') + } finally { + setIsLoading(false) + } + } + + const handleMobileChange = (e: React.ChangeEvent) => { + const value = e.target.value.replace(/\D/g, '') // Only allow digits + if (value.length <= 10) { + setMobileNumber(value) + } + } + + return ( +
+
+

+ Create Coupon +

+ +
+
+ + +

+ Enter 10-digit mobile number (digits only) +

+
+ + {success && ( +
+ {success} +
+ )} + + {error && ( +
+ {error} +
+ )} + + +
+ +
+

Coupon Details:

+
    +
  • 20% discount
  • +
  • Minimum order: ₹1000
  • +
  • Maximum discount: ₹500
  • +
  • One-time use per user
  • +
  • Valid for 90 days from creation
  • +
+
+
+
+ ) +} \ No newline at end of file diff --git a/apps/fallback-ui/src/routes/home.tsx b/apps/fallback-ui/src/routes/home.tsx new file mode 100644 index 0000000..757314a --- /dev/null +++ b/apps/fallback-ui/src/routes/home.tsx @@ -0,0 +1,57 @@ +import { Link, useNavigate } from '@tanstack/react-router' +import { useEffect, useState } from 'react' +import { isAuthenticated } from '@/services/auth' + +export function HomeRoute() { + const navigate = useNavigate() + const [isAuthChecked, setIsAuthChecked] = useState(false) + const [isUserAuthenticated, setIsUserAuthenticated] = useState(false) + + useEffect(() => { + const checkAuth = async () => { + const authenticated = await isAuthenticated() + setIsUserAuthenticated(authenticated) + setIsAuthChecked(true) + + if (authenticated) { + navigate({ to: '/user-home' as any }) + } + } + + checkAuth() + }, [navigate]) + + if (!isAuthChecked) { + return ( +
+
+
+

Checking authentication...

+
+
+ ) + } + + if (isUserAuthenticated) { + return null // Will redirect via useEffect + } + + return ( +
+
+

+ Welcome to Freshyo Admin +

+

+ Manage your meat delivery platform with ease +

+ + Login to Dashboard + +
+
+ ) +} \ No newline at end of file diff --git a/apps/fallback-ui/src/routes/login.tsx b/apps/fallback-ui/src/routes/login.tsx new file mode 100644 index 0000000..a475ec3 --- /dev/null +++ b/apps/fallback-ui/src/routes/login.tsx @@ -0,0 +1,98 @@ +import { useState, useEffect } from 'react' +import { useNavigate } from '@tanstack/react-router' +import { trpc } from '@/trpc/client' +import { Button } from '@/components/ui/button' +import { setAuthToken, isAuthenticated } from '@/services/auth' + +export function LoginRoute() { + const [name, setName] = useState('') + const [password, setPassword] = useState('') + const [error, setError] = useState('') + const navigate = useNavigate() + + useEffect(() => { + const checkAuth = async () => { + if (await isAuthenticated()) { + navigate({ to: '/user-home' as any }) + } + } + checkAuth() + }, [navigate]) + + const loginMutation = trpc.admin.staffUser.login.useMutation({ + onSuccess: async (data: any) => { + await setAuthToken(data.token); + navigate({ to: '/user-home' as any }) + }, + onError: (error: any) => { + setError(error.message || 'Login failed') + } + }) + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + setError('') + loginMutation.mutate({ name, password }) + } + + return ( +
+
+

Login

+ +
+
+ + setName(e.target.value)} + className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + required + /> +
+ +
+ + setPassword(e.target.value)} + className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + required + /> +
+ + {error && ( +
+ {error} +
+ )} + + +
+ +
+ +
+
+
+ ) +} \ No newline at end of file diff --git a/apps/fallback-ui/src/routes/super-admin.tsx b/apps/fallback-ui/src/routes/super-admin.tsx new file mode 100644 index 0000000..3e5d07c --- /dev/null +++ b/apps/fallback-ui/src/routes/super-admin.tsx @@ -0,0 +1,52 @@ +import { StaffUserForm } from '@/components/StaffUserForm'; + +export function SuperAdminRoute() { + return ( +
+
+

Super Admin Dashboard

+

Advanced system management and user administration

+
+ +
+ {/* System Management Cards */} +
+

System Overview

+
+
+ Total Users + 1,234 +
+
+ Active Sessions + 89 +
+
+ System Health + Good +
+
+
+ +
+

Recent Activity

+
+

• New user registration

+

• Order completed

+

• System backup completed

+
+
+ + {/* Staff User Management - Full Width */} +
+ { + // Could refresh staff list or show additional success feedback + console.log('Staff user created successfully'); + }} + /> +
+
+
+ ); +} \ No newline at end of file diff --git a/apps/fallback-ui/src/routes/user-home.tsx b/apps/fallback-ui/src/routes/user-home.tsx new file mode 100644 index 0000000..225087c --- /dev/null +++ b/apps/fallback-ui/src/routes/user-home.tsx @@ -0,0 +1,149 @@ +import { Link, useNavigate } from '@tanstack/react-router' +import { removeAuthToken } from '@/services/auth' +import { useUserStore } from '@/stores/userStore' + + + +function AdminDashboard() { + const navigate = useNavigate() + + const handleLogout = async () => { + await removeAuthToken() + navigate({ to: '/' as any }) + } + + const { user } = useUserStore(); + + return ( +
+
+

Admin Dashboard

+ +
+
+
+

User Management

+

Manage staff users and permissions

+
+
+

System Settings

+

Configure system-wide settings

+
+
+

Analytics

+

View system analytics and reports

+
+ {user?.role?.name === 'super_admin' && ( + +

Super Admin

+

Advanced system management and user creation

+ + )} +
+
+ ); +} + +function MarketerDashboard() { + const navigate = useNavigate() + + const handleLogout = async () => { + await removeAuthToken() + navigate({ to: '/' as any }) + } + + + + const handleFirstUserCoupon = () => { + navigate({ to: '/create-coupon' as any }) + } + + const handleDiscountCoupon = () => { + navigate({ to: '/create-coupon' as any }) + } + + return ( +
+
+

Marketing Dashboard

+ +
+ +
+

Quick Actions

+
+ + +
+
+
+ ); +} + +function ErrorPage() { + const navigate = useNavigate() + + const handleLogout = async () => { + await removeAuthToken() + navigate({ to: '/' as any }) + } + + return ( +
+
+
+ + + +
+ +
+

Access Denied

+

+ Your role does not have access to this dashboard. Please contact an administrator. +

+
+ ); +} + +export function UserHomeRoute() { + const { user } = useUserStore() + + console.log({user}) + + return ( +
+ {(user?.role?.name === 'admin' || user?.role?.name === 'super_admin') && } + {user?.role?.name === 'marketer' && } + {user?.role && user.role.name !== 'admin' && user.role.name !== 'super_admin' && user.role.name !== 'marketer' && } +
+ ) +} \ No newline at end of file diff --git a/apps/fallback-ui/src/routes/vendor-order-list.tsx b/apps/fallback-ui/src/routes/vendor-order-list.tsx new file mode 100644 index 0000000..00f0e46 --- /dev/null +++ b/apps/fallback-ui/src/routes/vendor-order-list.tsx @@ -0,0 +1,221 @@ +import { useMemo, useState } from 'react' +import { useSearch } from '@tanstack/react-router' +import { trpc } from '../trpc/client' +import { cn } from '@/lib/utils' +import { Button } from '@/components/ui/button' + +interface VendorOrder { + orderId: string + customerName: string + orderDate: string + totalAmount: string + products: Array<{ + orderItemId: number + productId: number + productName: string + quantity: number + unit: string + is_packaged: boolean + is_package_verified: boolean + }> +} + +export function VendorOrderListRoute() { + const { id } = useSearch({ from: '/vendor-order-list' }) + + const { data, error, isLoading, isFetching, refetch } = id + ? trpc.admin.vendorSnippets.getOrdersBySnippet.useQuery({ snippetCode: id }) + : { data: null, error: null, isLoading: false, isFetching: false, refetch: () => {} } + + const updatePackagingMutation = trpc.admin.vendorSnippets.updateOrderItemPackaging.useMutation() + + const [updatingItems, setUpdatingItems] = useState>(new Set()) + + const handlePackagingToggle = async (orderItemId: number, currentValue: boolean) => { + setUpdatingItems(prev => new Set(prev).add(orderItemId)) + + try { + await updatePackagingMutation.mutateAsync({ + orderItemId, + is_packaged: !currentValue + }) + // Refetch data to update the UI + refetch() + } catch (error) { + console.error('Failed to update packaging status:', error) + } finally { + setUpdatingItems(prev => { + const newSet = new Set(prev) + newSet.delete(orderItemId) + return newSet + }) + } + } + + const orders = data?.success ? data.data : [] + + + const productSummary = useMemo(() => { + const summary: Record = {}; + + orders.forEach(order => { + order.products.forEach(product => { + const key = product.productName; + if (!summary[key]) { + summary[key] = { quantity: 0, unit: product.unit }; + } + summary[key].quantity += product.quantity; + }); + }); + + return Object.entries(summary).map(([name, data]) => ({ + name, + quantity: data.quantity, + unit: data.unit + })); + }, [orders]) + + return ( +
+
+

Summary

+
+ {productSummary.map((item, index) => ( +
+ {item.name}: + {item.quantity} {item.unit} +
+ ))} +
+
+ +
+
+
+

Vendor Orders

+

+ Track incoming orders and fulfilment progress for vendor partners. + {id && Snippet: {id}} +

+
+ +
+ +
+ {isLoading ? ( +
+ Loading orders… +
+ ) : error ? ( +
+ {error.message ?? 'Unable to load vendor orders right now'} +
+ ) : !id ? ( +
+ No snippet code provided +
+ ) : orders.length === 0 ? ( +
+ No vendor orders found. +
+ ) : ( +
+ {orders.map((order) => { + const parsedDate = order.orderDate + ? new Date(order.orderDate).toLocaleString() + : 'N/A' + const badgeClass = 'border-slate-200 bg-slate-100 text-slate-600 inline-flex items-center rounded-full border px-3 py-0.5 text-xs font-semibold uppercase' + + return ( +
+
+

+ {order.orderId} +

+ + Pending + +
+
+
+
+ Products (Packaging Status) +
+
+ {order.products.map((product) => ( +
+ + {product.productName}: {product.quantity} {product.unit} + + + handlePackagingToggle(product.orderItemId, product.is_packaged)} + className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" + /> +
+ ))} +
+
+
+
+ Date +
+
{parsedDate}
+
+
+
+ Total Amount +
+
+ ₹{order.totalAmount} +
+
+
+
+ ) + })} +
+ )} +
+ + {isFetching && !isLoading ? ( +

Refreshing…

+ ) : null} +
+
+ ) +} + +const statusBadgeStyles: Record = { + pending: 'border-amber-200 bg-amber-100 text-amber-700', + completed: 'border-emerald-200 bg-emerald-100 text-emerald-700', + cancelled: 'border-rose-200 bg-rose-100 text-rose-700', + inprogress: 'border-sky-200 bg-sky-100 text-sky-700', + dispatched: 'border-indigo-200 bg-indigo-100 text-indigo-700' +} diff --git a/apps/fallback-ui/src/services/StorageService.ts b/apps/fallback-ui/src/services/StorageService.ts new file mode 100644 index 0000000..c61cadd --- /dev/null +++ b/apps/fallback-ui/src/services/StorageService.ts @@ -0,0 +1,40 @@ +export const StorageService = { + async setItem(key: string, value: string): Promise { + try { + localStorage.setItem(key, value); + return true; + } catch (error) { + console.error('StorageService setItem error:', error); + return false; + } + }, + + async getItem(key: string): Promise { + try { + return localStorage.getItem(key); + } catch (error) { + console.error('StorageService getItem error:', error); + return null; + } + }, + + async removeItem(key: string): Promise { + try { + localStorage.removeItem(key); + return true; + } catch (error) { + console.error('StorageService removeItem error:', error); + return false; + } + }, + + async clearAll(keys: string[]): Promise { + try { + keys.forEach((key) => localStorage.removeItem(key)); + return true; + } catch (error) { + console.error('StorageService clearAll error:', error); + return false; + } + }, +}; \ No newline at end of file diff --git a/apps/fallback-ui/src/services/auth.ts b/apps/fallback-ui/src/services/auth.ts new file mode 100644 index 0000000..4a0f263 --- /dev/null +++ b/apps/fallback-ui/src/services/auth.ts @@ -0,0 +1,32 @@ +import { StorageService } from './StorageService'; +import { getUserIdFromToken, isTokenExpired } from '@/lib/jwt'; + +const AUTH_TOKEN_KEY = 'auth_token'; + +export const getAuthToken = async (): Promise => { + return await StorageService.getItem(AUTH_TOKEN_KEY); +}; + +export const setAuthToken = async (token: string): Promise => { + return await StorageService.setItem(AUTH_TOKEN_KEY, token); +}; + +export const removeAuthToken = async (): Promise => { + return await StorageService.removeItem(AUTH_TOKEN_KEY); +}; + +export const clearAllAuthData = async (): Promise => { + return await StorageService.clearAll([AUTH_TOKEN_KEY]); +}; + +export const getCurrentUserId = async (): Promise => { + const token = await getAuthToken(); + if (!token) return null; + return getUserIdFromToken(token); +}; + +export const isAuthenticated = async (): Promise => { + const token = await getAuthToken(); + if (!token) return false; + return !isTokenExpired(token); +}; \ No newline at end of file diff --git a/apps/fallback-ui/src/stores/userStore.ts b/apps/fallback-ui/src/stores/userStore.ts new file mode 100644 index 0000000..a9b28d1 --- /dev/null +++ b/apps/fallback-ui/src/stores/userStore.ts @@ -0,0 +1,47 @@ +import { create } from 'zustand'; +import { devtools } from 'zustand/middleware'; + +interface User { + id: number; + name: string; +} + +interface Role { + id: number; + name: string; +} + +interface Permission { + id: number; + name: string; +} + +interface UserWithRole extends User { + role: Role | null; + permissions: Permission[]; +} + +interface UserStore { + user: UserWithRole | null; + isLoading: boolean; + error: string | null; + setUser: (user: UserWithRole | null) => void; + setLoading: (loading: boolean) => void; + setError: (error: string | null) => void; + clearUser: () => void; +} + +export const useUserStore = create()( + devtools( + (set) => ({ + user: null, + isLoading: false, + error: null, + setUser: (user) => set({ user, error: null }), + setLoading: (loading) => set({ isLoading: loading }), + setError: (error) => set({ error, user: null }), + clearUser: () => set({ user: null, error: null, isLoading: false }), + }), + { name: 'user-store' } + ) +); \ No newline at end of file diff --git a/apps/fallback-ui/src/trpc/client.ts b/apps/fallback-ui/src/trpc/client.ts new file mode 100644 index 0000000..d4cac38 --- /dev/null +++ b/apps/fallback-ui/src/trpc/client.ts @@ -0,0 +1,35 @@ +import { createTRPCReact } from '@trpc/react-query' +import { httpBatchLink, loggerLink } from '@trpc/client' +import type { AppRouter } from '../../../backend/src/trpc/router' +import webUiConstants from '@/constants' +import { getAuthToken } from '@/services/auth' + +export const trpc = createTRPCReact() + + + +export function createTRPCClient() { + return trpc.createClient({ + // transformer: superjson, + links: [ + loggerLink({ + enabled: (opts) => + import.meta.env.DEV || + (opts.direction === 'down' && opts.result instanceof Error) + }), + httpBatchLink({ + url: webUiConstants.baseUrl+`api/trpc`, + headers: async () => { + const token = await getAuthToken(); + return token ? { Authorization: `Bearer ${token}` } : {}; + }, + fetch(url, options) { + return fetch(url, { + ...options, + credentials: 'include' + }) + } + }) + ] + }) +} diff --git a/apps/fallback-ui/tailwind.config.ts b/apps/fallback-ui/tailwind.config.ts new file mode 100644 index 0000000..08c20ca --- /dev/null +++ b/apps/fallback-ui/tailwind.config.ts @@ -0,0 +1,72 @@ +import type { Config } from 'tailwindcss' +import tailwindcssAnimate from 'tailwindcss-animate' + +const config: Config = { + darkMode: ['class'], + content: [ + './index.html', + './src/**/*.{ts,tsx}', + '../../packages/ui/**/*.{ts,tsx}' + ], + theme: { + extend: { + colors: { + border: 'hsl(var(--border))', + input: 'hsl(var(--input))', + ring: 'hsl(var(--ring))', + background: 'hsl(var(--background))', + foreground: 'hsl(var(--foreground))', + primary: { + DEFAULT: 'hsl(var(--primary))', + foreground: 'hsl(var(--primary-foreground))' + }, + secondary: { + DEFAULT: 'hsl(var(--secondary))', + foreground: 'hsl(var(--secondary-foreground))' + }, + destructive: { + DEFAULT: 'hsl(var(--destructive))', + foreground: 'hsl(var(--destructive-foreground))' + }, + muted: { + DEFAULT: 'hsl(var(--muted))', + foreground: 'hsl(var(--muted-foreground))' + }, + accent: { + DEFAULT: 'hsl(var(--accent))', + foreground: 'hsl(var(--accent-foreground))' + }, + popover: { + DEFAULT: 'hsl(var(--popover))', + foreground: 'hsl(var(--popover-foreground))' + }, + card: { + DEFAULT: 'hsl(var(--card))', + foreground: 'hsl(var(--card-foreground))' + } + }, + borderRadius: { + lg: 'var(--radius)', + md: 'calc(var(--radius) - 2px)', + sm: 'calc(var(--radius) - 4px)' + }, + keyframes: { + 'accordion-down': { + from: { height: '0' }, + to: { height: 'var(--radix-accordion-content-height)' } + }, + 'accordion-up': { + from: { height: 'var(--radix-accordion-content-height)' }, + to: { height: '0' } + } + }, + animation: { + 'accordion-down': 'accordion-down 0.2s ease-out', + 'accordion-up': 'accordion-up 0.2s ease-out' + } + } + }, + plugins: [tailwindcssAnimate] +} + +export default config diff --git a/apps/fallback-ui/tsconfig.json b/apps/fallback-ui/tsconfig.json new file mode 100644 index 0000000..53fd815 --- /dev/null +++ b/apps/fallback-ui/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["DOM", "DOM.Iterable", "ESNext"], + "skipLibCheck": true, + "moduleResolution": "Bundler", + "allowImportingTsExtensions": false, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"], + // "common-ui/shared-types": ["../../packages/ui/shared-types"] + "common-ui": ["../../packages/ui"], + "common-ui/*": ["../../packages/ui/*"] + }, + "types": ["node"] + }, + "include": ["./src", "./vite.config.ts", "./env.d.ts"] +} diff --git a/apps/fallback-ui/vite.config.ts b/apps/fallback-ui/vite.config.ts new file mode 100644 index 0000000..78a2a00 --- /dev/null +++ b/apps/fallback-ui/vite.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react-swc' +import path from 'path' + + +export default defineConfig({ + base: '/', + plugins: [react()], + resolve: { + alias: { + '@': path.resolve(__dirname, 'src'), + } + }, + server: { + port: 5174, + proxy: { + '/api': { + target: 'http://localhost:4000', + changeOrigin: true + } + } + }, + build: { + outDir: 'dist', + emptyOutDir: true + } +}) diff --git a/apps/info-site/Dockerfile b/apps/info-site/Dockerfile new file mode 100644 index 0000000..b3ffe56 --- /dev/null +++ b/apps/info-site/Dockerfile @@ -0,0 +1,20 @@ +# Use lightweight Node.js 18 alpine image +FROM node:18-alpine + +# Set working directory +WORKDIR /app + +# Copy package files first to leverage Docker cache for dependencies +COPY package*.json ./ + +# Install dependencies (only production if possible, but standard npm install is fine here) +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Expose the application port +EXPOSE 3000 + +# Start the application +CMD ["npm", "start"] diff --git a/apps/info-site/README.md b/apps/info-site/README.md new file mode 100644 index 0000000..cb4d3b3 --- /dev/null +++ b/apps/info-site/README.md @@ -0,0 +1,157 @@ +# Symbuyote - Fresh Local Shopping Platform + +A modern, responsive web application for local farm-to-consumer shopping experience. + +## Features + +- 🎨 **Modern Design**: Beautiful gradient-based UI with smooth animations +- 📱 **Responsive**: Works perfectly on all devices +- ⚡ **Fast**: Built with HTMX for dynamic content without heavy JavaScript frameworks +- 🖼️ **Rich Media**: High-quality images from Unsplash +- ✨ **Interactive**: Smooth scroll animations, hover effects, and micro-interactions +- 📧 **Newsletter**: Functional subscription form with feedback + +## Technology Stack + +- **Backend**: Node.js with Express +- **Frontend**: HTML5, CSS3, JavaScript (ES6+) +- **Dynamic Content**: HTMX +- **Styling**: Custom CSS with CSS Grid and Flexbox +- **Icons**: Font Awesome +- **Images**: Unsplash API +- **Fonts**: Google Fonts (Inter, Poppins) + +## Getting Started + +### Prerequisites + +- Node.js (v14 or higher) +- npm + +### Installation + +1. Clone the repository +2. Navigate to the info-site directory: + ```bash + cd apps/info-site + ``` + +3. Install dependencies: + ```bash + npm install + ``` + +4. Start the development server: + ```bash + npm start + ``` + +5. Open your browser and navigate to: + ``` + http://localhost:6446 + ``` + +## Project Structure + +``` +apps/info-site/ +├── public/ +│ ├── css/ +│ │ └── styles.css # Main stylesheet +│ ├── js/ +│ │ └── main.js # JavaScript interactions +│ ├── images/ +│ │ ├── logo.svg # Company logo +│ │ └── [product-images] # Product and lifestyle images +│ └── index.html # Main HTML file +├── index.js # Express server +├── package.json # Dependencies and scripts +└── README.md # This file +``` + +## Features Overview + +### Hero Section +- Eye-catching gradient background +- Compelling headline and description +- Call-to-action buttons with hover effects +- Parallax scrolling effect + +### Product Categories +- Three main categories: Meat, Fruits, Dry Fruits +- Beautiful card layouts with images +- Hover animations and transitions + +### How It Works +- Three-step process visualization +- Interactive step cards +- Clear, concise descriptions + +### Quality Promise +- Trust indicators +- Feature highlights +- Professional imagery + +### Testimonials +- Customer reviews +- Author avatars and information +- Card-based layout + +### Newsletter +- Email subscription form +- Real-time validation +- Success/error feedback + +### Footer +- Company information +- Quick links +- Social media connections +- Copyright information + +## Customization + +### Colors +The color scheme is defined in CSS variables: +- Primary: `#F83758` (Coral Red) +- Secondary: `#FF6B9D` (Pink) +- Accent: `#4ECDC4` (Teal) +- Background: `#fff0f6` (Light Pink) + +### Images +Replace images in the `public/images/` directory. Current images are from Unsplash and loaded via CDN. + +### Content +Edit the HTML content in `public/index.html` to modify text, add new sections, or change the structure. + +## Deployment + +### Environment Variables +- `PORT`: Server port (default: 6446) + +### Production Setup +1. Set NODE_ENV to production +2. Configure your preferred port +3. Deploy to your hosting platform + +## Browser Support + +- Chrome/Chromium (latest) +- Firefox (latest) +- Safari (latest) +- Edge (latest) + +## Contributing + +1. Fork the repository +2. Create a feature branch +3. Make your changes +4. Test thoroughly +5. Submit a pull request + +## License + +This project is proprietary to Symbuyote. + +## Support + +For support or questions, please contact the development team. \ No newline at end of file diff --git a/apps/info-site/index.js b/apps/info-site/index.js new file mode 100644 index 0000000..1225c25 --- /dev/null +++ b/apps/info-site/index.js @@ -0,0 +1,61 @@ +const express = require('express'); +const path = require('path'); + +const app = express(); + +app.use(express.urlencoded({ extended: true })); + +// Set up Pug as the view engine +app.set('view engine', 'pug'); +app.set('views', path.join(__dirname, 'views')); + +// Serve static files +app.use(express.static(path.join(__dirname, 'public'))); + +// Home route +app.get('/', (_, res) => { + res.render('index', { + title: 'Freshyo - Freshness Redefined', + year: new Date().getFullYear() + }); +}); + +// Privacy Policy route +app.get('/privacy-policy', (_, res) => { + res.render('policy', { + title: 'Freshyo - Privacy Policy', + year: new Date().getFullYear() + }); +}); + +// Delete Account route +app.get('/delete-account', (_, res) => { + res.render('delete', { + title: 'Freshyo - Delete Account', + year: new Date().getFullYear() + }); +}); + +// Handle Delete Account submission +app.post('/delete-account', (req, res) => { + const { mobile } = req.body; + console.log(`Received deletion request for: ${mobile}`); + + res.render('success', { + title: 'Freshyo - Request Submitted', + year: new Date().getFullYear() + }); +}); + +// QR-based download route +app.get('/qr-based-download', (_, res) => { + res.render('qr-download', { + title: 'Freshyo - Download App', + year: new Date().getFullYear() + }); +}); + +const PORT = process.env.PORT || 3000; +app.listen(PORT, () => { + console.log(`✨ Freshyo FRESH info site running at http://localhost:${PORT}`); +}); \ No newline at end of file diff --git a/apps/info-site/package.json b/apps/info-site/package.json new file mode 100644 index 0000000..295029b --- /dev/null +++ b/apps/info-site/package.json @@ -0,0 +1,14 @@ +{ + "name": "symbuyote-info-site", + "version": "1.0.0", + "description": "Info website for Freshyo - Local trust, online convenience", + "main": "index.js", + "scripts": { + "start": "node index.js", + "docker:deploy": "docker buildx build --platform linux/amd64 -t mohdshafiuddin54/freshyo-info:latest . && docker push mohdshafiuddin54/freshyo-info:latest" + }, + "dependencies": { + "express": "^4.18.2", + "pug": "^3.0.2" + } +} \ No newline at end of file diff --git a/apps/info-site/public/css/styles.css b/apps/info-site/public/css/styles.css new file mode 100644 index 0000000..f793f31 --- /dev/null +++ b/apps/info-site/public/css/styles.css @@ -0,0 +1,796 @@ +@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap'); + +:root { + /* Brand Colors - Matching user-ui app */ + --brand-25: #F5FAFF; + --brand-50: #EFF8FF; + --brand-100: #D1E9FF; + --brand-200: #B2DDFF; + --brand-300: #84CAFF; + --brand-400: #53B1FD; + --brand-500: #2E90FA; + --brand-600: #1570EF; + --brand-700: #175CD3; + --brand-800: #1849A9; + --brand-900: #194185; + + /* Semantic Colors */ + --primary: var(--brand-500); + --primary-dark: var(--brand-600); + --primary-light: var(--brand-400); + --success: #22C55E; + --warning: #F59E0B; + --error: #EF4444; + + /* Grays */ + --gray-50: #FAFAFA; + --gray-100: #F5F5F5; + --gray-200: #E9EAEB; + --gray-300: #D5D7DA; + --gray-400: #A4A7AE; + --gray-500: #717680; + --gray-600: #535862; + --gray-700: #414651; + --gray-800: #252B37; + --gray-900: #101828; + + /* Spacing */ + --spacing-xs: 0.25rem; + --spacing-sm: 0.5rem; + --spacing-md: 1rem; + --spacing-lg: 1.5rem; + --spacing-xl: 2rem; + --spacing-2xl: 3rem; + + /* Border Radius */ + --radius-sm: 8px; + --radius-md: 12px; + --radius-lg: 16px; + --radius-xl: 24px; + --radius-full: 9999px; + + /* Shadows */ + --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05); + --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); + --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); + --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); + + /* Container */ + --container-max: 480px; + --nav-height: 70px; +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +html { + font-size: 16px; +} + +body { + font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + background-color: var(--brand-50); + color: var(--gray-900); + line-height: 1.5; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* Typography */ +h1 { + font-size: 2rem; + font-weight: 800; + color: var(--gray-900); + line-height: 1.2; +} + +h2 { + font-size: 1.5rem; + font-weight: 700; + color: var(--gray-900); + line-height: 1.3; +} + +h3 { + font-size: 1.25rem; + font-weight: 600; + color: var(--gray-900); + line-height: 1.4; +} + +p { + font-size: 1rem; + color: var(--gray-600); + line-height: 1.6; +} + +a { + color: var(--brand-500); + text-decoration: none; + transition: color 0.2s ease; +} + +a:hover { + color: var(--brand-600); +} + +/* App Container - Mobile First */ +.app-container { + min-height: 100vh; + display: flex; + flex-direction: column; + background-color: var(--brand-50); +} + +.app-content { + flex: 1; + padding: var(--spacing-lg); + max-width: var(--container-max); + margin: 0 auto; + width: 100%; + padding-top: calc(var(--nav-height) + var(--spacing-lg)); +} + +/* Navigation - Mobile App Style */ +.nav { + position: fixed; + top: 0; + left: 50%; + transform: translateX(-50%); + width: 100%; + max-width: var(--container-max); + height: var(--nav-height); + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 var(--spacing-lg); + background: rgba(255, 255, 255, 0.95); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); + border-bottom: 1px solid var(--gray-100); + z-index: 1000; +} + +.nav-logo { + display: flex; + align-items: center; + gap: var(--spacing-sm); + font-size: 1.25rem; + font-weight: 800; + color: var(--brand-600); +} + +.nav-logo svg, +.nav-logo i { + width: 28px; + height: 28px; + color: var(--brand-500); +} + +.nav-links { + display: flex; + gap: var(--spacing-md); + list-style: none; +} + +.nav-links a { + font-size: 0.875rem; + font-weight: 500; + color: var(--gray-600); + padding: var(--spacing-sm) var(--spacing-md); + border-radius: var(--radius-full); + transition: all 0.2s ease; +} + +.nav-links a:hover, +.nav-links a.active { + color: var(--brand-500); + background-color: var(--brand-50); +} + +/* Cards */ +.card { + background: white; + border-radius: var(--radius-xl); + padding: var(--spacing-xl); + box-shadow: var(--shadow-md); + border: 1px solid var(--gray-100); + margin-bottom: var(--spacing-lg); +} + +.card-header { + margin-bottom: var(--spacing-lg); + padding-bottom: var(--spacing-md); + border-bottom: 1px solid var(--gray-100); +} + +.card-header h2 { + margin-bottom: var(--spacing-xs); +} + +.card-header p { + font-size: 0.875rem; +} + +/* Buttons */ +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--spacing-sm); + padding: var(--spacing-md) var(--spacing-xl); + border-radius: var(--radius-lg); + font-size: 1rem; + font-weight: 600; + border: none; + cursor: pointer; + transition: all 0.2s ease; + text-decoration: none; +} + +.btn-primary { + background: var(--brand-500); + color: white; + box-shadow: 0 4px 14px rgba(46, 144, 250, 0.4); +} + +.btn-primary:hover { + background: var(--brand-600); + transform: translateY(-2px); + box-shadow: 0 6px 20px rgba(46, 144, 250, 0.5); +} + +.btn-secondary { + background: white; + color: var(--gray-700); + border: 1px solid var(--gray-200); +} + +.btn-secondary:hover { + background: var(--gray-50); + border-color: var(--gray-300); +} + +.btn-danger { + background: var(--error); + color: white; +} + +.btn-danger:hover { + background: #DC2626; +} + +.btn-sm { + padding: var(--spacing-sm) var(--spacing-md); + font-size: 0.875rem; +} + +.btn-lg { + padding: var(--spacing-lg) var(--spacing-2xl); + font-size: 1.125rem; +} + +/* Form Elements */ +.form-group { + margin-bottom: var(--spacing-lg); +} + +.form-label { + display: block; + font-size: 0.875rem; + font-weight: 500; + color: var(--gray-700); + margin-bottom: var(--spacing-sm); +} + +.form-input { + width: 100%; + padding: var(--spacing-md); + border: 1px solid var(--gray-200); + border-radius: var(--radius-md); + font-size: 1rem; + font-family: inherit; + transition: all 0.2s ease; + background: white; +} + +.form-input:focus { + outline: none; + border-color: var(--brand-500); + box-shadow: 0 0 0 3px rgba(46, 144, 250, 0.1); +} + +.form-input::placeholder { + color: var(--gray-400); +} + +/* Feature Items */ +.feature-grid { + display: grid; + gap: var(--spacing-lg); + margin: var(--spacing-xl) 0; +} + +.feature-item { + display: flex; + align-items: flex-start; + gap: var(--spacing-md); + padding: var(--spacing-lg); + background: white; + border-radius: var(--radius-lg); + border: 1px solid var(--gray-100); +} + +.feature-icon { + width: 48px; + height: 48px; + display: flex; + align-items: center; + justify-content: center; + background: var(--brand-50); + border-radius: var(--radius-md); + color: var(--brand-500); + font-size: 1.25rem; + flex-shrink: 0; +} + +.feature-content h3 { + margin-bottom: var(--spacing-xs); +} + +.feature-content p { + font-size: 0.875rem; +} + +/* Stats */ +.stats-row { + display: flex; + justify-content: space-around; + gap: var(--spacing-md); + padding: var(--spacing-xl); + background: var(--brand-500); + border-radius: var(--radius-xl); + margin: var(--spacing-xl) 0; +} + +.stat-item { + text-align: center; + color: white; +} + +.stat-value { + font-size: 2rem; + font-weight: 800; + display: block; +} + +.stat-label { + font-size: 0.875rem; + opacity: 0.9; +} + +/* Footer */ +.footer { + background: white; + padding: var(--spacing-xl); + margin-top: var(--spacing-2xl); + border-top: 1px solid var(--gray-100); +} + +.footer-content { + max-width: var(--container-max); + margin: 0 auto; + display: flex; + flex-direction: column; + gap: var(--spacing-lg); + text-align: center; +} + +.footer-brand { + display: flex; + align-items: center; + justify-content: center; + gap: var(--spacing-sm); + font-size: 1.25rem; + font-weight: 700; + color: var(--brand-600); +} + +.footer-brand svg, +.footer-brand i { + color: var(--brand-500); +} + +.footer-links { + display: flex; + justify-content: center; + gap: var(--spacing-lg); + flex-wrap: wrap; +} + +.footer-links a { + color: var(--gray-500); + font-size: 0.875rem; +} + +.footer-copyright { + font-size: 0.75rem; + color: var(--gray-400); +} + +/* Hero Section */ +.hero { + text-align: center; + padding: var(--spacing-2xl) 0; +} + +.hero-badge { + display: inline-block; + padding: var(--spacing-xs) var(--spacing-md); + background: var(--brand-100); + color: var(--brand-700); + font-size: 0.75rem; + font-weight: 600; + border-radius: var(--radius-full); + margin-bottom: var(--spacing-md); + text-transform: uppercase; + letter-spacing: 0.05em; +} + +.hero h1 { + margin-bottom: var(--spacing-md); +} + +.hero p { + margin-bottom: var(--spacing-xl); + max-width: 100%; +} + +.hero-actions { + display: flex; + flex-direction: column; + gap: var(--spacing-md); + align-items: center; +} + +/* Section Headers */ +.section-header { + margin-bottom: var(--spacing-xl); + text-align: center; +} + +.section-header h2 { + margin-bottom: var(--spacing-sm); +} + +.section-header p { + font-size: 0.875rem; +} + +/* Alert/Banner */ +.alert { + padding: var(--spacing-md); + border-radius: var(--radius-md); + margin-bottom: var(--spacing-lg); +} + +.alert-info { + background: var(--brand-50); + border: 1px solid var(--brand-100); + color: var(--brand-700); +} + +.alert-warning { + background: #FFFBEB; + border: 1px solid #FDE68A; + color: #B45309; +} + +.alert-danger { + background: #FEF2F2; + border: 1px solid #FECACA; + color: #B91C1C; +} + +.alert-success { + background: #F0FDF4; + border: 1px solid #BBF7D0; + color: #15803D; +} + +/* Icon styles */ +.icon { + display: inline-flex; + align-items: center; + justify-content: center; +} + +.icon-sm { font-size: 1rem; } +.icon-md { font-size: 1.25rem; } +.icon-lg { font-size: 1.5rem; } +.icon-xl { font-size: 2rem; } + +/* Utility Classes */ +.text-center { text-align: center; } +.text-left { text-align: left; } +.text-right { text-align: right; } + +.mt-sm { margin-top: var(--spacing-sm); } +.mt-md { margin-top: var(--spacing-md); } +.mt-lg { margin-top: var(--spacing-lg); } +.mt-xl { margin-top: var(--spacing-xl); } + +.mb-sm { margin-bottom: var(--spacing-sm); } +.mb-md { margin-bottom: var(--spacing-md); } +.mb-lg { margin-bottom: var(--spacing-lg); } +.mb-xl { margin-bottom: var(--spacing-xl); } + +.flex { display: flex; } +.flex-col { flex-direction: column; } +.items-center { align-items: center; } +.justify-center { justify-content: center; } +.justify-between { justify-content: space-between; } +.gap-sm { gap: var(--spacing-sm); } +.gap-md { gap: var(--spacing-md); } +.gap-lg { gap: var(--spacing-lg); } + +/* Responsive */ +@media (min-width: 768px) { + :root { + --container-max: 700px; + } + + h1 { + font-size: 2.5rem; + } + + .hero-actions { + flex-direction: row; + } + + .feature-grid { + grid-template-columns: repeat(2, 1fr); + } + + .footer-content { + flex-direction: row; + justify-content: space-between; + text-align: left; + } +} + +@media (min-width: 1024px) { + :root { + --container-max: 800px; + } + + .feature-grid { + grid-template-columns: repeat(3, 1fr); + } +} + +/* Animations */ +@keyframes fadeIn { + from { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); } +} + +.animate-fade-in { + animation: fadeIn 0.5s ease forwards; +} + +@keyframes pulse { + 0%, 100% { opacity: 1; } + 50% { opacity: 0.5; } +} + +.animate-pulse { + animation: pulse 2s ease-in-out infinite; +} + +/* Back Link */ +.back-link { + display: inline-flex; + align-items: center; + gap: var(--spacing-sm); + color: var(--brand-500); + font-weight: 500; + margin-bottom: var(--spacing-lg); + transition: opacity 0.2s; +} + +.back-link:hover { + opacity: 0.8; +} + +/* Policy Page Specific */ +.policy-content { + background: white; + border-radius: var(--radius-xl); + padding: var(--spacing-xl); + box-shadow: var(--shadow-md); +} + +.policy-content h1 { + margin-bottom: var(--spacing-md); +} + +.policy-content h2 { + margin-top: var(--spacing-xl); + margin-bottom: var(--spacing-md); + font-size: 1.25rem; +} + +.policy-content p, +.policy-content li { + color: var(--gray-600); + margin-bottom: var(--spacing-md); + line-height: 1.7; +} + +.policy-content ul { + padding-left: var(--spacing-xl); + margin-bottom: var(--spacing-lg); +} + +/* Download Page Specific */ +.download-container { + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + padding: var(--spacing-lg); + background: linear-gradient(180deg, var(--brand-50) 0%, white 100%); +} + +.download-card { + background: white; + border-radius: var(--radius-xl); + padding: var(--spacing-2xl); + box-shadow: var(--shadow-xl); + text-align: center; + max-width: 400px; + width: 100%; +} + +.download-options { + display: flex; + flex-direction: column; + gap: var(--spacing-md); + margin-top: var(--spacing-xl); +} + +.download-option { + display: flex; + align-items: center; + gap: var(--spacing-md); + padding: var(--spacing-lg); + background: white; + border: 2px solid var(--gray-200); + border-radius: var(--radius-lg); + text-decoration: none; + color: var(--gray-900); + transition: all 0.2s ease; +} + +.download-option:hover { + border-color: var(--brand-300); + transform: translateX(4px); + box-shadow: var(--shadow-md); +} + +.download-option.android:hover { + border-color: #3DDC84; +} + +.download-option.ios:hover { + border-color: var(--brand-500); +} + +.download-icon { + width: 48px; + height: 48px; + display: flex; + align-items: center; + justify-content: center; + border-radius: var(--radius-md); + font-size: 1.5rem; + color: white; +} + +.download-icon.android { + background: linear-gradient(135deg, #3DDC84 0%, #2AA852 100%); +} + +.download-icon.ios { + background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 100%); +} + +.download-info { + text-align: left; + flex: 1; +} + +.download-info h3 { + font-size: 1rem; + margin-bottom: 2px; +} + +.download-info p { + font-size: 0.75rem; + color: var(--gray-500); +} + +/* Success Page */ +.success-container { + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + padding: var(--spacing-lg); +} + +.success-card { + background: white; + border-radius: var(--radius-xl); + padding: var(--spacing-2xl); + box-shadow: var(--shadow-xl); + text-align: center; + max-width: 400px; + width: 100%; +} + +.success-icon { + font-size: 4rem; + color: var(--success); + margin-bottom: var(--spacing-lg); +} + +/* Delete Account Page */ +.delete-container { + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + padding: var(--spacing-lg); + background: var(--brand-50); +} + +.delete-card { + background: white; + border-radius: var(--radius-xl); + padding: var(--spacing-2xl); + box-shadow: var(--shadow-xl); + max-width: 450px; + width: 100%; +} + +.warning-icon { + font-size: 3rem; + color: var(--error); + margin-bottom: var(--spacing-lg); + display: block; + text-align: center; +} + +.delete-card h1 { + text-align: center; + margin-bottom: var(--spacing-md); +} + +.delete-card p { + text-align: center; + margin-bottom: var(--spacing-xl); +} + +.delete-card .form-group { + margin-bottom: var(--spacing-lg); +} + +.delete-card .btn-danger { + width: 100%; + margin-top: var(--spacing-md); +} diff --git a/apps/info-site/views/delete.pug b/apps/info-site/views/delete.pug new file mode 100644 index 0000000..2aca558 --- /dev/null +++ b/apps/info-site/views/delete.pug @@ -0,0 +1,51 @@ +doctype html +html(lang="en") + head + meta(charset="utf-8") + meta(name="viewport" content="width=device-width, initial-scale=1") + title= title + link(rel="stylesheet" href="/css/styles.css") + + body + .app-container + // Navigation + nav.nav + a.nav-logo(href="/") + svg(width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + path(d="M12 6v6l4 2") + span Freshyo + ul.nav-links + li: a(href="/privacy-policy") Back to Policy + + // Main Content + .app-content + .delete-card + a.back-link(href="/privacy-policy") + span ← Back to Privacy Policy + + span.warning-icon ! + h1 Delete Account + p To delete your account and personal data, please verify your mobile number. This action cannot be undone. + + form(action="/delete-account" method="POST") + .form-group + label.form-label(for="mobile") Mobile Number + input#mobile.form-input(type="tel" name="mobile" placeholder="+91 99999 99999" required minlength="10") + + button.btn.btn-danger(type="submit") + span Delete My Account + + // Footer + footer.footer + .footer-content + .footer-brand + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + span Freshyo + .footer-links + a(href="#") For Farmers + a(href="#") For Consumers + a(href="/privacy-policy") Privacy Policy + a(href="/delete-account") Delete Account + p.footer-copyright © #{year} Freshyo Inc. diff --git a/apps/info-site/views/index.pug b/apps/info-site/views/index.pug new file mode 100644 index 0000000..7b4b045 --- /dev/null +++ b/apps/info-site/views/index.pug @@ -0,0 +1,93 @@ +doctype html +html(lang="en") + head + meta(charset="utf-8") + meta(name="viewport" content="width=device-width, initial-scale=1") + title= title + link(rel="stylesheet" href="/css/styles.css") + + body + .app-container + // Navigation + nav.nav + a.nav-logo(href="/") + svg(width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + path(d="M12 6v6l4 2") + span Freshyo + ul.nav-links + li: a(href="#features") Features + li: a(href="/privacy-policy") Privacy + + // Main Content + .app-content + // Hero Section + section.hero + span.hero-badge Fresh & Healthy + h1 Fresh Meat, Fruits & Veggies + p Experience the true taste of nature. 100% organic, fresh products delivered to your doorstep. + .hero-actions + a.btn.btn-primary(href="/qr-based-download") + span Download App + span.icon-sm → + a.btn.btn-secondary(href="#features") Learn More + + // Features Section + section.section-header#features + h2 Why Choose Freshyo? + p Building an ecosystem where freshness meets fairness + + .feature-grid + .feature-item(data-aos="fade-up") + .feature-icon + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z") + path(d="M12 6v6l4 2") + .feature-content + h3 Farm Fresh & Healthy + p Nutrient-rich products straight from nature, packed with health and vitality + + .feature-item(data-aos="fade-up") + .feature-icon + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + rect(x="1" y="3" width="15" height="13") + polygon(points="16 8 20 8 23 11 23 16 16 16 16 8") + circle cx="5.5" cy="18.5" r="2.5" + circle cx="18.5" cy="18.5" r="2.5" + .feature-content + h3 Trusted Delivery + p Farm to your doorstep with care. Freshness guaranteed, no preservatives + + .feature-item(data-aos="fade-up") + .feature-icon + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z") + .feature-content + h3 Quality Assured + p Every product vetted for quality. If it's not good enough for our family, it's not for yours + + // Stats Section + .stats-row + .stat-item + span.stat-value 500+ + span.stat-label Farmers + .stat-item + span.stat-value 10K+ + span.stat-label Families + .stat-item + span.stat-value 100% + span.stat-label Organic + + // Footer + footer.footer + .footer-content + .footer-brand + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + span Freshyo + .footer-links + a(href="#") For Farmers + a(href="#") For Consumers + a(href="/privacy-policy") Privacy Policy + a(href="/delete-account") Delete Account + p.footer-copyright © #{year} Freshyo Inc. diff --git a/apps/info-site/views/policy.pug b/apps/info-site/views/policy.pug new file mode 100644 index 0000000..6adb7f1 --- /dev/null +++ b/apps/info-site/views/policy.pug @@ -0,0 +1,66 @@ +doctype html +html(lang="en") + head + meta(charset="utf-8") + meta(name="viewport" content="width=device-width, initial-scale=1") + title= title + link(rel="stylesheet" href="/css/styles.css") + + body + .app-container + // Navigation + nav.nav + a.nav-logo(href="/") + svg(width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + path(d="M12 6v6l4 2") + span Freshyo + ul.nav-links + li: a(href="/") Home + li: a(href="/privacy-policy" class="active") Privacy + + // Main Content + .app-content + .policy-content + a.back-link(href="/") + span ← Back to Home + + h1 Privacy Policy + p.last-updated Last Updated: December 18, 2025 + + p At Freshyo, we value your trust and are committed to protecting your personal information. This Privacy Policy explains how we collect, use, and safeguard your data when you use our website and services. + + h2 1. Information We Collect + p We collect information that you provide directly to us, such as when you create an account, place an order, or contact customer support. This may include your name, email address, phone number, and delivery address. + + h2 2. How We Use Your Information + p We use your information to: + ul + li Process and deliver your orders for fresh meat, fruits, and veggies + li Communicate with you regarding order updates and promotions + li Improve our platform and user experience + li Ensure the security of our services + + h2 3. Data Protection + p We implement industry-standard security measures to protect your personal data. We do not sell your personal information to third parties. + + h2 4. Contact Us + p If you have any questions about this Privacy Policy, please contact us at support@freshyo.com. + + h2 5. Data Deletion + p You have the right to request the deletion of your personal data. If you wish to delete your account: + a.btn.btn-danger(href="/delete-account" style="margin-top: 1rem; display: inline-flex;") Delete My Account + + // Footer + footer.footer + .footer-content + .footer-brand + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + span Freshyo + .footer-links + a(href="#") For Farmers + a(href="#") For Consumers + a(href="/privacy-policy") Privacy Policy + a(href="/delete-account") Delete Account + p.footer-copyright © #{year} Freshyo Inc. diff --git a/apps/info-site/views/qr-download.pug b/apps/info-site/views/qr-download.pug new file mode 100644 index 0000000..8dadc85 --- /dev/null +++ b/apps/info-site/views/qr-download.pug @@ -0,0 +1,68 @@ +doctype html +html(lang="en") + head + meta(charset="utf-8") + meta(name="viewport" content="width=device-width, initial-scale=1") + title= title + link(rel="stylesheet", href="/css/styles.css") + + body + .download-container + .download-card + a.back-link(href="/") + span ← Back to Home + + h1 Download Freshyo + p Experience the true taste of nature on your device + + .download-options + a.download-option.android(href="intent://play.google.com/store/apps/details?id=in.freshyo.app#Intent;scheme=https;package=com.android.vending;end;", onclick="handleAndroidClick(event)") + .download-icon.android + svg(width="24" height="24" viewBox="0 0 24 24" fill="currentColor") + path(d="M17.6 9.48l1.84-3.18c.16-.31.04-.69-.26-.85-.29-.15-.65-.06-.83.22l-1.88 3.24a11.463 11.463 0 0 0-8.94 0L5.65 5.67c-.19-.29-.58-.38-.87-.2-.28.18-.37.54-.22.83L6.4 9.48A10.78 10.78 0 0 0 1 18h22a10.78 10.78 0 0 0-5.4-8.52zM7 15.25a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5zm10 0a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5z") + .download-info + h3 Android + p Google Play Store + + a.download-option.ios(href="https://apps.apple.com/in/app/freshyo/id6756889077", onclick="handleIOSClick(event)") + .download-icon.ios + svg(width="24" height="24" viewBox="0 0 24 24" fill="currentColor") + path(d="M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.21-1.96 1.07-3.11-1.05.05-2.31.7-3.06 1.58-.68.77-1.28 2-1.12 3.16 1.19.09 2.41-.79 3.11-1.63z") + .download-info + h3 iOS + p Apple App Store + + p.mt-lg(style="font-size: 0.75rem; color: var(--gray-500);") If you are not redirected automatically, tap above + + script. + const ANDROID_URL = 'intent://play.google.com/store/apps/details?id=in.freshyo.app#Intent;scheme=https;package=com.android.vending;end;'; + const IOS_URL = 'https://apps.apple.com/in/app/freshyo/id6756889077'; + + function detectOS() { + const userAgent = navigator.userAgent || navigator.vendor || window.opera; + if (/android/i.test(userAgent)) return 'android'; + if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) return 'ios'; + return 'unknown'; + } + + function redirectToStore() { + const os = detectOS(); + + if (os === 'android') { + window.location.href = ANDROID_URL; + } else if (os === 'ios') { + window.location.href = IOS_URL; + } + } + + function handleAndroidClick(event) { + event.preventDefault(); + window.location.href = ANDROID_URL; + } + + function handleIOSClick(event) { + event.preventDefault(); + window.location.href = IOS_URL; + } + + window.addEventListener('load', redirectToStore); diff --git a/apps/info-site/views/success.pug b/apps/info-site/views/success.pug new file mode 100644 index 0000000..0112f6d --- /dev/null +++ b/apps/info-site/views/success.pug @@ -0,0 +1,41 @@ +doctype html +html(lang="en") + head + meta(charset="utf-8") + meta(name="viewport" content="width=device-width, initial-scale=1") + title= title + link(rel="stylesheet" href="/css/styles.css") + + body + .app-container + // Navigation + nav.nav + a.nav-logo(href="/") + svg(width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + path(d="M12 6v6l4 2") + span Freshyo + ul.nav-links + li: a(href="/") Back to Home + + // Main Content + .app-content + .success-card + span.success-icon ✓ + h1 Request Received + p Your request to delete your account has been submitted successfully. Your data will be permanently removed within 7 days. + a.btn.btn-primary(href="/") Back to Home + + // Footer + footer.footer + .footer-content + .footer-brand + svg(width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2") + path(d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z") + span Freshyo + .footer-links + a(href="#") For Farmers + a(href="#") For Consumers + a(href="/privacy-policy") Privacy Policy + a(href="/delete-account") Delete Account + p.footer-copyright © #{year} Freshyo Inc. diff --git a/apps/user-ui/.env b/apps/user-ui/.env new file mode 100644 index 0000000..f16b4c8 --- /dev/null +++ b/apps/user-ui/.env @@ -0,0 +1,14 @@ + + GOOGLE_CLIENT_ID=241178308178-olp71t2dq9fs09jrmcbhkr14db8mdhmt.apps.googleusercontent.com + APP_SCHEME=freshyo:// + BASE_URL=http://localhost:8081 + GOOGLE_AUTH_URL=https://accounts.google.com/o/oauth2/v2/auth + + +androidClientId = 241178308178-t33436b5agbcnsrs1o36jr3fh1s0g8i8.apps.googleusercontent.com +iosClientId = 241178308178-59kajtcjos0anpricj37m5u2t1b957es.apps.googleusercontent.com +androidDebugClientId = 241178308178-t33436b5agbcnsrs1o36jr3fh1s0g8i8.apps.googleusercontent.com +desktopClientId = 241178308178-js4dorresvnfarpu3d05f3rluubsm3rt.apps.googleusercontent.com +desktopClientSecret = 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y +webClientId = 241178308178-olp71t2dq9fs09jrmcbhkr14db8mdhmt.apps.googleusercontent.com +webClientSecret = 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 \ No newline at end of file diff --git a/apps/user-ui/.gitignore b/apps/user-ui/.gitignore new file mode 100755 index 0000000..09ca3ac --- /dev/null +++ b/apps/user-ui/.gitignore @@ -0,0 +1,7 @@ + +# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb +# The following patterns were generated by expo-cli + +expo-env.d.ts +.expo/ +# @end expo-cli \ No newline at end of file diff --git a/apps/user-ui/README.md b/apps/user-ui/README.md new file mode 100755 index 0000000..48dd63f --- /dev/null +++ b/apps/user-ui/README.md @@ -0,0 +1,50 @@ +# Welcome to your Expo app 👋 + +This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app). + +## Get started + +1. Install dependencies + + ```bash + npm install + ``` + +2. Start the app + + ```bash + npx expo start + ``` + +In the output, you'll find options to open the app in a + +- [development build](https://docs.expo.dev/develop/development-builds/introduction/) +- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/) +- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/) +- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo + +You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction). + +## Get a fresh project + +When you're ready, run: + +```bash +npm run reset-project +``` + +This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing. + +## Learn more + +To learn more about developing your project with Expo, look at the following resources: + +- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides). +- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web. + +## Join the community + +Join our community of developers creating universal apps. + +- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute. +- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions. diff --git a/apps/user-ui/app.json b/apps/user-ui/app.json new file mode 100644 index 0000000..91d3f2e --- /dev/null +++ b/apps/user-ui/app.json @@ -0,0 +1,108 @@ +{ + "expo": { + "name": "Freshyo", + "slug": "freshyo", + "version": "1.1.0", + "orientation": "portrait", + "icon": "./assets/images/freshyo-logo.png", + "scheme": "freshyo", + "userInterfaceStyle": "automatic", + "newArchEnabled": true, + "ios": { + "buildNumber": "1.1.0", + "supportsTablet": true, + "bundleIdentifier": "com.freshyotrial.app", + "infoPlist": { + "LSApplicationQueriesSchemes": [ + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay", + "ppemerchantsdkv1", + "ppemerchantsdkv2", + "ppemerchantsdkv3", + "paytmmp", + "gpay" + ], + "ITSAppUsesNonExemptEncryption": false, + "NSPhotoLibraryUsageDescription": "This app uses photo library to allow users to upload pictures as a part or product's review and feedback.", + "NSLocationWhenInUseUsageDescription": "This app uses your location to decide if your place is serviceable or not." + } + }, + "android": { + "softwareKeyboardLayoutMode": "resize", + "adaptiveIcon": { + "foregroundImage": "./assets/images/freshyo-logo.png", + "backgroundColor": "#fff0f6" + }, + "edgeToEdgeEnabled": true, + "package": "in.freshyo.app" + }, + "web": { + "bundler": "metro", + "output": "static", + "favicon": "./assets/images/favicon.png" + }, + "plugins": [ + "expo-router", + [ + "expo-splash-screen", + { + "image": "./assets/images/freshyo-logo.png", + "imageWidth": 200, + "resizeMode": "contain", + "backgroundColor": "#ffffff" + } + ], + "expo-secure-store" + ], + "experiments": { + "typedRoutes": true + }, + "extra": { + "router": {}, + "eas": { + "projectId": "7f3e7611-f7a8-45f9-8a99-c2b1f6454d48" + } + }, + "runtimeVersion": { + "policy": "appVersion" + + }, + "updates": { + "url": "https://u.expo.dev/7f3e7611-f7a8-45f9-8a99-c2b1f6454d48" + }, + "owner": "mohammedshafiuddin54" + } +} diff --git a/apps/user-ui/app/(auth)/_layout.tsx b/apps/user-ui/app/(auth)/_layout.tsx new file mode 100644 index 0000000..9bacb41 --- /dev/null +++ b/apps/user-ui/app/(auth)/_layout.tsx @@ -0,0 +1,20 @@ +import { Stack, Redirect } from 'expo-router'; +import { View, ActivityIndicator } from 'react-native'; +import { tw } from 'common-ui'; +import { useAuth } from '@/src/contexts/AuthContext'; + +export default function AuthLayout() { + const { isAuthenticated, isLoading } = useAuth(); + + if (isLoading) { + return ( + + + + ); + } + + return ( + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(auth)/login.tsx b/apps/user-ui/app/(auth)/login.tsx new file mode 100644 index 0000000..98a86df --- /dev/null +++ b/apps/user-ui/app/(auth)/login.tsx @@ -0,0 +1,492 @@ +import React, { useState, useEffect, useRef } from "react"; +import { View, Alert, TextInput } from "react-native"; +import { useForm, Controller } from "react-hook-form"; + +import { MyButton, MyText, MyTextInput, tw, StorageServiceCasual, colors, MyTouchableOpacity } from "common-ui"; +import { useAuth } from "@/src/contexts/AuthContext"; +import { trpc } from '@/src/trpc-client'; +import GoogleSignInPKCE from "common-ui/src/components/google-sign-in"; +import { LinearGradient } from "expo-linear-gradient"; +import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; +import { SafeAreaView } from "react-native-safe-area-context"; + +interface LoginFormInputs { + mobile: string; + otp?: string; + password?: string; +} + +function Login() { + const { loginWithToken } = useAuth(); + const [isLoading, setIsLoading] = useState(false); + const [step, setStep] = useState<'mobile' | 'choice' | 'otp' | 'password'>('mobile'); + const [selectedMobile, setSelectedMobile] = useState(''); + const [canResend, setCanResend] = useState(false); + const [resendCountdown, setResendCountdown] = useState(0); + const [otpCells, setOtpCells] = useState(['', '', '', '']); + const intervalRef = useRef(null); + const inputRefs = useRef<(TextInput | null)[]>([null, null, null, null]); + + const loginMutation = trpc.user.auth.login.useMutation(); + // const loginMutation = useLogin(); + + // Check for stored OTP timestamp on mount + useEffect(() => { + const checkStoredOtpTime = async () => { + const storedTime = await StorageServiceCasual.getItem('otp_sent_time'); + if (storedTime) { + const timeDiff = Date.now() - parseInt(storedTime); + const remainingTime = Math.max(0, 120 - Math.floor(timeDiff / 1000)); + + if (remainingTime > 0) { + setResendCountdown(remainingTime); + setCanResend(false); + } else { + setCanResend(true); + setResendCountdown(0); + } + } else { + setCanResend(true); + } + }; + + checkStoredOtpTime(); + }, []); + + // Cleanup interval on unmount + useEffect(() => { + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + }; + }, []); + + // Countdown timer effect + useEffect(() => { + // Clear existing interval + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + + if (resendCountdown > 0) { + // Set new interval and attach to ref + intervalRef.current = setInterval(() => { + setResendCountdown((prev) => { + if (prev <= 1) { + setCanResend(true); + return 0; + } + return prev - 1; + }); + }, 1000); + } + + return () => { + // Cleanup on unmount or dependency change + if (intervalRef.current) { + clearInterval(intervalRef.current); + intervalRef.current = null; + } + }; + }, [resendCountdown]); + + + + const sendOtpMutation = trpc.user.auth.sendOtp.useMutation({ + onSuccess: async (data) => { + if (data.success) { + // Save the current timestamp for resend cooldown + await StorageServiceCasual.setItem('otp_sent_time', Date.now().toString()); + setResendCountdown(120); // 2 minutes + setCanResend(false); + setStep('otp'); + Alert.alert('Success', data.message); + } else { + Alert.alert('Error', data.message); + } + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to send OTP'); + }, + }); + + const verifyOtpMutation = trpc.user.auth.verifyOtp.useMutation({ + onSuccess: (data) => { + if (data.success && data.token && data.user) { + loginWithToken(data.token, data.user); + } else { + Alert.alert('Error', 'Verification failed'); + } + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Invalid OTP'); + }, + }); + + + + const { + control, + handleSubmit, + formState: { errors }, + setError, + clearErrors, + setValue, + } = useForm({ + defaultValues: { mobile: "", otp: "", password: "" }, + }); + + const validateMobile = (mobile: string): boolean => { + // Remove all non-digit characters + const cleanMobile = mobile.replace(/\D/g, ''); + // Check if it's a valid Indian mobile number (10 digits, starts with 6-9) + return cleanMobile.length === 10 && /^[6-9]/.test(cleanMobile); + }; + + const handleOtpChange = (index: number, text: string) => { + // Handle paste (multiple characters) + if (text.length > 1) { + const digits = text.replace(/\D/g, '').slice(0, 4); + const newCells = digits.split('').concat(['', '', '', '']).slice(0, 4); + setOtpCells(newCells); + const combined = newCells.join(''); + setValue('otp', combined); + // Focus last filled cell + const lastIndex = Math.min(digits.length - 1, 3); + inputRefs.current[lastIndex]?.focus(); + return; + } + + // Handle single digit input + const newCells = [...otpCells]; + newCells[index] = text; + setOtpCells(newCells); + const combined = newCells.join(''); + setValue('otp', combined); + + // Auto-focus logic + if (text && index < 3) { + // Move to next cell + inputRefs.current[index + 1]?.focus(); + } else if (!text && index > 0) { + // Move to previous cell on delete + inputRefs.current[index - 1]?.focus(); + } + }; + + const onSubmit = async (data: LoginFormInputs) => { + clearErrors(); + + if (step === 'mobile') { + const mobile = data.mobile.trim(); + // Validate mobile number + if (!mobile) { + console.log('no mobile number found') + + setError("mobile", { + type: "manual", + message: "Mobile number is required", + }); + return; + } + + if (!validateMobile(data.mobile)) { + setError("mobile", { + type: "manual", + message: "Please enter a valid 10-digit mobile number", + }); + return; + } + + const cleanMobile = data.mobile.replace(/\D/g, ''); + setSelectedMobile(cleanMobile); + sendOtpMutation.mutate({ mobile }); + } else if (step === 'otp') { + // Verify OTP + if (!data.otp || data.otp.length < 4) { + setError("otp", { + type: "manual", + message: "Please enter a valid OTP", + }); + return; + } + + verifyOtpMutation.mutate({ + mobile: selectedMobile, + otp: data.otp, + }); + } else if (step === 'password') { + // Login with password + if (!data.password || data.password.length < 6) { + setError("password", { + type: "manual", + message: "Password must be at least 6 characters", + }); + return; + } + + try { + console.log('calling the login function') + + const response = await loginMutation.mutateAsync({ + identifier: selectedMobile, + password: data.password, + }); + loginWithToken(response.data.token, response.data.user); + } catch (error: any) { + Alert.alert('Error', error.message || 'Login failed'); + } + } + }; + + return ( + + + + + + Welcome + + + Sign in to continue your journey + + + + + {step === 'mobile' && ( + <> + ( + + { + // Format mobile number as user types + const clean = text.replace(/\D/g, ''); + if (clean.length <= 10) { + onChange(clean); + } + }} + onBlur={onBlur} + keyboardType="phone-pad" + maxLength={10} + style={tw`bg-gray-50`} + error={!!errors.mobile} + /> + + )} + /> + {errors.mobile && ( + + {errors.mobile.message} + + )} + + )} + + {step === 'choice' && ( + + + Choose your login method for {selectedMobile} + + + setStep('password')} + fillColor="gray1" + textColor="black1" + style={tw`flex-1 mr-2 border border-gray-200`} + /> + sendOtpMutation.mutate({ mobile: selectedMobile })} + fillColor="brand500" + textColor="white1" + style={tw`flex-1 ml-2 shadow-sm`} + disabled={sendOtpMutation.isPending} + /> + + { + setStep('mobile'); + setValue('mobile', ''); + clearErrors(); + }} + style={tw`mt-2`} + > + + Change Number + + + + )} + + {step === 'otp' && ( + <> + + + Enter 4-digit OTP + + + {[0, 1, 2, 3].map((i) => ( + { inputRefs.current[i] = ref; }} + style={tw`w-14 h-14 ${errors.otp ? 'border-red-500' : 'border-gray-200'} border-2 rounded-xl text-center text-2xl font-bold ${otpCells[i] ? 'bg-blue-50 border-brand500 text-brand700' : 'bg-gray-50'}`} + keyboardType="numeric" + maxLength={1} + value={otpCells[i]} + onChangeText={(text) => handleOtpChange(i, text)} + selectionColor={colors.brand500} + /> + ))} + + + {errors.otp && ( + + {errors.otp.message} + + )} + + { + setStep('password'); + setValue('otp', ''); + setOtpCells(['', '', '', '']); + clearErrors(); + }} + style={tw`mb-6`} + > + + Or login with Password + + + + + { + setStep('choice'); + setValue('otp', ''); + setOtpCells(['', '', '', '']); + clearErrors(); + }} + > + + Back + + + + sendOtpMutation.mutate({ mobile: selectedMobile })} + disabled={!canResend || sendOtpMutation.isPending} + > + + {sendOtpMutation.isPending + ? 'Sending...' + : canResend + ? 'Resend OTP' + : `Resend in ${resendCountdown}s` + } + + + + + )} + + {step === 'password' && ( + <> + ( + + + + )} + /> + {errors.password && ( + + {errors.password.message} + + )} + + + { + setStep('choice'); + setValue('password', ''); + clearErrors(); + }} + > + + Back to options + + + + + )} + + {(step === 'mobile' || step === 'otp' || step === 'password') && ( + + + {isLoading || sendOtpMutation.isPending || verifyOtpMutation.isPending || loginMutation.isPending + ? (step === 'otp' ? "Verifying..." : step === 'password' ? "Logging in..." : "Processing...") + : (step === 'otp' ? "Verify & Login" : step === 'password' ? "Login" : "Continue")} + + + )} + + + + + ); +} + +export default Login; \ No newline at end of file diff --git a/apps/user-ui/app/(auth)/register.tsx b/apps/user-ui/app/(auth)/register.tsx new file mode 100644 index 0000000..613e671 --- /dev/null +++ b/apps/user-ui/app/(auth)/register.tsx @@ -0,0 +1,60 @@ +import React, { useState } from "react"; +import { View, Alert, ScrollView } from "react-native"; +import { useRouter } from "expo-router"; + +import { MyText, tw, MyTouchableOpacity } from "common-ui"; +import { useAuth } from "@/src/contexts/AuthContext"; +import RegistrationForm from "@/components/registration-form"; + +function Register() { + const router = useRouter(); + const { register } = useAuth(); + const [isLoading, setIsLoading] = useState(false); + + const handleRegister = async (formData: FormData) => { + setIsLoading(true); + try { + await register(formData); + // Auth context will handle navigation on successful registration + } catch (error: any) { + console.error('Registration error:', error); + Alert.alert( + 'Registration Failed', + error.message || 'Failed to create account. Please try again.' + ); + } finally { + setIsLoading(false); + } + }; + + return ( + + + + + Create Account + + + Join us to start your journey + + + + + + + Already have an account? + router.push('/(auth)/login')}> + + Sign in + + + + + + ); +} + +export default Register; \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(cart)/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(cart)/_layout.tsx new file mode 100644 index 0000000..232a1de --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(cart)/_layout.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Slot } from 'expo-router'; + +export default function FlashDeliveryCartLayout() { + return ; +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(cart)/cart.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(cart)/cart.tsx new file mode 100644 index 0000000..7c2a859 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(cart)/cart.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import CartPage from '@/components/cart-page'; + +export default function FlashDeliveryCart() { + return ; +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(products)/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(products)/_layout.tsx new file mode 100644 index 0000000..d436f2c --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(products)/_layout.tsx @@ -0,0 +1,24 @@ +import React, { useEffect } from 'react'; +import { useLocalSearchParams } from 'expo-router'; +import { SlotLayout } from '@/components/SlotSpecificView'; +import TabLayoutWrapper from '@/components/TabLayoutWrapper'; +import { useSlotStore } from '@/components/stores/slotStore'; + +export default function FlashDeliveryProductsLayout() { + const { storeId: storeIdRaw } = useLocalSearchParams(); + const setStoreId = useSlotStore(state => state.setStoreId); + + useEffect(() => { + setStoreId(Number(storeIdRaw)); + }, [storeIdRaw, setStoreId]); + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(products)/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(products)/index.tsx new file mode 100644 index 0000000..c5827fa --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/(products)/index.tsx @@ -0,0 +1,42 @@ +import React, { useEffect } from 'react'; +import { useLocalSearchParams, useRouter } from 'expo-router'; +import { FlashDeliveryProducts } from '@/components/SlotSpecificView'; +import { useSlotStore } from '@/components/stores/slotStore'; +import FlashDeliveryNote from '@/components/FlashDeliveryNote'; +import { useFlashNavigationStore } from '@/components/stores/flashNavigationStore'; +import { useFocusEffect } from '@react-navigation/native'; + +export default function FlashDeliveryView() { + const { storeId } = useLocalSearchParams<{ storeId?: string }>(); + const setStoreId = useSlotStore(state => state.setStoreId); + const router = useRouter(); + const { shouldNavigateToCart, reset } = useFlashNavigationStore(); + + useEffect(() => { + setStoreId(Number(storeId)); + }, [storeId, setStoreId]); + + useFocusEffect( + React.useCallback(() => { + if (shouldNavigateToCart) { + reset(); + router.push('/(drawer)/(tabs)/flash-delivery/(cart)/cart'); + } + }, [shouldNavigateToCart, router]) + ); + + const handleProductPress = (productId: number) => { + router.push(`/(drawer)/(tabs)/flash-delivery/product-detail/${productId}`); + }; + + return ( + <> + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/_layout.tsx new file mode 100644 index 0000000..e8f7f8f --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/_layout.tsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { View, ActivityIndicator } from 'react-native'; +import { Slot } from 'expo-router'; +import { trpc } from '@/src/trpc-client'; +import { MyText, MyTouchableOpacity, tw, AppContainer } from 'common-ui'; +import { useRouter } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'; + +export default function FlashDeliveryBaseLayout() { + const router = useRouter(); + const { data: essentialConsts, isLoading } = useGetEssentialConsts(); + + if (isLoading) { + return ( + + + + Loading... + + + ); + } + + const isFlashDeliveryEnabled = essentialConsts?.isFlashDeliveryEnabled ?? true; + + if (!isFlashDeliveryEnabled) { + return ( + + + + + + + Flash Delivery Unavailable + + + Flash Delivery is not available at the moment. Please opt for a scheduled delivery. + + router.replace('/(drawer)/(tabs)/home')} + style={tw`bg-green-500 px-8 py-4 rounded-lg`} + > + + Go to Scheduled Delivery + + + + + ); + } + + return ; +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/checkout.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/checkout.tsx new file mode 100644 index 0000000..397ccf3 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/checkout.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import CheckoutPage from '@/components/checkout-page'; + +export default function FlashDeliveryCheckout() { + return ; +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/index.tsx new file mode 100644 index 0000000..1b832bd --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/index.tsx @@ -0,0 +1,5 @@ +import { Redirect } from 'expo-router'; + +export default function FlashDeliveryIndex() { + return ; +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/order-success.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/order-success.tsx new file mode 100644 index 0000000..c4cd705 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/order-success.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import { View } from "react-native"; +import { useRouter, useLocalSearchParams } from "expo-router"; +import { AppContainer, MyText, MyButton, tw } from "common-ui"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; + +export default function FlashDeliveryOrderSuccess() { + const router = useRouter(); + const params = useLocalSearchParams(); + + // You can access order details from params if passed + const orderId = params.orderId as string; + const totalAmount = params.totalAmount as string; + + return ( + + + {/* Success Icon */} + + + + + {/* Success Message */} + + Flash Order Placed! + + + + Lightning-fast delivery on the way! + + + + Your order will be delivered in just 30 minutes + + + {/* Order Details (if available) */} + {orderId && ( + + + Flash Order #{orderId} + + {totalAmount && ( + + Total: ₹{totalAmount} + + )} + + )} + + {/* Action Buttons */} + + router.replace("/(drawer)/(tabs)/flash-delivery")} + fillColor="brand500" + textColor="white1" + fullWidth + /> + + { + router.dismissAll(); + router.replace("/(drawer)/(tabs)/me/my-orders"); + }} + fillColor="gray1" + textColor="black1" + fullWidth + /> + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/[id].tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/[id].tsx new file mode 100644 index 0000000..d775bb4 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/[id].tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { useLocalSearchParams } from 'expo-router'; +import ProductDetail from '@/components/ProductDetail'; + +export default function FlashDeliveryProductDetail() { + const { id } = useLocalSearchParams(); + + return ; +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/_layout.tsx new file mode 100644 index 0000000..ca8365f --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/_layout.tsx @@ -0,0 +1,24 @@ +import FloatingCartBar from "@/components/floating-cart-bar"; +import { tw } from "common-ui"; +import { Stack } from "expo-router"; +import { View } from "react-native"; + +export default function HomeLayout() { + return ( + <> + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/cart.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/cart.tsx new file mode 100644 index 0000000..b4d61d3 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/cart.tsx @@ -0,0 +1,14 @@ +import CartPage from '@/components/cart-page' +import React from 'react' + +interface Props {} + +function Cart(props: Props) { + const {} = props + + return ( + + ) +} + +export default Cart diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/checkout.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/checkout.tsx new file mode 100644 index 0000000..0d40fb1 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/checkout.tsx @@ -0,0 +1,12 @@ +import CheckoutPage from '@/components/checkout-page'; +import React from 'react'; + +interface Props {} + +function Checkout(props: Props) { + const {} = props; + + return ; +} + +export default Checkout; \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx new file mode 100755 index 0000000..168761d --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/index.tsx @@ -0,0 +1,530 @@ +import React, { useState } from "react"; +import { View, Dimensions, Image, Alert, ScrollView, StatusBar as RNStatusBar } from "react-native"; +import { StatusBar as ExpoStatusBar } from 'expo-status-bar'; +import { LinearGradient } from "expo-linear-gradient"; +import { useRouter } from "expo-router"; +import { + theme, + tw, + useManualRefresh, + useMarkDataFetchers, + LoadingDialog, + AppContainer, + MyTouchableOpacity, + MyText, MyTextInput, SearchBar, useStatusBarStore +} from "common-ui"; + +import dayjs from "dayjs"; +import relativeTime from "dayjs/plugin/relativeTime"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import FontAwesome5 from "@expo/vector-icons/FontAwesome5"; +import { Ionicons } from "@expo/vector-icons"; +import ProductCard from "@/components/ProductCard"; + +import { trpc } from "@/src/trpc-client"; +import { useGetCart } from "@/hooks/cart-query-hooks"; +import { useProductSlotIdentifier } from "@/hooks/useProductSlotIdentifier"; +import FloatingCartBar from "@/components/floating-cart-bar"; +import AddressSelector from "@/components/AddressSelector"; +import BannerCarousel from "@/components/BannerCarousel"; +import TestingPhaseNote from "@/components/TestingPhaseNote"; +import { useUserDetails } from "@/src/contexts/AuthContext"; +import TabLayoutWrapper from "@/components/TabLayoutWrapper"; +import { useNavigationStore } from "@/src/store/navigationStore"; +import { useGetEssentialConsts } from "@/src/api-hooks/essential-consts.api"; +dayjs.extend(relativeTime); +// import { StatusBar } from "expo-status-bar"; + +const { width: screenWidth } = Dimensions.get("window"); +const itemWidth = screenWidth * 0.45; // 45% of screen width + +const RenderStore = ({ + item, +}: { + item: any; +}) => { + const router = useRouter(); + const { setNavigatedFromHome, setSelectedStoreId } = useNavigationStore(); + + const handlePress = () => { + setNavigatedFromHome(true); + setSelectedStoreId(item.id); + router.push('/(drawer)/(tabs)/stores'); + }; + + return ( + + + {item.signedImageUrl ? ( + + ) : ( + + )} + + + + {item.name.replace(/^The\s+/i, "")} + + + ); +}; + +// const headerColor = '#fedf89' +// const headerColor = '#444ce7' +const headerColor = '#f81260' + +export default function Dashboard() { + const router = useRouter(); + const userDetails = useUserDetails(); + const [inputQuery, setInputQuery] = useState(""); + const [searchQuery, setSearchQuery] = useState(""); + const [selectedTagId, setSelectedTagId] = useState(null); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); + const [gradientHeight, setGradientHeight] = useState(0); + const [stickyBarLayout, setStickyBarLayout] = useState({ y: 0, height: 0 }); + const [whiteSectionLayout, setWhiteSectionLayout] = useState({ y: 0 }); + const { backgroundColor } = useStatusBarStore(); + + const { + data: productsData, + isLoading, + error, + refetch, + } = trpc.common.product.getAllProductsSummary.useQuery({ + searchQuery: searchQuery || undefined, + tagId: selectedTagId || undefined, + }); + + const { data: essentialConsts, isLoading: isLoadingConsts, error: constsError } = useGetEssentialConsts(); + + const { data: tagsData } = trpc.common.product.getDashboardTags.useQuery(); + const { data: cartData, refetch: refetchCart } = useGetCart(); + const { data: storesData } = trpc.user.stores.getStores.useQuery(); + const { data: defaultAddressResponse } = + trpc.user.address.getDefaultAddress.useQuery(); + const { data: slotsData } = trpc.user.slots.getSlotsWithProducts.useQuery(); + + const products = productsData?.products || []; + const dashboardTags = tagsData?.tags || []; + const defaultAddress = defaultAddressResponse?.data; + const { getQuickestSlot } = useProductSlotIdentifier(); + + // Extract popular items IDs as an array to preserve order + const popularItemIds = (() => { + const popularItems = essentialConsts?.popularItems; + if (!popularItems) return []; + + if (Array.isArray(popularItems)) { + // Already an array of IDs + return popularItems.map((id: any) => parseInt(id)).filter((id: number) => !isNaN(id)); + } else if (typeof popularItems === 'string') { + // Comma-separated string + return popularItems + .split(',') + .map((id: string) => parseInt(id.trim())) + .filter((id: number) => !isNaN(id)); + } + return []; + })(); + + // Filter products to only include those whose ID exists in popularItemIds, preserving order + // Only filter when both products and essentialConsts are loaded + const popularProducts = popularItemIds + .map(id => products.find(product => product.id === id)) + .filter((product): product is NonNullable => product != null); + + + useManualRefresh(() => { + refetch(); + }); + + useMarkDataFetchers(() => { + refetch(); + }); + + const handleScroll = (event: any) => { + // const scrollY = event.nativeEvent.contentOffset.y; + // const stickyBarBottom = stickyBarLayout.y + stickyBarLayout.height; + // const whiteSectionTop = whiteSectionLayout.y; + + // const shouldBeWhite = scrollY + stickyBarBottom >= whiteSectionTop; + + // if (shouldBeWhite) { + // updateStatusBarColor('dark', '#ffffff'); + // } else { + // updateStatusBarColor('light', headerColor); + // } + }; + + // React.useFocu(() => { + // // Initial status bar color + // return () => updateStatusBarColor('dark', '#ffffff'); + // }, []); + + if (isLoading || isLoadingConsts) { + return ( + + + {isLoading ? 'Loading products...' : 'Loading app settings...'} + + + ); + } + + if (error || constsError) { + return ( + + + Oops! + + {error ? 'Failed to load products' : 'Failed to load app settings'} + + + ); + } + + + return ( + + {/* */} + + + + + + + router.push("/(drawer)/(tabs)/me")} + style={tw`bg-white/10 rounded-full border border-white/10`} + > + {userDetails?.profileImage ? ( + + ) : ( + + )} + + + + { + const { y, height } = event.nativeEvent.layout; + setStickyBarLayout({ y, height }); + }} + > + { }} + onPress={() => router.push("/(drawer)/(tabs)/home/search-results")} + editable={false} + containerStyle={tw` bg-white`} + onSubmitEditing={() => { + if (inputQuery.trim()) { + router.push( + `/(drawer)/(tabs)/home/search-results?q=${encodeURIComponent( + inputQuery.trim() + )}` + ); + } + }} + returnKeyType="search" + /> + + + { + const { y, height } = event.nativeEvent.layout; + setGradientHeight(y + height); + }} + > + {/* Stores Section */} + {storesData?.stores && storesData.stores.length > 0 && ( + + + + + Our Stores + + + Fresh from our locations + + + + + + {storesData.stores.map((store, index) => ( + + + + ))} + + + + )} + + + {/* Banner Carousel */} + + + + + + + {/* White Section */} + { + const { y } = event.nativeEvent.layout; + setWhiteSectionLayout({ y }); + }} + > + {/* Section Title */} + + + Popular Items + + + Trending fresh picks just for you + + + + + + {popularProducts.map((item, index: number) => ( + + + router.push( + `/(drawer)/(tabs)/home/product-detail/${item.id}` + ) + } + showDeliveryInfo={false} + miniView={true} + /> + + ))} + + + + + {/* Upcoming Deliveries Section */} + {slotsData?.slots && slotsData.slots.length > 0 && ( + + + + + Delivery Slots + + + Plan your fresh deliveries ahead + + + + + + {slotsData.slots.slice(0, 5).map((slot) => { + const now = dayjs(); + const freezeTime = dayjs(slot.freezeTime); + const isClosingSoon = + freezeTime.diff(now, "hour") < 4 && freezeTime.isAfter(now); + + return ( + + router.push( + `/(drawer)/(tabs)/home/slot-view?slotId=${slot.id}` + ) + } + activeOpacity={0.9} + > + {/* Status Badge */} + + {isClosingSoon && ( + + + + CLOSING SOON + + + )} + + + {/* Main Time Grid */} + + + + + + + + Delivery At + + + + {dayjs(slot.deliveryTime).format("h:mm A")} + + + {dayjs(slot.deliveryTime).format("ddd, MMM DD")} + + + + + + + + + + Order By + + + + {dayjs(slot.freezeTime).format("h:mm A")} + + + {dayjs(slot.freezeTime).format("ddd, MMM DD")} + + + + + {/* Product Teaser */} + + + {slot.products.slice(0, 3).map((p, i) => ( + 0 && tw`-ml-3`, + ]} + > + {p.images?.[0] ? ( + + ) : ( + + )} + + ))} + + + View all {slot.products.length} items + + + + + ); + })} + + + )} + + + + + + + + + + ); +} diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/order-success.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/order-success.tsx new file mode 100644 index 0000000..1a1bb94 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/order-success.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import { View } from "react-native"; +import { useRouter, useLocalSearchParams } from "expo-router"; +import { AppContainer, MyText, MyButton, tw } from "common-ui"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; + +export default function OrderSuccess() { + const router = useRouter(); + const params = useLocalSearchParams(); + + // You can access order details from params if passed + const orderId = params.orderId as string; + const totalAmount = params.totalAmount as string; + + return ( + + + {/* Success Icon */} + + + + + {/* Success Message */} + + Order Placed Successfully! + + + + Thank you for your order + + + + Your order will be delivered as per your selected slot + + + {/* Order Details (if available) */} + {orderId && ( + + + Order #{orderId} + + {totalAmount && ( + + Total: ₹{totalAmount} + + )} + + )} + + {/* Action Buttons */} + + router.replace("/(drawer)/(tabs)/home")} + fillColor="brand500" + textColor="white1" + fullWidth + /> + + { + router.dismissAll(); + router.replace("/(drawer)/(tabs)/me/my-orders"); + }} + fillColor="gray1" + textColor="black1" + fullWidth + /> + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/[id].tsx b/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/[id].tsx new file mode 100755 index 0000000..bd63cf4 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/[id].tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import { useLocalSearchParams } from 'expo-router'; +import ProductDetail from '@/components/ProductDetail'; +import { View } from 'react-native'; +import { tw } from 'common-ui'; +import FloatingCartBar from '@/components/floating-cart-bar'; + +export default function ProductDetailPage() { + const { id } = useLocalSearchParams(); + const productId = id as string; + + return ( + + + {/* + + */} + + + ) +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx new file mode 100644 index 0000000..871c3ae --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx @@ -0,0 +1,20 @@ +import FloatingCartBar from "@/components/floating-cart-bar"; +import { tw } from "common-ui"; +import { Stack } from "expo-router"; +import { View } from "react-native"; + +export default function ProductDetailLayout() { + return ( + <> + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/search-results/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/search-results/_layout.tsx new file mode 100644 index 0000000..74b77f5 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/search-results/_layout.tsx @@ -0,0 +1,20 @@ +import FloatingCartBar from '@/components/floating-cart-bar'; +import { tw } from 'common-ui'; +import { Stack } from 'expo-router'; +import { View } from 'react-native'; + +export default function SearchResultsLayout() { + return ( + <> + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/search-results/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/search-results/index.tsx new file mode 100644 index 0000000..5cc2c7a --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/search-results/index.tsx @@ -0,0 +1,176 @@ +import React, { useState, useRef, useEffect } from "react"; +import { + View, + Dimensions, + Image, + Alert, + Platform, +} from "react-native"; +import { useRouter, useLocalSearchParams } from "expo-router"; +import { + theme, + tw, + useManualRefresh, + useMarkDataFetchers, + LoadingDialog, + AppContainer, + MyFlatList, + MyText, + MyTextInput, + MyTouchableOpacity, + SearchBar } from "common-ui"; +import dayjs from "dayjs"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { trpc } from "@/src/trpc-client"; +import { useGetCart, useAddToCart } from '@/hooks/cart-query-hooks'; +import ProductCard from "@/components/ProductCard"; +import FloatingCartBar from "@/components/floating-cart-bar"; + +const { width: screenWidth } = Dimensions.get("window"); +const itemWidth = (screenWidth - 48) / 2; // 48 = padding horizontal (16*2) + gap (16) + + +export default function SearchResults() { + const router = useRouter(); + const { q } = useLocalSearchParams(); + const query = (q as string) || ""; + const [inputQuery, setInputQuery] = useState(query); + const [searchQuery, setSearchQuery] = useState(query); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); + const searchInputRef = useRef(null); + + useEffect(() => { + // Auto-focus search bar on mount + setTimeout(() => { + searchInputRef.current?.focus(); + }, 100); + }, []); + + const { + data: productsData, + isLoading, + error, + refetch, + } = trpc.common.product.getAllProductsSummary.useQuery({ + searchQuery: searchQuery || undefined, + }); + + const { data: cartData, refetch: refetchCart } = useGetCart(); + + const products = productsData?.products || []; + const addToCart = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }); + + useManualRefresh(() => { + refetch(); + }); + + useMarkDataFetchers(() => { + refetch(); + }); + + const handleAddToCart = (productId: number) => { + setIsLoadingDialogOpen(true); + addToCart.mutate( + { productId, quantity: 1 }, + { + onSuccess: () => { + Alert.alert("Success", "Item added to cart!"); + refetchCart(); + }, + onError: (error: any) => { + Alert.alert("Error", error.message || "Failed to add item to cart"); + }, + onSettled: () => { + setIsLoadingDialogOpen(false); + }, + } + ); + }; + + const handleBuyNow = (productId: number) => { + setIsLoadingDialogOpen(true); + addToCart.mutate( + { productId, quantity: 1 }, + { + onSuccess: () => { + router.push(`/(drawer)/(tabs)/home/cart?select=${productId}`); + }, + onError: (error: any) => { + Alert.alert("Error", error.message || "Failed to add item to cart"); + }, + onSettled: () => { + setIsLoadingDialogOpen(false); + }, + } + ); + }; + + const handleSearch = () => { + setSearchQuery(inputQuery); + }; + + if (isLoading) { + return ( + + Loading products... + + ); + } + + if (error) { + return ( + + + Oops! + Failed to load products + + ); + } + + return ( + + ( + router.push(`/(drawer)/(tabs)/home/product-detail/${item.id}`)} + showDeliveryInfo={false} + iconType="flash" + /> + )} + keyExtractor={(item, index) => index.toString()} + columnWrapperStyle={{ gap: 16, justifyContent: 'center' }} + contentContainerStyle={[tw`pb-24`, { gap: 16 }]} + ListHeaderComponent={ + + {/* Search Bar */} + + + {/* Section Title */} + + + {searchQuery ? `Search Results for "${searchQuery}"` : 'All Products'} + + + + } + /> + + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/slot-view/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/slot-view/_layout.tsx new file mode 100644 index 0000000..fea7f09 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/slot-view/_layout.tsx @@ -0,0 +1,26 @@ +import React, { useEffect } from 'react'; +import { View } from 'react-native'; +import { useLocalSearchParams } from 'expo-router'; +import { SlotLayout } from '@/components/SlotSpecificView'; +import TabLayoutWrapper from '@/components/TabLayoutWrapper'; +import { useSlotStore } from '@/components/stores/slotStore'; + +export default function SlotViewLayout() { + const { slotId: id, storeId: storeIdRaw } = useLocalSearchParams(); + const slotId = id ? Number(id) : undefined; + const setSlotId = useSlotStore(state => state.setSlotId); + const setStoreId = useSlotStore(state => state.setStoreId); + + + useEffect(() => { + setSlotId(slotId); + setStoreId(Number(storeIdRaw)); + }, [slotId, storeIdRaw, setSlotId, setStoreId]); + + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/slot-view/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/slot-view/index.tsx new file mode 100644 index 0000000..0c67c12 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/home/slot-view/index.tsx @@ -0,0 +1,23 @@ +import React, { useEffect } from 'react'; +import { View } from 'react-native'; +import { useLocalSearchParams } from 'expo-router'; +import { SlotProducts } from '@/components/SlotSpecificView'; +import { useSlotStore } from '@/components/stores/slotStore'; +import TabLayoutWrapper from '@/components/TabLayoutWrapper'; + +export default function SlotView() { + const params = useLocalSearchParams(); + const { slotId:id, storeId } = useLocalSearchParams(); + const slotId = id ? Number(id) : undefined; + const setSlotId = useSlotStore(state => state.setSlotId); + const setStoreId = useSlotStore(state => state.setStoreId); + + useEffect(() => { + setSlotId(slotId); + setStoreId(Number(storeId)); + }, [slotId, storeId, setSlotId, setStoreId]); + + return ( + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/_layout.tsx new file mode 100644 index 0000000..fcace8d --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/_layout.tsx @@ -0,0 +1,17 @@ +import { useAuthenticatedRoute } from "@/hooks/useAuthenticatedRoute"; +import { Stack } from "expo-router"; + +export default function MeLayout() { + // Protect all profile routes - redirect to login if not authenticated + useAuthenticatedRoute({ + targetUrl: '/(drawer)/(tabs)/me' + }); + + return ( + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/about/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/about/_layout.tsx new file mode 100644 index 0000000..51cdaa5 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/about/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router' + +function AboutLayout() { + return ( + + ) +} + +export default AboutLayout \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/about/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/about/index.tsx new file mode 100644 index 0000000..1fb8c5f --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/about/index.tsx @@ -0,0 +1,167 @@ +import React from 'react'; +import { View, ScrollView, Linking } from 'react-native'; +import { Image } from 'expo-image'; +import { AppContainer, MyText, tw, MyTouchableOpacity } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import FontAwesome5 from '@expo/vector-icons/FontAwesome5'; + +export default function About() { + const openLink = (url: string) => { + Linking.openURL(url).catch((err) => console.error("Couldn't load page", err)); + }; + + return ( + + + {/* Hero Section */} + + + + + + + + Meat Farmer + + + Bringing local trust and online convenience together. + + + + + {/* Mission Cards */} + + Our Mission + + + + + + Local Roots + Based in MBNR, supporting our community. + + + + + + Best Price + Minimizing costs to enhance your buying experience. + + + + + + Quality First + Committed to fresh, high-quality meat products. + + + + + + Farmers First + Dedicated to supporting local farmers. + + + + + {/* Sourcing Section */} + + + + + + + Sourcing & Quality + + + + + + + All items are procured directly from authorized dealers. + + + + + + 100% local products sourced from trusted suppliers. + + + + + + All products are purely Halal certified. + + + + + + + {/* Payments & Refunds Section */} + + + + + + + Payments & Refunds + + + + + Payment Options: Online or Cash on Delivery (COD). + + + Complaints: Must be raised within 12 hours of delivery. + + + + + + + + Refunds are processed to the original payment method. + + + + + + Alternatively, receive a refund coupon for future purchases. + + + + + + Processing time: Up to 3 business days. + + + + + + + {/* Footer */} + + Follow us + + + + + + + + + + + + + © 2024 Meat Farmer. All rights reserved. + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/addresses/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/addresses/_layout.tsx new file mode 100644 index 0000000..5415704 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/addresses/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from 'expo-router'; + +export default function AddressesLayout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx new file mode 100644 index 0000000..7a9eb41 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/addresses/index.tsx @@ -0,0 +1,278 @@ +import React, { useState } from 'react'; +import { View, Alert, Modal } from 'react-native'; +import { useRouter } from 'expo-router'; +import { AppContainer, MyText, tw, useMarkDataFetchers, MyFlatList, MyTouchableOpacity } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import AddressForm from '@/src/components/AddressForm'; + +interface Address { + id: number; + name: string; + phone: string; + addressLine1: string; + addressLine2: string | null; + city: string; + state: string; + pincode: string; + isDefault: boolean; +} + +function AddressCard({ address, onEdit, onDelete, onSetDefault, isDeleting }: { + address: Address; + onEdit: (address: Address) => void; + onDelete: (id: number) => void; + onSetDefault: (id: number) => void; + isDeleting?: boolean; +}) { + const formatAddress = (addr: Address) => { + return `${addr.addressLine1}${addr.addressLine2 ? `, ${addr.addressLine2}` : ''}, ${addr.city}, ${addr.state} - ${addr.pincode}`; + }; + + return ( + + + + + + {address.name} + + {address.isDefault && ( + + Default + + )} + + + 📞 {address.phone} + + + 📍 {formatAddress(address)} + + + + + + {!address.isDefault && ( + onSetDefault(address.id)} + > + Set Default + + )} + onEdit(address)} + > + Edit + + onDelete(address.id)} + disabled={isDeleting} + > + + {isDeleting ? 'Deleting...' : 'Delete'} + + + + + ); +} + +export default function Addresses() { + const [modalVisible, setModalVisible] = useState(false); + const [editingAddress, setEditingAddress] = useState
(null); + + const { data, isLoading, error, refetch } = trpc.user.address.getUserAddresses.useQuery(); + + useMarkDataFetchers(() => { + refetch(); + }); + + const addresses = data?.data || []; + + const updateAddressMutation = trpc.user.address.updateAddress.useMutation(); + const deleteAddressMutation = trpc.user.address.deleteAddress.useMutation(); + + const handleAddAddress = () => { + setEditingAddress(null); + setModalVisible(true); + }; + + const handleEditAddress = (address: Address) => { + setEditingAddress(address); + setModalVisible(true); + }; + + const handleDeleteAddress = (id: number) => { + Alert.alert( + 'Delete Address', + 'Are you sure you want to delete this address?', + [ + { text: 'Cancel', style: 'cancel' }, + { + text: 'Delete', + style: 'destructive', + onPress: () => { + deleteAddressMutation.mutate({ id }, { + onSuccess: () => { + refetch(); + Alert.alert('Success', 'Address deleted successfully'); + }, + onError: (error) => { + Alert.alert('Error', error.message || 'Failed to delete address'); + } + }); + } + } + ] + ); + }; + + const handleSetDefault = (id: number) => { + // Update the address to be default + const addressToUpdate = addresses.find(addr => addr.id === id); + if (addressToUpdate) { + updateAddressMutation.mutate({ + id: addressToUpdate.id, + name: addressToUpdate.name, + phone: addressToUpdate.phone, + addressLine1: addressToUpdate.addressLine1, + addressLine2: addressToUpdate.addressLine2 || undefined, + city: addressToUpdate.city, + state: addressToUpdate.state, + pincode: addressToUpdate.pincode, + isDefault: true, + }, { + onSuccess: () => { + refetch(); + Alert.alert('Success', 'Default address updated'); + }, + onError: (error) => { + Alert.alert('Error', error.message || 'Failed to update default address'); + } + }); + } + }; + + const handleAddressSubmit = () => { + setModalVisible(false); + setEditingAddress(null); + refetch(); + }; + + if (isLoading) { + return ( + + + Loading addresses... + + + ); + } + + if (error) { + return ( + + + + + Failed to load addresses. Please try again. + + refetch()} + > + Retry + + + + ); + } + + return ( + <> + ( + + )} + keyExtractor={(item) => item.id.toString()} + ListHeaderComponent={() => ( + + + My Addresses + + + + + + )} + ListEmptyComponent={() => ( + + + + No addresses found + + + Add your first delivery address + + + Add Address + + + )} + contentContainerStyle={tw`p-4`} + showsVerticalScrollIndicator={false} + /> + + setModalVisible(false)} + > + + + + {editingAddress ? 'Edit Address' : 'Add Address'} + + setModalVisible(false)} + style={tw`p-1`} + > + + + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/complaints/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/complaints/_layout.tsx new file mode 100644 index 0000000..7654ab9 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/complaints/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router' + +function ComplaintsLayout() { + return ( + + ) +} + +export default ComplaintsLayout \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/complaints/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/complaints/index.tsx new file mode 100644 index 0000000..948182d --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/complaints/index.tsx @@ -0,0 +1,187 @@ +import React from 'react'; +import { View, Linking, TouchableOpacity, ActivityIndicator } from 'react-native'; +import { Image } from 'expo-image'; +import { MyText, tw, useManualRefresh, MyFlatList, useMarkDataFetchers, theme, MyTouchableOpacity } from 'common-ui'; +import { MaterialIcons, Ionicons } from '@expo/vector-icons'; +import { trpc } from '@/src/trpc-client'; +import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'; +import dayjs from 'dayjs'; +import { useRouter } from 'expo-router'; + +interface ComplaintItemProps { + item: any; +} + +const ComplaintItem: React.FC = ({ item }) => ( + + {/* Header: ID, Date, Status */} + + + + + Complaint #{item.id} + + {item.orderId && ( + + + Order #{item.orderId} + + + )} + + + {dayjs(item.createdAt).format('MMM DD, YYYY • h:mm A')} + + + + + + {item.isResolved ? 'Resolved' : 'Pending'} + + + + + {/* Complaint Body */} + + {item.complaintBody} + + + {/* Admin Response */} + {item.response && ( + + + + + + + Support Response + + + + {item.response} + + + )} + + {!item.response && !item.isResolved && ( + + + + We are reviewing your complaint... + + + )} + +); + +export default function Complaints() { + const router = useRouter(); + const { data, isLoading, error, refetch } = trpc.user.complaint.getAll.useQuery(); + const complaints = data?.complaints || []; + + const { data: constsData } = useGetEssentialConsts(); + + useManualRefresh(() => refetch()); + + useMarkDataFetchers(() => { + refetch(); + }); + + if (isLoading) { + return ( + + Loading complaints... + + ); + } + + if (error) { + return ( + + + Oops! + Failed to load complaints + + ); + } + + + + return ( + + item.id.toString()} + renderItem={({ item }) => } + contentContainerStyle={tw`px-4 py-6`} + ListHeaderComponent={ + + + + + + Need Help? + + + + { + const phone = constsData?.supportMobile || '8688182552'; + Linking.openURL(`tel:${phone}`); + }} + > + + + + + Call Us + + {constsData?.supportMobile || '8688182552'} + + + + + { + const email = constsData?.supportEmail || 'qushammohd@gmail.com'; + Linking.openURL(`mailto:${email}`); + }} + > + + + + + Email + + {constsData?.supportEmail || 'qushammohd@gmail.com'} + + + + + + } + ListEmptyComponent={ + + + + + No Complaints + + You haven't raised any complaints yet. That's great! + + router.push('/(drawer)/(tabs)/home')} + style={tw`mt-8 bg-brand500 px-6 py-3 rounded-xl shadow-sm`} + > + Continue Shopping + + + } + /> + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/coupons/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/coupons/_layout.tsx new file mode 100644 index 0000000..622608a --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/coupons/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from 'expo-router'; + +export default function CouponsLayout() { + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/coupons/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/coupons/index.tsx new file mode 100644 index 0000000..041e65e --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/coupons/index.tsx @@ -0,0 +1,206 @@ +import React, { useState } from 'react'; +import { View, ScrollView, Alert } from 'react-native'; +import { AppContainer, MyText, tw, useMarkDataFetchers, MyTouchableOpacity, MyTextInput } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import dayjs from 'dayjs'; + +interface CouponCardProps { + coupon: { + id: number; + code: string; + discountType: 'percentage' | 'flat'; + discountValue: number; + maxValue?: number; + minOrder?: number; + description: string; + validTill?: string | Date; + usageCount: number; + maxLimitForUser?: number; + isExpired: boolean; + isUsedUp: boolean; + }; +} + +function CouponCard({ coupon }: CouponCardProps) { + const getStatusColor = () => { + if (coupon.isExpired) return 'text-red-500'; + if (coupon.isUsedUp) return 'text-orange-500'; + return 'text-green-600'; + }; + + const getStatusText = () => { + if (coupon.isExpired) return 'Expired'; + if (coupon.isUsedUp) return 'Used'; + return 'Available'; + }; + + const formatDate = (date?: string | Date) => { + if (!date) return 'No expiry'; + return dayjs(date).format('DD MMM YYYY'); + }; + + return ( + + + + + {coupon.code} + + + {coupon.description} + + + + + {getStatusText()} + + {coupon.maxLimitForUser && ( + + Used: {coupon.usageCount}/{coupon.maxLimitForUser} + + )} + + + + + + Valid till: {formatDate(coupon.validTill)} + + + + {coupon.isExpired || coupon.isUsedUp ? 'Unavailable' : 'Apply'} + + + + + ); +} + +function CouponSection({ + title, + coupons, + emptyMessage +}: { + title: string; + coupons: CouponCardProps['coupon'][]; + emptyMessage: string; +}) { + return ( + + + {title} + + + {coupons.length === 0 ? ( + + + + {emptyMessage} + + + ) : ( + coupons.map(coupon => ( + + )) + )} + + ); +} + +export default function Coupons() { + const { data, isLoading, error, refetch } = trpc.user.coupon.getMyCoupons.useQuery(); + const [couponCode, setCouponCode] = useState(''); + + const redeemCouponMutation = trpc.user.coupon.redeemReservedCoupon.useMutation({ + onSuccess: () => { + setCouponCode(''); + refetch(); + Alert.alert('Success', 'Coupon added successfully!'); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to add coupon. Please check the code and try again.'); + } + }); + + useMarkDataFetchers(() => { + refetch(); + }); + + console.log({data, error}) + + + if (isLoading) { + return ( + + + Loading coupons... + + + ); + } + + if (error) { + return ( + + + + + Failed to load coupons. Please try again. + + + + ); + } + + const personalCoupons = data?.data?.personal || []; + const generalCoupons = data?.data?.general || []; + + return ( + + + + + Add a Coupon + + + { + if (couponCode.trim().length >= 4) { + redeemCouponMutation.mutate({ secretCode: couponCode.trim().toUpperCase() }); + } + }} + > + + {redeemCouponMutation.isPending ? 'Adding...' : 'Add Coupon'} + + + + + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/delivery-slots/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/delivery-slots/_layout.tsx new file mode 100644 index 0000000..8a04d45 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/delivery-slots/_layout.tsx @@ -0,0 +1,9 @@ +import { Stack } from 'expo-router' + +function DeliverySlotsLayout() { + return ( + + ) +} + +export default DeliverySlotsLayout \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/delivery-slots/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/delivery-slots/index.tsx new file mode 100644 index 0000000..d9f4aba --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/delivery-slots/index.tsx @@ -0,0 +1,230 @@ +import React, { useState } from 'react'; +import { View, ScrollView } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter } from 'expo-router'; +import { MyFlatList, MyText, tw, useMarkDataFetchers, BottomDialog, theme, MyTouchableOpacity } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import dayjs from 'dayjs'; + +export default function DeliverySlots() { + const router = useRouter(); + const { data, isLoading, error, refetch } = trpc.user.slots.getSlotsWithProducts.useQuery(); + const [selectedSlotForDialog, setSelectedSlotForDialog] = useState(null); + + useMarkDataFetchers(() => { + refetch(); + }); + + if (isLoading) { + return ( + null} + ListHeaderComponent={() => ( + + Loading delivery slots... + + )} + /> + ); + } + + if (error) { + return ( + null} + ListHeaderComponent={() => ( + + Error loading delivery slots + refetch()} + style={tw`mt-4 bg-blue-500 px-4 py-2 rounded-lg`} + > + Retry + + + )} + /> + ); + } + + const slots = data?.slots || []; + + if (slots.length === 0) { + return ( + null} + ListHeaderComponent={() => ( + + + + No upcoming delivery slots available + + + Check back later for new delivery schedules + + + )} + /> + ); + } + + return ( + <> + item.id.toString()} + // ListHeaderComponent={() => ( + // + // Delivery Slots + // + // Choose your preferred delivery time + // + // + // )} + renderItem={({ item: slot }) => ( + + {/* Slot Header */} + + + + + {dayjs(slot.deliveryTime).format('ddd DD MMM, h:mm a')} + + + Orders close by: {dayjs(slot.freezeTime).format('h:mm a')} + + + + + + {slot.products.length} items + + + router.push(`/(drawer)/(tabs)/home/cart?slot=${slot.id}`)} + style={tw`bg-pink-500 p-2 rounded-full`} + > + + + + + + + {/* Products List */} + + + Available Products + + + {slot.products.slice(0, 2).map((product) => ( + router.push(`/(drawer)/(tabs)/home/product-detail/${product.id}`)} + style={tw`bg-gray-50 rounded-lg p-3 flex-row items-center`} + > + {product.images && product.images.length > 0 ? ( + + ) : ( + + + + )} + + + {product.name} + + + ₹{product.price} {product.unit && `per ${product.unit}`} + + + {product.isOutOfStock && ( + Out of stock + )} + + ))} + + {slot.products.length > 2 && ( + setSelectedSlotForDialog(slot)} + style={tw`bg-pink-50 rounded-lg p-3 flex-row items-center justify-center border border-pink-200`} + > + + +{slot.products.length - 2} more products + + + + )} + + + + )} + ListFooterComponent={() => } + showsVerticalScrollIndicator={false} + contentContainerStyle={tw`pt-2`} + /> + + {/* Products Dialog */} + setSelectedSlotForDialog(null)} + > + + + All Products - {dayjs(selectedSlotForDialog?.deliveryTime).format('ddd DD MMM, h:mm a')} + + + + + {selectedSlotForDialog?.products.map((product: any) => ( + { + setSelectedSlotForDialog(null); + router.push(`/(drawer)/(tabs)/home/product-detail/${product.id}`); + }} + style={tw`bg-gray-50 rounded-lg p-4 flex-row items-center`} + > + {product.images && product.images.length > 0 ? ( + + ) : ( + + + + )} + + + {product.name} + + + ₹{product.price} {product.unit && `per ${product.unit}`} + + {product.marketPrice && ( + + ₹{product.marketPrice} + + )} + + {product.isOutOfStock && ( + Out of stock + )} + + ))} + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/edit-profile/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/edit-profile/_layout.tsx new file mode 100644 index 0000000..a0e7d39 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/edit-profile/_layout.tsx @@ -0,0 +1,11 @@ +import { Stack } from 'expo-router' + +function EditProfileLayout() { + return ( + + + + ) +} + +export default EditProfileLayout \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/edit-profile/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/edit-profile/index.tsx new file mode 100644 index 0000000..fe89bca --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/edit-profile/index.tsx @@ -0,0 +1,184 @@ +import React, { useState, useMemo } from "react"; +import { View, ScrollView, TextInput, Alert } from "react-native"; +import { AppContainer, MyButton, MyText, tw , BottomDialog } from "common-ui"; +import RegistrationForm from "@/components/registration-form"; +import { useUserDetails, useAuth } from "@/src/contexts/AuthContext"; +import { useUpdateProfile } from "@/src/api-hooks/auth.api"; +import { router } from "expo-router"; +import { trpc } from '@/src/trpc-client'; + +function EditProfile() { + const userDetails = useUserDetails(); + const { updateUserDetails, logout } = useAuth(); + const updateProfileMutation = useUpdateProfile(); + + // State for mobile verification modal + const [showDeleteModal, setShowDeleteModal] = useState(false); + const [enteredMobile, setEnteredMobile] = useState(''); + const deleteAccountMutation = trpc.user.auth.deleteAccount.useMutation(); + + // Prevent unnecessary re-renders + const mobileInputValue = useMemo(() => enteredMobile, [enteredMobile]); + + const handleUpdate = async (data: FormData) => { + try { + const response = await updateProfileMutation.mutateAsync(data); + + // Update the context with new user details + if (response.user) { + updateUserDetails(response.user); + } + + // Navigate back to profile/me page + router.replace('/(drawer)/(tabs)/me'); + } catch (error) { + JSON.stringify(error); + console.error('Update profile error:', error); + throw error; + } + }; + + const handleDeleteAccount = () => { + setShowDeleteModal(true); + }; + + const confirmDeleteAccount = async () => { + if (!enteredMobile.trim()) { + Alert.alert('Error', 'Please enter your mobile number'); + return; + } + + try { + await deleteAccountMutation.mutateAsync({ mobile: enteredMobile }); + + Alert.alert( + 'Account Deleted', + 'Your account and all data have been successfully deleted.', + [ + { + text: 'OK', + onPress: () => { + setShowDeleteModal(false); + logout(); + } + } + ] + ); + } catch (error: any) { + Alert.alert( + 'Verification Failed', + error?.message || 'Failed to delete account. Please check your mobile number.' + ); + } + }; + + // Prepare initial values from user details + const initialValues = userDetails ? { + name: userDetails.name || '', + email: userDetails.email || '', + mobile: userDetails.mobile || '', + profileImageUri: userDetails.profileImage || undefined, + } : undefined; + + return ( + + + + + Edit Profile + + + Update your account details + + + + + + + + + + + + + + {showDeleteModal && ( + setShowDeleteModal(false)} + enableDismiss={false} + > + + + ⚠️ Delete Account Permanently + + + + This action cannot be undone. All your data will be permanently deleted. + + + + Enter your registered mobile number to confirm: + + + + + + + + + setShowDeleteModal(false)} + fillColor="gray1" + textColor="gray700" + fullWidth + /> + + + + + + + + )} + + + ); +} + +export default EditProfile; \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/index.tsx new file mode 100644 index 0000000..dc3ee53 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/index.tsx @@ -0,0 +1,151 @@ +import React from 'react'; +import { View, ScrollView } from 'react-native'; +import { useRouter } from 'expo-router'; +import { AppContainer, MyText, tw, MyTouchableOpacity, ProfileImage, colors } from 'common-ui'; +import TabLayoutWrapper from '@/components/TabLayoutWrapper'; +import { LinearGradient } from 'expo-linear-gradient'; +import { Ionicons } from '@expo/vector-icons'; +import NextOrderGlimpse from '@/components/NextOrderGlimpse'; +import { useAuth } from '@/src/contexts/AuthContext'; + +export default function Me() { + const router = useRouter(); + const { logout } = useAuth(); + + const menuSections = [ + { + title: 'Shopping & Activity', + items: [ + { + title: 'My Orders', + icon: 'receipt-outline', + color: colors.brand600, + onPress: () => router.push('/(drawer)/(tabs)/me/my-orders'), + subtitle: 'Orders history & tracking' + }, + { + title: 'My Cart', + icon: 'cart-outline', + color: '#10B981', + onPress: () => router.push('/(drawer)/(tabs)/home/cart'), + subtitle: 'Items ready for checkout' + }, + { + title: 'Coupons', + icon: 'ticket-outline', + color: '#8B5CF6', + onPress: () => router.push('/(drawer)/(tabs)/me/coupons'), + subtitle: 'View active offers & rewards' + }, + ] + }, + { + title: 'Saved Information', + items: [ + { + title: 'Addresses', + icon: 'location-outline', + color: '#F59E0B', + onPress: () => router.push('/(drawer)/(tabs)/me/addresses'), + subtitle: 'Manage delivery locations' + }, + { + title: 'Profile Settings', + icon: 'person-outline', + color: '#3B82F6', + onPress: () => router.push('/(drawer)/(tabs)/me/edit-profile'), + subtitle: 'Update your personal details' + }, + ] + }, + { + title: 'Support', + items: [ + { + title: 'Help & Complaints', + icon: 'chatbubble-ellipses-outline', + color: '#EF4444', + onPress: () => router.push('/(drawer)/(tabs)/me/complaints'), + subtitle: 'Talk to our customer care' + }, + ] + } + ]; + + return ( + + + + {/* Minimal Header Section */} + + + + My Account + + + Manage your freshyo experience + + + router.push('/(drawer)/(tabs)/me/edit-profile')} + > + + + + + {/* Upcoming Order Glimpse */} + + + {/* Menu Sections */} + + {menuSections.map((section, sIndex) => ( + + + {section.title} + + + {section.items.map((item, iIndex) => ( + + + + + + {item.title} + {item.subtitle} + + + + + + ))} + + + ))} + + {/* Footer / Logout */} + logout()} + > + + Log Out from Freshyo + + + + Version 1.2.0 • Freshyo App + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/[id].tsx b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/[id].tsx new file mode 100644 index 0000000..0590f1d --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/[id].tsx @@ -0,0 +1,430 @@ +import React, { useState, useEffect } from "react"; +import { View, ScrollView, Alert, TextInput, ActivityIndicator, KeyboardAvoidingView, Platform } from "react-native"; +import { Image } from 'expo-image'; +import { useLocalSearchParams, useRouter } from "expo-router"; +import { AppContainer, MyText, tw, MyTouchableOpacity, theme, BottomDialog } from "common-ui"; +import { trpc } from "@/src/trpc-client"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import Ionicons from '@expo/vector-icons/Ionicons'; +import dayjs from "dayjs"; +import ComplaintForm from "@/components/ComplaintForm"; + +export default function OrderDetails() { + const { id } = useLocalSearchParams<{ id: string }>(); + const router = useRouter(); + + const { + data: orderData, + isLoading, + error, + refetch, + } = trpc.user.order.getOrderById.useQuery( + { orderId: id }, + { enabled: !!id } + ); + + const [isEditingNotes, setIsEditingNotes] = useState(false); + const [notesText, setNotesText] = useState(""); + const [notesInput, setNotesInput] = useState(""); + const [cancelDialogOpen, setCancelDialogOpen] = useState(false); + const [cancelReason, setCancelReason] = useState(""); + const [complaintDialogOpen, setComplaintDialogOpen] = useState(false); + + const updateNotesMutation = trpc.user.order.updateUserNotes.useMutation({ + onSuccess: () => { + setNotesText(notesInput); + setIsEditingNotes(false); + refetch(); + Alert.alert('Success', 'Notes updated successfully'); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update notes'); + }, + }); + + const cancelOrderMutation = trpc.user.order.cancelOrder.useMutation({ + onSuccess: () => { + setCancelDialogOpen(false); + setCancelReason(""); + refetch(); + Alert.alert('Success', 'Order cancelled successfully'); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to cancel order'); + }, + }); + + const handleCancelOrder = () => { + if (!cancelReason.trim()) { + Alert.alert('Error', 'Please enter a reason for cancellation'); + return; + } + cancelOrderMutation.mutate({ id: order.orderId, reason: cancelReason }); + }; + + useEffect(() => { + if (orderData?.userNotes) { + setNotesText(orderData.userNotes); + setNotesInput(orderData.userNotes); + } + }, [orderData]); + + + if (isLoading) { + return ( + + + Loading details... + + + ); + } + + if (error || !orderData) { + return ( + + + + Failed to load + router.back()} + style={tw`mt-6 bg-slate-900 px-6 py-2 rounded-xl`} + > + Go Back + + + + ); + } + + const order = orderData; + const getStatusConfig = (status: string) => { + const s = status.toLowerCase(); + switch (s) { + case "delivered": + case "success": + return { label: "Delivered", color: "#10B981" }; + case "cancelled": + case "failed": + return { label: "Cancelled", color: "#EF4444" }; + case "pending": + case "processing": + return { label: "Pending", color: "#F59E0B" }; + default: + return { label: status, color: theme.colors.brand500 }; + } + }; + + const subtotal = order.items.reduce((sum, item) => sum + item.amount, 0); + const discountAmount = order.discountAmount || 0; + const totalAmount = order.orderAmount; + const statusConfig = getStatusConfig(order.deliveryStatus || "pending"); + + return ( + + + {/* Simple Header */} + + + + Order #{order.orderId} + {dayjs(order.orderDate).format("DD MMM, h:mm A")} + {order.isFlashDelivery && ( + ⚡ 30-Minute Flash Delivery + )} + + + + + + {statusConfig.label} + + + {order.isFlashDelivery && ( + + + + )} + + + + + {/* Flash Delivery Banner */} + {order.isFlashDelivery && ( + + + + + Flash Delivery Order + + Your order will be delivered within 30 minutes of placement + + + + + )} + + {/* Main Info Card */} + + + + + + + + Payment Method + + {order.paymentMode?.toUpperCase() === "COD" ? "Cash on Delivery" : order.paymentMode} + + + + + Status + {order.paymentStatus} + + + + {(order.deliveryDate || order.isFlashDelivery) && ["delivered", "success"].includes(order.deliveryStatus?.toLowerCase() || "") && ( + + {order.isFlashDelivery ? ( + + ) : ( + + )} + + {order.isFlashDelivery + ? `Flash Delivered on ${dayjs(order.createdAt || order.orderDate).add(30, 'minutes').format("DD MMM YYYY, h:mm A")}` + : `Delivered on ${dayjs(order.deliveryDate).format("DD MMM YYYY, h:mm A")}` + } + + + )} + + {/* Flash Delivery Info */} + {order.isFlashDelivery && !["delivered", "success"].includes(order.deliveryStatus?.toLowerCase() || "") && ( + + + + Flash Delivery: {dayjs(order.createdAt || order.orderDate).add(30, 'minutes').format("DD MMM YYYY, h:mm A")} + + + )} + + + {/* Special Instructions */} + + + Special Instructions + {isEditingNotes ? ( + + { + setIsEditingNotes(false); + setNotesInput(notesText); + }} + style={tw`px-3 py-1 bg-slate-100 rounded-lg`} + > + Cancel + + { + updateNotesMutation.mutate({ id: order.orderId, userNotes: notesInput }); + }} + disabled={updateNotesMutation.isPending} + style={tw`px-3 py-1 bg-brand500 rounded-lg`} + > + + {updateNotesMutation.isPending ? 'Saving...' : 'Save'} + + + + ) : ( + { + setNotesInput(notesText || ""); + setIsEditingNotes(true); + }} + style={tw`flex-row items-center px-2 py-1 bg-slate-50 rounded-lg`} + > + + + {notesText ? 'Edit' : 'Add'} + + + )} + + {isEditingNotes ? ( + + ) : ( + + {notesText || "No instructions added"} + + )} + + + {/* Cancellation Detail */} + {order.cancelReason && ( + + Cancellation Reason + {order.cancelReason} + {order.refundAmount && ( + + Refund Amount + ₹{order.refundAmount} + + )} + + )} + + {/* Items Section */} + + Order Items + + + {order.items.map((item: any, index: number) => ( + + + + + + {item.productName} + {item.quantity} × ₹{item.price} + + ₹{item.amount} + + ))} + + {/* Coupon */} + {order.couponCode && ( + + + + + {order.couponCode} + Coupon Applied + + + -₹{order.discountAmount} + + )} + + {/* Summary Section */} + + + Subtotal + ₹{subtotal} + + {discountAmount > 0 && ( + + Discount + -₹{discountAmount} + + )} + + Total Amount + ₹{totalAmount} + + + + {/* Footer Actions */} + + router.back()} + style={tw`flex-1 bg-slate-100 py-3.5 rounded-xl items-center`} + > + Dismiss + + setComplaintDialogOpen(true)} + style={[tw`flex-1 py-3.5 rounded-xl items-center`, { backgroundColor: theme.colors.brand600 }]} + > + Raise Complaint + + + + {/* Additional Actions */} + + {order.deliveryStatus !== 'success' && order.deliveryStatus !== 'cancelled' && ( + setCancelDialogOpen(true)} + style={tw`bg-red-50 border border-red-100 py-3.5 rounded-xl items-center flex-row justify-center`} + > + + Cancel Order + + )} + + + + {/* Cancel Order Dialog */} + setCancelDialogOpen(false)}> + + + + Cancel Order + setCancelDialogOpen(false)}> + + + + + + + Are you sure you want to cancel this order? This action cannot be undone. + + + + Reason for cancellation + + + + {cancelOrderMutation.isPending ? ( + + ) : ( + Confirm Cancellation + )} + + + + + + {/* Raise Complaint Dialog */} + setComplaintDialogOpen(false)}> + { + setComplaintDialogOpen(false); + refetch(); + }} + orderId={order.orderId} + /> + + + + ); +} diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/_layout.tsx new file mode 100755 index 0000000..d734199 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/_layout.tsx @@ -0,0 +1,11 @@ +import { Stack } from 'expo-router' + +function MyOrdersLayout() { + return ( + + + + ) +} + +export default MyOrdersLayout \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx new file mode 100755 index 0000000..d8fe1d6 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/me/my-orders/index.tsx @@ -0,0 +1,669 @@ +import React, { useState, useCallback, useEffect } from 'react'; +import { View, FlatList, Alert, ActivityIndicator } from 'react-native'; +import { Image } from 'expo-image'; +import { MaterialIcons, Ionicons } from '@expo/vector-icons'; +import { useRouter } from 'expo-router'; +import { tw, useManualRefresh, MyText, MyFlatList, useMarkDataFetchers, REFUND_STATUS, MyTouchableOpacity, theme } from 'common-ui'; + +import { trpc } from '@/src/trpc-client'; +// import RazorpayCheckout from 'react-native-razorpay'; +import OrderMenu from '@/components/OrderMenu'; +import dayjs from 'dayjs'; + +// Type definitions +interface OrderItem { + productName: string; + quantity: number; + price: number; + amount: number; + image: string | null; +} + +interface Order { + id: number; + orderId: string; + orderDate: string; + deliveryStatus: string; + deliveryDate?: string; + orderStatus: string; + cancelReason: string | null; + totalAmount: number; + deliveryCharge: number; + paymentMode: string; + paymentStatus: string; + refundStatus: string; + refundAmount: number | null; + userNotes: string | null; + items: OrderItem[]; + discountAmount?: number; + isFlashDelivery: boolean; + createdAt: string; +} + +interface OrderFooterProps { + isLoadingMore: boolean; + loadMoreError: string | null; + hasNextPage: boolean; + allOrders: Order[]; + onRetryLoadMore: () => void; +} + +const OrderFooter: React.FC = ({ + isLoadingMore, + loadMoreError, + hasNextPage, + allOrders, + onRetryLoadMore +}) => { + if (isLoadingMore) { + return ( + + + Loading more orders... + + ); + } + + if (loadMoreError) { + return ( + + {loadMoreError} + + Retry + + + ); + } + + if (!hasNextPage && allOrders.length > 0) { + return ( + + End of list + + ); + } + + return null; +}; + +interface OrderItemProps { + item: Order; + index: number; + getStatusColor: (status: string) => any; + getRefundStatusColor: (status: string) => any; + onPress: (orderId: number) => void; + onRetryPayment: (orderId: number) => void; + onViewMoreItems: (orderId: number) => void; + isPaymentPending: boolean; +} + +const OrderItem: React.FC = ({ + item, + index, + getStatusColor, + getRefundStatusColor, + onPress, + onRetryPayment, + onViewMoreItems, + isPaymentPending +}) => { + const mainStatus = getStatusColor(item.orderStatus); + const deliveryStatus = getStatusColor(item.deliveryStatus); + const totalAmount = item.totalAmount; + + return ( + onPress(item.id)} + activeOpacity={0.95} + > + {/* Top Header: Order ID and Status */} + + + + + Order Reference + + #{item.orderId} + + + + {item.orderStatus.toLowerCase() === 'cancelled' && ( + + + + {mainStatus.label} + + + )} + {item.isFlashDelivery && ( + + + FLASH + + )} + + + + + {/* Order Date & Quick Stats */} + + + {(item.deliveryDate || item.isFlashDelivery) && ( + + + {item.isFlashDelivery ? ( + + ) : ( + + )} + + + + {item.isFlashDelivery ? "Flash Delivery" : "Delivery Time"} + + + {item.isFlashDelivery + ? dayjs(item.createdAt || item.orderDate).add(30, 'minutes').format("DD MMM, hh:mm A") + : dayjs(item.deliveryDate).format("DD MMM, hh:mm A") + } + + {item.isFlashDelivery && ( + + ⚡ 30-Min Delivery + + )} + + + )} + + + + + + + Placed On + + {dayjs(item.orderDate).format("DD MMM YYYY, hh:mm A")} + + + + + + { + // refetch will be handled by parent + }} + /> + + + {/* Items Section */} + + + Items Summary + {item.items.length} {item.items.length === 1 ? 'Item' : 'Items'} + + + {item.items.slice(0, 2).map((product, index) => ( + + + + + {product.quantity} + + + + + + {product.productName} + + + Unit Price: ₹{product.price} + + + + ₹{product.amount} + + + ))} + + {item.items.length > 2 && ( + onViewMoreItems(item.id)} + > + + + {item.items.length - 2} more {item.items.length - 2 === 1 ? 'item' : 'items'} in this order + + + )} + + + {/* Delivery Status - Single Line */} + + + + {item.isFlashDelivery ? ( + + ) : ( + + )} + + + {item.isFlashDelivery ? "Flash Delivery:" : "Shipping Status:"} + + + {item.deliveryStatus} + + + {item.isFlashDelivery && ( + + ⚡ FAST + + )} + + + {/* User Notes or Delivery Time if present */} + {item.userNotes && ( + + + + + Your Instructions + {item.userNotes} + + + + )} + + {/* Cancellation Info */} + {item.cancelReason && ( + + + + Cancellation Details + + {item.cancelReason} + + {item.refundStatus && item.refundStatus !== REFUND_STATUS.NOT_APPLICABLE && ( + + Refund Status + + + + {item.refundStatus} + + + + )} + + )} + + {/* Footer: Price and CTA */} + + + Amount to Pay + ₹{totalAmount} + {item.discountAmount ? ( + + + Saved ₹{item.discountAmount} + + ) : null} + {item.deliveryCharge > 0 && ( + + + Delivery: ₹{item.deliveryCharge} + + )} + + + {(item.paymentMode === 'Online' && (item.paymentStatus === 'pending' || item.paymentStatus === 'failed')) ? ( + { + e.stopPropagation(); + onRetryPayment(item.id); + }} + disabled={isPaymentPending} + style={tw`bg-rose-600 px-6 py-3 rounded-2xl shadow-lg shadow-rose-200 flex-row items-center`} + > + {isPaymentPending ? ( + + ) : ( + <> + + Retry Payment + + )} + + ) : ( + + View Details + + + )} + + + + ); +}; + +export default function MyOrders() { + const router = useRouter(); + + // Infinite scroll state + const [allOrders, setAllOrders] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const [isLoadingMore, setIsLoadingMore] = useState(false); + const [hasNextPage, setHasNextPage] = useState(true); + const [loadMoreError, setLoadMoreError] = useState(null); + const pageSize = 10; + + const { data: ordersData, isLoading, error, refetch } = trpc.user.order.getOrders.useQuery({ + page: currentPage, + pageSize: pageSize, + }); + + + + const createRazorpayOrderMutation = trpc.user.payment.createRazorpayOrder.useMutation({ + onSuccess: (paymentData) => { + const order = allOrders.find(o => o.id === retryOrderId); + if (order) { + const totalAmount = order.items.reduce((sum, p) => sum + p.amount, 0); + // initiateRazorpayPayment(paymentData.razorpayOrderId, paymentData.key, totalAmount); + } + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to create payment order'); + }, + }); + + const verifyPaymentMutation = trpc.user.payment.verifyPayment.useMutation({ + onSuccess: () => { + refetch(); + Alert.alert('Success', 'Payment completed successfully'); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Payment verification failed'); + refetch(); + }, + }); + // Handle data accumulation for infinite scroll + useEffect(() => { + if (ordersData?.data) { + if (currentPage === 1) { + // First page - replace all orders + setAllOrders(ordersData.data); + } else { + // Subsequent pages - append to existing orders + setAllOrders(prev => [...prev, ...ordersData.data]); + } + + // Check if there are more pages + const totalPages = ordersData.pagination?.totalPages || 1; + setHasNextPage(currentPage < totalPages); + setIsLoadingMore(false); + setLoadMoreError(null); // Clear any previous errors + } + }, [ordersData, currentPage]); + + // Handle errors during infinite scroll loading + useEffect(() => { + if (error && currentPage > 1) { + // If there's an error loading more pages, show error state + setIsLoadingMore(false); + setLoadMoreError('Failed to load more orders. Please try again.'); + } + }, [error, currentPage]); + + // Reset to first page on manual refresh + useManualRefresh(() => { + setCurrentPage(1); + setAllOrders([]); + setHasNextPage(true); + setIsLoadingMore(false); + setLoadMoreError(null); + refetch(); + }); + + useMarkDataFetchers(() => { + setCurrentPage(1); + setAllOrders([]); + setHasNextPage(true); + setIsLoadingMore(false); + setLoadMoreError(null); + refetch(); + }); + + const [dialogOpen, setDialogOpen] = useState(false); + const [dialogItems, setDialogItems] = useState([]); + const [retryOrderId, setRetryOrderId] = useState(0); + + const openDialog = useCallback((items: OrderItem[]) => { + setDialogItems(items); + setDialogOpen(true); + }, []); + + // Infinite scroll functions + const loadMoreOrders = useCallback(() => { + if (!isLoadingMore && hasNextPage && !isLoading) { + setIsLoadingMore(true); + setCurrentPage(prev => prev + 1); + } + }, [isLoadingMore, hasNextPage, isLoading]); + + + + const getStatusColor = (status: string) => { + const s = status.toLowerCase(); + switch (s) { + case 'delivered': + case 'success': + case 'completed': + return { + bg: 'bg-emerald-50', + text: 'text-emerald-700', + icon: 'check-circle', + color: '#059669', + border: 'border-emerald-100', + label: 'Delivered' + }; + case 'cancelled': + case 'failed': + return { + bg: 'bg-rose-50', + text: 'text-rose-700', + icon: 'cancel', + color: '#E11D48', + border: 'border-rose-100', + label: 'Cancelled' + }; + case 'pending': + case 'payment_pending': + return { + bg: 'bg-amber-50', + text: 'text-amber-700', + icon: 'schedule', + color: '#D97706', + border: 'border-amber-100', + label: 'Pending' + }; + case 'packaged': + return { + bg: 'bg-brand50', + text: 'text-brand700', + icon: 'inventory', + color: '#1570EF', + border: 'border-brand100', + label: 'Packaged' + }; + case 'processing': + case 'confirmed': + case 'shipped': + return { + bg: 'bg-brand50', + text: 'text-brand700', + icon: 'local-shipping', + color: '#1570EF', + border: 'border-brand100', + label: status.charAt(0).toUpperCase() + status.slice(1) + }; + default: + return { + bg: 'bg-slate-50', + text: 'text-slate-700', + icon: 'info', + color: '#64748B', + border: 'border-slate-100', + label: status + }; + } + }; + + const getRefundStatusColor = (status: string) => { + switch (status) { + case REFUND_STATUS.SUCCESS: + return { bg: 'bg-emerald-50', text: 'text-emerald-700', icon: 'check-circle', color: '#059669', border: 'border-emerald-100' }; + case REFUND_STATUS.PROCESSING: + return { bg: 'bg-brand50', text: 'text-brand700', icon: 'refresh', color: '#1570EF', border: 'border-brand100' }; + case REFUND_STATUS.PENDING: + return { bg: 'bg-amber-50', text: 'text-amber-700', icon: 'schedule', color: '#D97706', border: 'border-amber-100' }; + case REFUND_STATUS.NOT_APPLICABLE: + return { bg: 'bg-slate-50', text: 'text-slate-700', icon: 'info', color: '#64748B', border: 'border-slate-100' }; + default: + return { bg: 'bg-slate-50', text: 'text-slate-700', icon: 'info', color: '#64748B', border: 'border-slate-100' }; + } + }; + + + + + + const handleRetryPayment = (orderId: number) => { + setRetryOrderId(orderId); + createRazorpayOrderMutation.mutate({ orderId: orderId.toString() }); + }; + + // const initiateRazorpayPayment = (razorpayOrderId: string, key: string, amount: number) => { + // const options = { + // key, + // amount: amount * 100, // in paisa + // currency: 'INR', + // order_id: razorpayOrderId, + // name: 'Meat Farmer', + // description: 'Order Payment Retry', + // prefill: { + // // Add user details if available + // }, + // }; + + // RazorpayCheckout.open(options) + // .then((data: any) => { + // // Payment success + // verifyPaymentMutation.mutate({ + // razorpay_payment_id: data.razorpay_payment_id, + // razorpay_order_id: data.razorpay_order_id, + // razorpay_signature: data.razorpay_signature, + // }); + // }) + // .catch((error: any) => { + // Alert.alert('Payment Failed', 'Payment failed. Please try again.'); + // refetch(); + // }); + // }; + + if (isLoading && currentPage === 1) { + return ( + + + Loading your orders... + + ); + } + + if (error) { + return ( + + + + + Unable to load orders + Please check your connection and try again + refetch()} + style={tw`bg-blue-600 px-8 py-3 rounded-full shadow-md`} + > + Retry + + + ); + } + + return ( + + ( + router.push(`/(drawer)/(tabs)/me/my-orders/${orderId}`)} + onRetryPayment={handleRetryPayment} + onViewMoreItems={(orderId) => router.push(`/(drawer)/(tabs)/me/my-orders/${orderId}`)} + isPaymentPending={createRazorpayOrderMutation.isPending} + /> + )} + keyExtractor={(item) => item.orderId} + showsVerticalScrollIndicator={false} + onEndReached={loadMoreOrders} + onEndReachedThreshold={0.5} + ListFooterComponent={ + { + setLoadMoreError(null); + loadMoreOrders(); + }} + /> + } + ListEmptyComponent={ + + + + + No orders yet + Your order history will appear here + router.push('/(drawer)/(tabs)/home')} + > + Start Shopping + + + } + /> + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/order-again/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/order-again/_layout.tsx new file mode 100644 index 0000000..7dcc4d4 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/order-again/_layout.tsx @@ -0,0 +1,12 @@ +import { Stack } from 'expo-router'; + +export default function StoresLayout() { + return ( + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/order-again/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/order-again/index.tsx new file mode 100644 index 0000000..e6637c1 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/order-again/index.tsx @@ -0,0 +1,186 @@ +import React, { useState } from "react"; +import { + View, + Dimensions, + Image, + Platform, + Alert, + ScrollView, +} from "react-native"; +import { LinearGradient } from "expo-linear-gradient"; +import { useRouter } from "expo-router"; +import { + theme, + tw, + useManualRefresh, + useMarkDataFetchers, + LoadingDialog, + AppContainer, + MyFlatList, + MyText, +} from "common-ui"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import ProductCard from "@/components/ProductCard"; + +import { trpc } from "@/src/trpc-client"; +import { useGetCart, useAddToCart } from '@/hooks/cart-query-hooks'; +import { useProductSlotIdentifier } from '@/hooks/useProductSlotIdentifier'; +import FloatingCartBar from "@/components/floating-cart-bar"; +import TabLayoutWrapper from "@/components/TabLayoutWrapper"; + +const { width: screenWidth } = Dimensions.get("window"); +const itemWidth = (screenWidth - 48) / 2; // 2 items per row with padding + +export default function OrderAgain() { + const router = useRouter(); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); + + const { + data: recentProductsData, + isLoading, + error, + refetch, + } = trpc.user.order.getRecentlyOrderedProducts.useQuery({ + limit: 20, + }); + + + + const { data: cartData, refetch: refetchCart } = useGetCart(); + const { addToCart = () => {} } = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }) || {}; + const { getQuickestSlot } = useProductSlotIdentifier(); + + const recentProducts = recentProductsData?.products || []; + + useManualRefresh(() => { + refetch(); + }); + + useMarkDataFetchers(() => { + refetch(); + }); + + const handleAddToCart = (productId: number) => { + const slotId = getQuickestSlot(productId); + if (!slotId) { + Alert.alert("Error", "No available delivery slot for this product"); + return; + } + + setIsLoadingDialogOpen(true); + addToCart(productId, 1, slotId, () => setIsLoadingDialogOpen(false)); + }; + + const handleBuyNow = (productId: number) => { + const slotId = getQuickestSlot(productId); + if (!slotId) { + Alert.alert("Error", "No available delivery slot for this product"); + return; + } + + setIsLoadingDialogOpen(true); + addToCart(productId, 1, slotId, () => { + setIsLoadingDialogOpen(false); + router.push(`/(drawer)/(tabs)/home/cart?select=${productId}`); + }); + }; + + if (isLoading) { + return ( + + + + Loading your recent orders... + + + ); + } + + if (error) { + return ( + + + + Oops! + Failed to load recent orders + + + ); + } + + return ( + + + + + + + + + + + Order Again + + + + Reorder your favorite items quickly + + + + + + {/* White Section */} + + {/* Section Title */} + + Recently Ordered + + + {recentProducts.length === 0 ? ( + + + + + + No recent orders + + + Items you've ordered recently will appear here + + + ) : ( + + + {recentProducts.map((item, index) => ( + + router.push(`/(drawer)/(tabs)/order-again/product-detail/${item.id}`)} + showDeliveryInfo={false} + // iconType="flash" + /> + + ))} + + + )} + + + + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/[id]/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/[id]/index.tsx new file mode 100644 index 0000000..1ae676a --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/[id]/index.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { useLocalSearchParams } from 'expo-router'; +import ProductDetail from '@/components/ProductDetail'; +import { View } from 'react-native'; +import { tw } from 'common-ui'; +import FloatingCartBar from '@/components/floating-cart-bar'; + +export default function ProductDetailPage() { + const { id } = useLocalSearchParams(); + const productId = id as string; + + return ( + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/_layout.tsx new file mode 100644 index 0000000..23c9a30 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/_layout.tsx @@ -0,0 +1,20 @@ +import FloatingCartBar from '@/components/floating-cart-bar'; +import { tw } from 'common-ui'; +import { Stack } from 'expo-router'; +import { View } from 'react-native'; + +export default function StoresLayout() { + return ( + <> + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/index.tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/index.tsx new file mode 100644 index 0000000..1d44a6d --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/index.tsx @@ -0,0 +1,235 @@ +import React, { useState } from "react"; +import { + View, + FlatList, +} from "react-native"; +import { Image } from 'expo-image'; +import { useRouter } from "expo-router"; +import { + theme, + tw, + useManualRefresh, + useMarkDataFetchers, + MyFlatList, + MyText, + MyTouchableOpacity, +} from "common-ui"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { Ionicons } from "@expo/vector-icons"; +import { trpc } from "@/src/trpc-client"; +import { LinearGradient } from "expo-linear-gradient"; +import TabLayoutWrapper from "@/components/TabLayoutWrapper"; +import FloatingCartBar from "@/components/floating-cart-bar"; +import { useFocusEffect } from "expo-router"; +import { useNavigationStore } from "@/src/store/navigationStore"; + +const StoreCard = ({ + item, + router, +}: { + item: any; + router: any; +}) => { + const sampleProducts = item.sampleProducts || []; + const remainingCount = item.productCount - sampleProducts.length; + + const navigateToStore = () => router.push(`/(drawer)/(tabs)/stores/store-detail/${item.id}`); + + return ( + + {/* Top Header Section - Touchable */} + + + + + {!item.signedImageUrl && ( + + + + )} + + + + + {item.name} + + + + + {item.productCount} + Items + + + + + {/* Horizontal Scrollable Product Collection */} + + product.id.toString()} + renderItem={({ item: product }) => ( + + + + + + {product.name} + + + )} + ListFooterComponent={remainingCount > 0 ? ( + + + +{remainingCount} + Discover + + + + + ) : null} + /> + + + + + Explore Store + + + + + ); +}; + +export default function Stores() { + const router = useRouter(); + + const { + data: storesData, + isLoading, + error, + refetch, + } = trpc.user.stores.getStores.useQuery(); + + const stores = storesData?.stores || []; + + useManualRefresh(refetch); + useMarkDataFetchers(() => refetch()); + + const { isNavigatedFromHome, setNavigatedFromHome, selectedStoreId, setSelectedStoreId } = useNavigationStore(); + + useFocusEffect(() => { + if (isNavigatedFromHome && selectedStoreId) { + setNavigatedFromHome(false); + setSelectedStoreId(null); + router.push(`/(drawer)/(tabs)/stores/store-detail/${selectedStoreId}`); + } + }); + + if (isLoading) { + return ( + + + + + Opening Marketplace... + + ); + } + + if (error) { + return ( + + + + + Store Fetch Failed + + We couldn't reach our vendor network. + + refetch()} + style={tw`bg-brand600 px-8 py-3 rounded-2xl shadow-lg shadow-brand200`} + > + Retry + + + ); + } + + return ( + + + } + keyExtractor={(item) => item.id.toString()} + contentContainerStyle={tw`pb-32 px-3`} + showsVerticalScrollIndicator={false} + ListHeaderComponent={ + + + + + + Our Outlets + + + Our Stores + + + + + Experience the finest selection of premium meat, poultry, fresh fruits, vegetables, and dairy directly from our own stores. + + + } + ListEmptyComponent={ + + + + + No Stores Available + + } + /> + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/[id].tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/[id].tsx new file mode 100644 index 0000000..66f667f --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/[id].tsx @@ -0,0 +1,135 @@ +import React, { useState } from 'react'; +import { + View, + Dimensions, + Image, + TouchableOpacity, + Alert, + Platform, +} from 'react-native'; +import { useRouter, useLocalSearchParams } from 'expo-router'; +import { theme, tw, useManualRefresh, MyFlatList, useDrawerTitle, useMarkDataFetchers, LoadingDialog, MyText, MyTouchableOpacity } from 'common-ui'; +import dayjs from 'dayjs'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import FontAwesome5 from '@expo/vector-icons/FontAwesome5'; +import { trpc } from '@/src/trpc-client'; +import { useAddToCart } from '@/hooks/cart-query-hooks'; +import ProductCard from '@/components/ProductCard'; +import FloatingCartBar from '@/components/floating-cart-bar'; + +const { width: screenWidth } = Dimensions.get('window'); +const itemWidth = (screenWidth - 48) / 2; // 48 = padding horizontal (16*2) + gap (16) + + +export default function StoreDetail() { + const router = useRouter(); + // const { storeId } = useLocalSearchParams(); + const { id: storeId } = useLocalSearchParams(); + const storeIdNum = parseInt(storeId as string); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); + + const { data: storeData, isLoading, refetch, error } = trpc.user.stores.getStoreWithProducts.useQuery( + { storeId: storeIdNum }, + { enabled: !!storeIdNum } + ); + + + useMarkDataFetchers(() => { + refetch(); + }); + + useDrawerTitle(storeData?.store?.name || 'Store', [storeData?.store?.name]); + + const addToCart = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }); + + const handleAddToCart = (productId: number) => { + setIsLoadingDialogOpen(true); + addToCart.mutate({ productId, quantity: 1 }, { + onSuccess: () => { + Alert.alert('Success', 'Item added to cart!'); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to add item to cart'); + }, + onSettled: () => { + setIsLoadingDialogOpen(false); + }, + }); + }; + + const handleBuyNow = (productId: number) => { + setIsLoadingDialogOpen(true); + addToCart.mutate({ productId, quantity: 1 }, { + onSuccess: () => { + router.push(`/(drawer)/(tabs)/home/cart?select=${productId}`); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to add item to cart'); + }, + onSettled: () => { + setIsLoadingDialogOpen(false); + }, + }); + }; + + if (isLoading) { + return ( + + Loading store... + + ); + } + + if (error || !storeData) { + return ( + + + Oops! + Store not found or error loading + + ); + } + + return ( + + ( + router.push(`/(drawer)/(tabs)/stores/store-detail/product-detail/${item.id}`)} + showDeliveryInfo={false} + miniView={true} + /> + )} + keyExtractor={(item, index) => index.toString()} + columnWrapperStyle={{ gap: 16 }} + contentContainerStyle={[tw`px-4 pb-24`, { gap: 16 }]} + ListHeaderComponent={ + + + + + + {storeData?.store?.name} + {storeData?.store?.description && ( + {storeData?.store?.description} + )} + + + + Products from this Store + + + } + /> + + + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/_layout.tsx new file mode 100644 index 0000000..86a1d6c --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from 'expo-router'; + +export default function StoreDetailLayout() { + return ( + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/[id].tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/[id].tsx new file mode 100644 index 0000000..7f7b42c --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/[id].tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { useLocalSearchParams } from 'expo-router'; +import ProductDetail from '@/components/ProductDetail'; +import { View } from 'react-native'; +import { tw } from 'common-ui'; +import FloatingCartBar from '@/components/floating-cart-bar'; + +export default function ProductDetailPage() { + const { id } = useLocalSearchParams(); + const productId = id as string; + + return( + <> + + + ) +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx new file mode 100644 index 0000000..7d1194a --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx @@ -0,0 +1,12 @@ +import { Stack } from 'expo-router'; + +export default function ProductDetailLayout() { + return ( + + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/(drawer)/_layout.tsx b/apps/user-ui/app/(drawer)/_layout.tsx new file mode 100755 index 0000000..f1c2f2e --- /dev/null +++ b/apps/user-ui/app/(drawer)/_layout.tsx @@ -0,0 +1,119 @@ +import { Tabs } from "expo-router/tabs"; +import { Redirect } from "expo-router"; +import { + View, + ActivityIndicator, + StatusBar, +} from "react-native"; +import { LinearGradient } from "expo-linear-gradient"; +import { Ionicons } from "@expo/vector-icons"; +import { useAuth } from "@/src/contexts/AuthContext"; +import { tw, theme, MyTouchableOpacity, MyText } from "common-ui"; +import ProfileChecker from "@/components/ProfileChecker"; +import HomeIcon from "@/components/icons/HomeIcon"; +import StoresIcon from "@/components/icons/StoresIcon"; +import OrderAgainIcon from "@/components/icons/OrderAgainIcon"; +import MeIcon from "@/components/icons/MeIcon"; +import { useAppStore } from "@/src/store/appStore"; + +export default function Layout() { + const { isAuthenticated, isLoading } = useAuth(); + const hideTabsNav = useAppStore((state) => state.hideTabsNav); + const shouldHideTabs = Object.values(hideTabsNav).some(Boolean); + + + + if (isLoading) { + return ( + + + + ); + } + + return ( + <> + {/* */} + + ( + + ), + }} + /> + ( + + ), + }} + /> + null, + tabBarIcon: () => null, + tabBarButton: (props) => ( + + + + + + Flash Delivery + + + ), + }} + /> + ( + + ), + }} + /> + ( + + ), + }} + /> + + + + ); +} diff --git a/apps/user-ui/app/_layout.tsx b/apps/user-ui/app/_layout.tsx new file mode 100755 index 0000000..4d1331d --- /dev/null +++ b/apps/user-ui/app/_layout.tsx @@ -0,0 +1,79 @@ +import { + DarkTheme, + DefaultTheme, + ThemeProvider, +} from "@react-navigation/native"; +import { useFonts } from "expo-font"; +import { Stack } from "expo-router"; +import "react-native-reanimated"; + +import { useColorScheme } from "@/hooks/useColorScheme"; +import { Appearance, Dimensions, StatusBar, View } from "react-native"; +import { QueryClientProvider } from "@tanstack/react-query"; +import { theme , MyStatusBar } from "common-ui"; +import queryClient from "@/utils/queryClient"; +import Toast from "react-native-toast-message"; +import { NotificationProvider } from "@/services/notif-service/notif-context"; +import { Provider as PaperProvider } from "react-native-paper"; +import { AuthProvider } from "@/src/contexts/AuthContext"; +import { trpc, trpcClient } from "@/src/trpc-client"; +import { SafeAreaView, SafeAreaProvider } from "react-native-safe-area-context"; +import LocationTestWrapper from "@/components/LocationTestWrapper"; +import HealthTestWrapper from "@/components/HealthTestWrapper"; +import FirstUserWrapper from "@/components/FirstUserWrapper"; +import UpdateChecker from "@/components/UpdateChecker"; +import { RefreshProvider } from "../../../packages/ui/src/lib/refresh-context"; +import WebViewWrapper from "@/components/WebViewWrapper"; +import React from "react"; + +export default function RootLayout() { + const colorScheme = useColorScheme(); + const [loaded] = useFonts({ + SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"), + }); + + React.useEffect(() => { + Appearance.setColorScheme('light') + }, []); + + if (!loaded) { + return null; + } + + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/apps/user-ui/app/api/auth/authorize+api.ts b/apps/user-ui/app/api/auth/authorize+api.ts new file mode 100644 index 0000000..215e170 --- /dev/null +++ b/apps/user-ui/app/api/auth/authorize+api.ts @@ -0,0 +1,55 @@ +import constants from "@/src/constants"; + +const GOOGLE_CLIENT_ID = constants.GOOGLE_CLIENT_ID; +export async function GET(request: Request) { + + if (!GOOGLE_CLIENT_ID) { + return Response.json( + { error: "Missing GOOGLE_CLIENT_ID environment variable" }, + { status: 500 } + ); + } + + const url = new URL(request.url); + let idpClientId: string; + + const internalClient = url.searchParams.get("client_id"); + + const redirectUri = url.searchParams.get("redirect_uri"); + + + let platform; + + if (redirectUri === constants.APP_SCHEME) { + platform = "mobile"; + } else if (redirectUri === constants.BASE_URL) { + platform = "web"; + } else { + return Response.json({ error: "Invalid redirect_uri" }, { status: 400 }); + } + + // use state to drive redirect back to platform + let state = platform + "|" + url.searchParams.get("state"); + + if (internalClient === "google") { + idpClientId = GOOGLE_CLIENT_ID; + } else { + return Response.json({ error: "Invalid client" }, { status: 400 }); + } + + // additional enforcement + if (!state) { + return Response.json({ error: "Invalid state" }, { status: 400 }); + } + + const params = new URLSearchParams({ + client_id: idpClientId, + redirect_uri: constants.BASE_URL + "/api/auth/callback", + response_type: "code", + scope: url.searchParams.get("scope") || "identity", + state: state, + prompt: "select_account", + }); + + return Response.redirect(constants.GOOGLE_AUTH_URL + "?" + params.toString()); +} \ No newline at end of file diff --git a/apps/user-ui/app/api/auth/callback+api.ts b/apps/user-ui/app/api/auth/callback+api.ts new file mode 100644 index 0000000..06ac1d2 --- /dev/null +++ b/apps/user-ui/app/api/auth/callback+api.ts @@ -0,0 +1,28 @@ +// import { BASE_URL, APP_SCHEME } from "@/utils/constants"; + +import constants from "@/src/constants"; + +const BASE_URL = constants.BASE_URL; +const APP_SCHEME = constants.APP_SCHEME; + +export async function GET(request: Request) { + const incomingParams = new URLSearchParams(request.url.split("?")[1]); + const combinedPlatformAndState = incomingParams.get("state"); + if (!combinedPlatformAndState) { + return Response.json({ error: "Invalid state" }, { status: 400 }); + } + // strip platform to return state as it was set on the client + const platform = combinedPlatformAndState.split("|")[0]; + const state = combinedPlatformAndState.split("|")[1]; + + const outgoingParams = new URLSearchParams({ + code: incomingParams.get("code")?.toString() || "", + state, + }); + + return Response.redirect( + (platform === "web" ? BASE_URL : APP_SCHEME) + + "?" + + outgoingParams.toString() + ); +} \ No newline at end of file diff --git a/apps/user-ui/app/api/auth/token+api.ts b/apps/user-ui/app/api/auth/token+api.ts new file mode 100644 index 0000000..84483d8 --- /dev/null +++ b/apps/user-ui/app/api/auth/token+api.ts @@ -0,0 +1,4 @@ +export async function GET(request:Request) { + console.log('from the get token request') + +} \ No newline at end of file diff --git a/apps/user-ui/app/index.tsx b/apps/user-ui/app/index.tsx new file mode 100755 index 0000000..c09216b --- /dev/null +++ b/apps/user-ui/app/index.tsx @@ -0,0 +1,22 @@ +import { Redirect } from 'expo-router'; +import { useAuth } from '@/src/contexts/AuthContext'; +import { View, ActivityIndicator } from 'react-native'; +import { tw, AppContainer } from 'common-ui'; + +export default function Index() { + const { isAuthenticated, isLoading } = useAuth(); + + if (isLoading) { + return ( + + + + + + ); + } + + + console.log("from the user ui index.tsx - isAuthenticated:", isAuthenticated); + return ; +} \ No newline at end of file diff --git a/apps/user-ui/assets/fonts/SpaceMono-Regular.ttf b/apps/user-ui/assets/fonts/SpaceMono-Regular.ttf new file mode 100755 index 0000000..28d7ff7 Binary files /dev/null and b/apps/user-ui/assets/fonts/SpaceMono-Regular.ttf differ diff --git a/apps/user-ui/assets/images/adaptive-icon.png b/apps/user-ui/assets/images/adaptive-icon.png new file mode 100755 index 0000000..03d6f6b Binary files /dev/null and b/apps/user-ui/assets/images/adaptive-icon.png differ diff --git a/apps/user-ui/assets/images/farm2door-logo.png b/apps/user-ui/assets/images/farm2door-logo.png new file mode 100644 index 0000000..95f9b8b Binary files /dev/null and b/apps/user-ui/assets/images/farm2door-logo.png differ diff --git a/apps/user-ui/assets/images/favicon.png b/apps/user-ui/assets/images/favicon.png new file mode 100755 index 0000000..e75f697 Binary files /dev/null and b/apps/user-ui/assets/images/favicon.png differ diff --git a/apps/user-ui/assets/images/freshyo-logo.png b/apps/user-ui/assets/images/freshyo-logo.png new file mode 100644 index 0000000..83f0a8c Binary files /dev/null and b/apps/user-ui/assets/images/freshyo-logo.png differ diff --git a/apps/user-ui/assets/images/freshyo-logoo.png b/apps/user-ui/assets/images/freshyo-logoo.png new file mode 100644 index 0000000..f8d701c Binary files /dev/null and b/apps/user-ui/assets/images/freshyo-logoo.png differ diff --git a/apps/user-ui/assets/images/freshyo-logoo.svg b/apps/user-ui/assets/images/freshyo-logoo.svg new file mode 100644 index 0000000..345afcf --- /dev/null +++ b/apps/user-ui/assets/images/freshyo-logoo.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/user-ui/assets/images/icon.png b/apps/user-ui/assets/images/icon.png new file mode 100755 index 0000000..a0b1526 Binary files /dev/null and b/apps/user-ui/assets/images/icon.png differ diff --git a/apps/user-ui/assets/images/logo.png b/apps/user-ui/assets/images/logo.png new file mode 100644 index 0000000..4c13a45 Binary files /dev/null and b/apps/user-ui/assets/images/logo.png differ diff --git a/apps/user-ui/assets/images/logo_mini.jpg b/apps/user-ui/assets/images/logo_mini.jpg new file mode 100644 index 0000000..4782a53 Binary files /dev/null and b/apps/user-ui/assets/images/logo_mini.jpg differ diff --git a/apps/user-ui/assets/images/partial-react-logo.png b/apps/user-ui/assets/images/partial-react-logo.png new file mode 100755 index 0000000..66fd957 Binary files /dev/null and b/apps/user-ui/assets/images/partial-react-logo.png differ diff --git a/apps/user-ui/assets/images/react-logo.png b/apps/user-ui/assets/images/react-logo.png new file mode 100755 index 0000000..9d72a9f Binary files /dev/null and b/apps/user-ui/assets/images/react-logo.png differ diff --git a/apps/user-ui/assets/images/react-logo@2x.png b/apps/user-ui/assets/images/react-logo@2x.png new file mode 100755 index 0000000..2229b13 Binary files /dev/null and b/apps/user-ui/assets/images/react-logo@2x.png differ diff --git a/apps/user-ui/assets/images/react-logo@3x.png b/apps/user-ui/assets/images/react-logo@3x.png new file mode 100755 index 0000000..a99b203 Binary files /dev/null and b/apps/user-ui/assets/images/react-logo@3x.png differ diff --git a/apps/user-ui/assets/images/splash-icon.png b/apps/user-ui/assets/images/splash-icon.png new file mode 100755 index 0000000..03d6f6b Binary files /dev/null and b/apps/user-ui/assets/images/splash-icon.png differ diff --git a/apps/user-ui/assets/images/symbuyote.png b/apps/user-ui/assets/images/symbuyote.png new file mode 100644 index 0000000..4f32b0c Binary files /dev/null and b/apps/user-ui/assets/images/symbuyote.png differ diff --git a/apps/user-ui/assets/logo.png b/apps/user-ui/assets/logo.png new file mode 100644 index 0000000..0ca5730 Binary files /dev/null and b/apps/user-ui/assets/logo.png differ diff --git a/apps/user-ui/components/AddressSelector.tsx b/apps/user-ui/components/AddressSelector.tsx new file mode 100644 index 0000000..8183ecc --- /dev/null +++ b/apps/user-ui/components/AddressSelector.tsx @@ -0,0 +1,163 @@ +import React from "react"; +import { View, Dimensions } from "react-native"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { + BottomDropdown, + MyTouchableOpacity, + MyText, + tw, + theme, +} from "common-ui"; +import { useAuth } from "@/src/contexts/AuthContext"; +import { trpc } from "@/src/trpc-client"; +import { useAddressStore } from "@/src/store/addressStore"; + +const { width: screenWidth } = Dimensions.get("window"); + +interface AddressSelectorProps { + mode?: "home"; + deliveryTime?: string; +} + +const AddressSelector: React.FC = ({ + mode = "home", + deliveryTime, +}) => { + const { isAuthenticated } = useAuth(); + const { selectedAddressId, setSelectedAddressId } = useAddressStore(); + + const { data: defaultAddressData } = + trpc.user.address.getDefaultAddress.useQuery(); + const { data: addressesData } = trpc.user.address.getUserAddresses.useQuery( + undefined, + { + enabled: isAuthenticated, + } + ); + + const defaultAddress = defaultAddressData?.data; + const addresses = addressesData?.data || []; + + // Transform addresses for dropdown + const addressOptions = addresses.map((address) => ({ + label: `${address.name} - ${address.addressLine1}, ${address.city}`, + value: address.id, + })); + + const handleAddressChange = ( + value: string | number | string[] | number[] + ) => { + const addressId = value as number; + setSelectedAddressId(addressId); + }; + + // Helper to get display parts + const getDisplayParts = (displayText?: string) => { + const fullText = + displayText || + (defaultAddress + ? `${defaultAddress.name} - ${defaultAddress.addressLine1}, ${defaultAddress.city}` + : ""); + let name = defaultAddress ? defaultAddress.name : "Home"; + let address = defaultAddress + ? `${defaultAddress.addressLine1}, ${defaultAddress.city}` + : "Add your delivery address"; + + if (fullText) { + const parts = fullText.split(" - "); + if (parts.length >= 1) name = parts[0]; + if (parts.length > 1) address = parts.slice(1).join(" - "); + } + return { name, address }; + }; + + const { name: defaultName, address: defaultAddr } = getDisplayParts(); + + if (!isAuthenticated) { + // Static display for non-authenticated users (Home mode) + return ( + + + + + + + + Delivery to {defaultName} + + + {defaultAddr} + + + + + ); + } + + return ( + { + const { name, address } = getDisplayParts(displayText); + + // Home styling + return ( + + + + + + + + + to {name} + + {/* */} + + + {address} + + + + + ); + }} + /> + ); +}; + +export default AddressSelector; diff --git a/apps/user-ui/components/BannerCarousel.tsx b/apps/user-ui/components/BannerCarousel.tsx new file mode 100644 index 0000000..49bf501 --- /dev/null +++ b/apps/user-ui/components/BannerCarousel.tsx @@ -0,0 +1,143 @@ +import React, { useState, useRef, useEffect } from 'react'; +import { View, Dimensions, Image, ScrollView, NativeSyntheticEvent, NativeScrollEvent } from 'react-native'; +import { MyTouchableOpacity, MyText, tw } from 'common-ui'; +import { useRouter } from 'expo-router'; +import { trpc } from '@/src/trpc-client'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +const { width: screenWidth } = Dimensions.get('window'); + +interface Banner { + id: number; + name: string; + imageUrl: string; + description?: string | null; + productIds?: number[] | null; + redirectUrl?: string | null; + serialNum?: number | null; + isActive: boolean; +} + +export default function BannerCarousel() { + const router = useRouter(); + const scrollViewRef = useRef(null); + const [currentIndex, setCurrentIndex] = useState(0); + const [isAutoPlaying, setIsAutoPlaying] = useState(true); + + // Fetch banners data + const { data: bannersData, isLoading, error } = trpc.user.banner.getBanners.useQuery(); + const banners = bannersData?.banners || []; + + // Auto-play functionality + useEffect(() => { + if (banners.length <= 1 || !isAutoPlaying) return; // Don't auto-play if conditions not met + + const interval = setInterval(() => { + setCurrentIndex((prevIndex) => { + const nextIndex = (prevIndex + 1) % banners.length; + // Auto-scroll to next slide + if (scrollViewRef.current) { + scrollViewRef.current.scrollTo({ + x: nextIndex * (screenWidth - 32), + animated: true, + }); + } + return nextIndex; + }); + }, 6000); // 6 seconds + + return () => clearInterval(interval); // Cleanup on unmount + }, [banners.length, isAutoPlaying]); + + if (isLoading) { + return ( + + Loading banners... + + ); + } + + if (error || !banners || banners.length === 0) return null; + + const handleBannerPress = (banner: Banner) => { + if (banner.productIds && banner.productIds.length > 0) { + // Navigate to the first product's detail page + router.push(`/(drawer)/(tabs)/home/product-detail/${banner.productIds[0]}`); + } else if (banner.redirectUrl) { + // Handle external URL - could open in browser or handle deep links + console.log('Banner redirect URL:', banner.redirectUrl); + } + // If no productIds or redirectUrl, banner is just for display + }; + + const handleScroll = (event: NativeSyntheticEvent) => { + const slideSize = screenWidth - 32; // width minus horizontal padding + const index = Math.round(event.nativeEvent.contentOffset.x / slideSize); + setCurrentIndex(index); + }; + + const goToSlide = (index: number) => { + setIsAutoPlaying(false); // Pause auto-play when user manually navigates + if (scrollViewRef.current) { + scrollViewRef.current.scrollTo({ + x: index * (screenWidth - 32), + animated: true, + }); + } + setCurrentIndex(index); + // Resume auto-play after a short delay + setTimeout(() => setIsAutoPlaying(true), 1000); + }; + + return ( + + setIsAutoPlaying(false)} + onTouchEnd={() => setIsAutoPlaying(true)} + onMomentumScrollEnd={() => setIsAutoPlaying(true)} + > + {banners.map((banner: Banner) => ( + handleBannerPress(banner)} + style={tw`mr-4 rounded-2xl overflow-hidden`} + activeOpacity={0.9} + > + + + ))} + + + {/* Pagination Dots */} + {banners.length > 1 && ( + + {banners.map((_, index: number) => ( + goToSlide(index)} + style={tw`mx-1`} + > + + + ))} + + )} + + ); +} \ No newline at end of file diff --git a/apps/user-ui/components/CheckoutAddressSelector.tsx b/apps/user-ui/components/CheckoutAddressSelector.tsx new file mode 100644 index 0000000..a281804 --- /dev/null +++ b/apps/user-ui/components/CheckoutAddressSelector.tsx @@ -0,0 +1,129 @@ +import React, { useState, useEffect } from 'react'; +import { View, Text, TouchableOpacity, ScrollView } from 'react-native'; +import { tw, BottomDialog } from 'common-ui'; +import { useQueryClient } from '@tanstack/react-query'; +import AddressForm from '@/src/components/AddressForm'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { trpc } from '@/src/trpc-client'; + +interface AddressSelectorProps { + selectedAddress: number | null; + onAddressSelect: (addressId: number) => void; +} + +const CheckoutAddressSelector: React.FC = ({ + selectedAddress, + onAddressSelect, +}) => { + const [showAddAddress, setShowAddAddress] = useState(false); + const queryClient = useQueryClient(); + const { data: addresses } = trpc.user.address.getUserAddresses.useQuery(); + + // Sort addresses with selected first, then default, then others + const sortedAddresses = React.useMemo(() => { + if (!addresses?.data) return []; + return [...addresses.data].sort((a, b) => { + // Selected address comes first + if (selectedAddress === a.id && selectedAddress !== b.id) return -1; + if (selectedAddress === b.id && selectedAddress !== a.id) return 1; + + // Then default address (if not already selected) + if (a.isDefault && !b.isDefault) return -1; + if (!a.isDefault && b.isDefault) return 1; + + // Maintain stable sort by id for other addresses + return a.id - b.id; + }); + }, [addresses?.data, selectedAddress]); + + // Auto-select default address when addresses are loaded and none is selected + useEffect(() => { + if (sortedAddresses.length > 0 && selectedAddress === null) { + const defaultAddress = sortedAddresses.find(addr => addr.isDefault); + if (defaultAddress) { + onAddressSelect(defaultAddress.id); + } + } + }, [sortedAddresses, selectedAddress, onAddressSelect]); + + return ( + <> + + + + + + + + Delivery Address + + + setShowAddAddress(true)}> + + Add New + + + + {(!sortedAddresses || sortedAddresses.length === 0) ? ( + + + No addresses found + setShowAddAddress(true)} style={tw`mt-3 bg-brand500 px-4 py-2 rounded-lg`}> + Add Address + + + ) : ( + + {sortedAddresses.map((address) => ( + onAddressSelect(address.id)} + style={tw`w-72 p-4 mr-3 bg-gray-50 rounded-xl border-2 ${selectedAddress === address.id ? 'border-brand500 bg-blue-50' : 'border-gray-200' + } shadow-sm`} + > + + + + + {address.name} + + + {selectedAddress === address.id && ( + + + + )} + + + {address.addressLine1}{address.addressLine2 ? `, ${address.addressLine2}` : ''} + + + {address.city}, {address.state} - {address.pincode} + + + Phone: {address.phone} + + + ))} + + )} + + + setShowAddAddress(false)}> + { + setShowAddAddress(false); + queryClient.invalidateQueries(); + }} + /> + + + ); +}; + +export default CheckoutAddressSelector; \ No newline at end of file diff --git a/apps/user-ui/components/ComplaintForm.tsx b/apps/user-ui/components/ComplaintForm.tsx new file mode 100644 index 0000000..115d7a9 --- /dev/null +++ b/apps/user-ui/components/ComplaintForm.tsx @@ -0,0 +1,128 @@ +import React, { useState } from 'react'; +import { View, TextInput, ActivityIndicator, KeyboardAvoidingView, Platform, Alert } from 'react-native'; +import { MaterialIcons } from '@expo/vector-icons'; +import { useMutation } from "@tanstack/react-query"; +import { MyText, ImageUploader, tw, MyTouchableOpacity } from 'common-ui'; +import usePickImage from 'common-ui/src/components/use-pick-image'; +import axios from '../services/axios-user-ui'; +// import axios from 'common-ui/src/services/axios'; + +interface ComplaintFormProps { + open: boolean; + onClose: () => void; + orderId: string; +} + +export default function ComplaintForm({ open, onClose, orderId }: ComplaintFormProps) { + const [complaintBody, setComplaintBody] = useState(''); + const [complaintImages, setComplaintImages] = useState<{ uri?: string }[]>([]); + + // API function + const raiseComplaintApi = async (payload: { complaintBody: string; images: { uri?: string }[] }) => { + const formData = new FormData(); + + formData.append('orderId', orderId); + formData.append('complaintBody', payload.complaintBody); + + // Add images if provided + if (payload.images && payload.images.length > 0) { + payload.images.forEach((image, index) => { + if (image.uri) { + const fileName = `complaint-image-${index}.jpg`; + formData.append('images', { + uri: image.uri, + name: fileName, + type: 'image/jpeg', + } as any); + } + }); + } + + const response = await axios.post('/uv/complaints/raise', formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data; + }; + + // Hook + const raiseComplaintMutation = useMutation({ + mutationFn: raiseComplaintApi, + }); + + const pickComplaintImage = usePickImage({ + setFile: (files) => setComplaintImages(prev => [...prev, ...files]), + multiple: true, + }); + + const handleSubmit = () => { + if (!complaintBody.trim()) { + Alert.alert('Error', 'Please enter complaint details'); + return; + } + + raiseComplaintMutation.mutate( + { + complaintBody: complaintBody.trim(), + images: complaintImages, + }, + { + onSuccess: () => { + Alert.alert('Success', 'Complaint raised successfully'); + setComplaintBody(''); + setComplaintImages([]); + onClose(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to raise complaint'); + }, + } + ); + }; + + if (!open) return null; + + return ( + + + + Raise Complaint + + + + + + Describe the issue + + + setComplaintImages(prev => prev.filter(img => img.uri !== uri))} + /> + + + {raiseComplaintMutation.isPending ? ( + + ) : ( + Submit Complaint + )} + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/components/CustomHeader.tsx b/apps/user-ui/components/CustomHeader.tsx new file mode 100644 index 0000000..1853bc7 --- /dev/null +++ b/apps/user-ui/components/CustomHeader.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import { View } from 'react-native'; +import { useRouter } from 'expo-router'; +import { tw, theme, MyTouchableOpacity } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +const CustomHeader = () => { + const router = useRouter(); + + return ( + + router.back()} + style={{ + width: 40, + height: 40, + borderRadius: 20, + backgroundColor: theme.colors.gray2, + justifyContent: 'center', + alignItems: 'center', + }} + > + + + + router.push('/(drawer)/(tabs)/home/cart')} + style={{ + width: 40, + height: 40, + borderRadius: 20, + backgroundColor: theme.colors.gray2, + justifyContent: 'center', + alignItems: 'center', + marginRight: 8, + }} + > + + + router.push('/(drawer)/(tabs)/me')} + style={{ + width: 40, + height: 40, + borderRadius: 20, + backgroundColor: theme.colors.gray2, + justifyContent: 'center', + alignItems: 'center', + }} + > + + + + + ); +}; + +export default CustomHeader; \ No newline at end of file diff --git a/apps/user-ui/components/FirstUserWrapper.tsx b/apps/user-ui/components/FirstUserWrapper.tsx new file mode 100644 index 0000000..38ce3ec --- /dev/null +++ b/apps/user-ui/components/FirstUserWrapper.tsx @@ -0,0 +1,43 @@ +import React, { useState, useEffect } from 'react' +import { View } from 'react-native' +import { MyButton, StorageServiceCasual, tw, MyText } from 'common-ui' + +interface Props { + children: React.ReactNode +} + +const FirstUserWrapper: React.FC = ({ children }) => { + const [isFirstTime, setIsFirstTime] = useState(null) + + useEffect(() => { + const checkFirstTime = async () => { + const value = await StorageServiceCasual.getItem('isFirstTimeUser') + setIsFirstTime(value !== 'false') + } + checkFirstTime() + }, []) + + const handleNext = async () => { + await StorageServiceCasual.setItem('isFirstTimeUser', 'false') + setIsFirstTime(false) + } + + if (isFirstTime === null) { + return null + } + + if (isFirstTime) { + return ( + + Hello Happy Shopping + + + + + ) + } + + return <>{children} +} + +export default FirstUserWrapper \ No newline at end of file diff --git a/apps/user-ui/components/FlashDeliveryNote.tsx b/apps/user-ui/components/FlashDeliveryNote.tsx new file mode 100644 index 0000000..0f36f17 --- /dev/null +++ b/apps/user-ui/components/FlashDeliveryNote.tsx @@ -0,0 +1,69 @@ +import React, { useState, useEffect } from "react"; +import { View } from "react-native"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { tw, MyText, MyTouchableOpacity } from "common-ui"; + +interface FlashDeliveryNoteProps { + onClose?: () => void; + autoHide?: boolean; + autoHideDelay?: number; +} + +const FlashDeliveryNote: React.FC = ({ + onClose, + autoHide = true, + autoHideDelay = 10000, // 10 seconds +}) => { + const [isVisible, setIsVisible] = useState(true); + + useEffect(() => { + if (!autoHide || !isVisible) return; + + const timer = setTimeout(() => { + setIsVisible(false); + }, autoHideDelay); + + return () => clearTimeout(timer); + }, [autoHide, autoHideDelay, isVisible]); + + const handleDismiss = () => { + setIsVisible(false); + onClose?.(); + }; + + if (!isVisible) return null; + + return ( + + + + + + + + + + Flash Delivery Notice + + + Prices may differ for Flash Delivery and not all products are available for flash delivery + + + + + + + + + + + ); +}; + +export default FlashDeliveryNote; \ No newline at end of file diff --git a/apps/user-ui/components/HealthTestWrapper.tsx b/apps/user-ui/components/HealthTestWrapper.tsx new file mode 100644 index 0000000..82f435b --- /dev/null +++ b/apps/user-ui/components/HealthTestWrapper.tsx @@ -0,0 +1,114 @@ +import React, { useState, useEffect } from 'react'; +import { View, ActivityIndicator } from 'react-native'; +import { tw, theme, MyText, MyTouchableOpacity , BottomDialog } from 'common-ui'; +import { trpc, trpcClient } from '@/src/trpc-client'; +import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'; +import Constants from 'expo-constants'; +import * as Linking from 'expo-linking'; + +interface HealthTestWrapperProps { + children: React.ReactNode; +} + +const HealthTestWrapper: React.FC = ({ children }) => { + const { data, isLoading, error, refetch } = trpc.common.healthCheck.useQuery(); + const { data: backendConsts } = useGetEssentialConsts(); + + const versionFromBackend = backendConsts?.versionNum; + const appUrl = backendConsts?.playStoreUrl; + + const [showUpdateDialog, setShowUpdateDialog] = useState(false); + + // Version comparison logic + useEffect(() => { + const version = Constants.expoConfig?.version; + if (!version || !versionFromBackend) return; + + // Parse local version + const versionParts = version.split('.'); + const versionNum1 = parseInt(versionParts[0]); + const versionNum2 = parseInt(versionParts[1]); + const versionNum3 = parseInt(versionParts[2]); + + if (isNaN(versionNum1) || isNaN(versionNum2) || isNaN(versionNum3)) return; + + // Parse backend version + const backendVersionParts = versionFromBackend.split('.'); + const backendVersionNum1 = parseInt(backendVersionParts[0]); + const backendVersionNum2 = parseInt(backendVersionParts[1]); + const backendVersionNum3 = parseInt(backendVersionParts[2]); + + if (isNaN(backendVersionNum1) || isNaN(backendVersionNum2) || isNaN(backendVersionNum3)) return; + + // Compare versions + const needsUpdate = versionNum1 < backendVersionNum1 || + (versionNum1 === backendVersionNum1 && versionNum2 < backendVersionNum2); + + if (needsUpdate) { + setShowUpdateDialog(true); + } + }, [versionFromBackend]); + + // Log app version + console.log('App Version:', Constants.expoConfig?.version); + console.log('Backend Version:', versionFromBackend); + if (isLoading) { + return ( + + + Checking service status... + + ); + } + + if (error || data?.status !== "ok") { + return ( + + + ⚠️ + + Service Unavailable + + Please check your connection and try again. + + refetch()} + style={tw`bg-brand500 px-8 py-3 rounded-xl shadow-md`} + activeOpacity={0.8} + > + Retry + + + ); + } + + return ( + <> + {children} + {showUpdateDialog && appUrl && ( + setShowUpdateDialog(false)} enableDismiss={false}> + + + Update Available + + + A new version ({versionFromBackend}) is available. Your current version is {Constants.expoConfig?.version}. Please update to continue using the app. + + { + if (appUrl) { + Linking.openURL(appUrl); + } + }} + style={{ backgroundColor: theme.colors.brand500, padding: 12, borderRadius: 8, alignItems: 'center' }} + > + Update Now + + + + )} + + ); +}; + +export default HealthTestWrapper; \ No newline at end of file diff --git a/apps/user-ui/components/LocationTestWrapper.tsx b/apps/user-ui/components/LocationTestWrapper.tsx new file mode 100644 index 0000000..e16ae82 --- /dev/null +++ b/apps/user-ui/components/LocationTestWrapper.tsx @@ -0,0 +1,110 @@ +import React, { useState, useEffect, ReactNode } from 'react'; +import * as Location from 'expo-location'; +import { BackHandler, Platform } from 'react-native'; +import { ConfirmationDialog } from 'common-ui'; +import { trpc } from '../src/trpc-client'; + +// Emulator detection utility +const isEmulator = (): boolean => { + try { + // Check for common emulator indicators + const brand = (Platform.constants as any)?.Brand?.toLowerCase(); + const model = (Platform.constants as any)?.Model?.toLowerCase(); + const manufacturer = (Platform.constants as any)?.Manufacturer?.toLowerCase(); + + // Android emulator detection + if (Platform.OS === 'android') { + return ( + brand?.includes('generic') || + brand?.includes('unknown') || + model?.includes('emulator') || + model?.includes('sdk') || + model?.includes('android sdk') || + manufacturer?.includes('genymotion') || + manufacturer?.includes('unknown') + ); + } + + // iOS simulator detection + if (Platform.OS === 'ios') { + return ( + (Platform.constants as any)?.systemName?.includes('Simulator') || + !(Platform.constants as any)?.isDevice || // iOS simulator + false + ); + } + + return false; + } catch (error) { + // If detection fails, assume it's a real device to be safe + console.warn('Emulator detection failed:', error); + return false; + } +}; + +interface LocationTestWrapperProps { + children: ReactNode; +} + +const LocationTestWrapper: React.FC = ({ children }) => { + // Skip location checks entirely for emulators + if (isEmulator()) { + return <>{children}; + } + + // Enable location functionality for real devices + const [locationDialogOpen, setLocationDialogOpen] = useState(false); + const [locationErrorDialogOpen, setLocationErrorDialogOpen] = useState(false); + const [userLocation, setUserLocation] = useState(null); + + const { data: locationCheck } = trpc.common.checkLocationInPolygon.useQuery( + { lat: userLocation?.coords.latitude || 0, lng: userLocation?.coords.longitude || 0 }, + { enabled: !!userLocation } + ); + + useEffect(() => { + if (locationCheck && !locationCheck.isInside) { + setLocationErrorDialogOpen(true); + } + }, [locationCheck]); + + useEffect(() => { + (async () => { + const { status } = await Location.requestForegroundPermissionsAsync(); + if (status === 'granted') { + const location = await Location.getCurrentPositionAsync({}); + console.log('User location:', location.coords); + setUserLocation(location); + } else { + setLocationDialogOpen(true); + } + })(); + }, []); + + + return ( + <> + {children} + setLocationDialogOpen(false)} + negativeAction={() => BackHandler.exitApp()} + /> + setLocationErrorDialogOpen(false)} + negativeAction={() => BackHandler.exitApp()} + /> + + ); +}; + +export default LocationTestWrapper; \ No newline at end of file diff --git a/apps/user-ui/components/NextOrderGlimpse.tsx b/apps/user-ui/components/NextOrderGlimpse.tsx new file mode 100644 index 0000000..cae820d --- /dev/null +++ b/apps/user-ui/components/NextOrderGlimpse.tsx @@ -0,0 +1,173 @@ +import React from 'react'; +import { View, TouchableOpacity, ActivityIndicator } from 'react-native'; +import { useRouter } from 'expo-router'; +import { tw, MyText } from 'common-ui'; +import { MaterialIcons, Ionicons } from '@expo/vector-icons'; +import dayjs from 'dayjs'; +import { trpc } from '@/src/trpc-client'; +import { Image } from 'expo-image'; + +interface OrderItem { + productName: string; + quantity: number; + price: number; + amount: number; + image: string | null; +} + +interface Order { + id: number; + orderId: string; + orderDate: string; + deliveryStatus: string; + deliveryDate?: string; + orderStatus: string; + cancelReason: string | null; + totalAmount: number; + deliveryCharge: number; + paymentMode: string; + paymentStatus: string; + refundStatus: string; + refundAmount: number | null; + userNotes: string | null; + items: OrderItem[]; + discountAmount?: number; + isFlashDelivery: boolean; + createdAt: string; +} + +export default function NextOrderGlimpse() { + const router = useRouter(); + + const { data: ordersData, isLoading: ordersLoading } = trpc.user.order.getOrders.useQuery({ + page: 1, + pageSize: 50, + }); + + const allOrders: Order[] = ordersData?.data || []; + + const now = dayjs(); + + const upcomingOrders = allOrders.filter(order => { + if (order.orderStatus.toLowerCase() === 'cancelled') return false; + if (order.deliveryStatus.toLowerCase() === 'success') return false; + + if (order.isFlashDelivery) { + return true; + } + + if (order.deliveryDate) { + return dayjs(order.deliveryDate).isAfter(now); + } + + return false; + }); + + upcomingOrders.sort((a, b) => { + if (a.isFlashDelivery && !b.isFlashDelivery) return -1; + if (!a.isFlashDelivery && b.isFlashDelivery) return 1; + + if (a.isFlashDelivery && b.isFlashDelivery) { + return dayjs(b.createdAt).diff(dayjs(a.createdAt)); + } + + if (a.deliveryDate && b.deliveryDate) { + return dayjs(a.deliveryDate).diff(dayjs(b.deliveryDate)); + } + + return 0; + }); + + const nextOrder = upcomingOrders[0] || null; + + if (ordersLoading) { + return ( + + + + + + ); + } + + if (!nextOrder) { + return null; + } + + return ( + router.push(`/(drawer)/(tabs)/me/my-orders/${nextOrder.id}`)} + > + + + + + Upcoming Order + + {nextOrder.isFlashDelivery && ( + + + FLASH + + )} + + + + + #{nextOrder.orderId} + + {nextOrder.items.length} {nextOrder.items.length === 1 ? 'item' : 'items'} • ₹{nextOrder.totalAmount} + + + + {nextOrder.deliveryStatus} + + + + + + + {nextOrder.isFlashDelivery + ? "30-Min Delivery" + : dayjs(nextOrder.deliveryDate).format("DD MMM, hh:mm A") + } + + + + {nextOrder.items.length > 0 && ( + + + {nextOrder.items.slice(0, 3).map((item, idx) => ( + 0 ? -8 : 0 } + ]} + > + + + ))} + {nextOrder.items.length > 3 && ( + + +{nextOrder.items.length - 3} + + )} + + Track Order + + + )} + + + ); +} diff --git a/apps/user-ui/components/OrderMenu.tsx b/apps/user-ui/components/OrderMenu.tsx new file mode 100644 index 0000000..88a0e80 --- /dev/null +++ b/apps/user-ui/components/OrderMenu.tsx @@ -0,0 +1,228 @@ +import React, { useState } from 'react'; +import { View, Alert, KeyboardAvoidingView, Platform, TextInput, ActivityIndicator } from 'react-native'; +import { MaterialIcons, Ionicons } from '@expo/vector-icons'; +import { tw, MyText, MyTouchableOpacity, BottomDialog } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import ComplaintForm from '@/components/ComplaintForm'; + +interface OrderMenuProps { + orderId: string; + postActionHandler?: () => void; +} + +const OrderMenu: React.FC = ({ orderId, postActionHandler }) => { + const [open, setOpen] = useState(false); + const [editNotesDialogOpen, setEditNotesDialogOpen] = useState(false); + const [editNotes, setEditNotes] = useState(''); + const [complaintDialogOpen, setComplaintDialogOpen] = useState(false); + const [cancelDialogOpen, setCancelDialogOpen] = useState(false); + const [cancelReason, setCancelReason] = useState(''); + + const cancelOrderMutation = trpc.user.order.cancelOrder.useMutation(); + const updateNotesMutation = trpc.user.order.updateUserNotes.useMutation({ + onSuccess: () => { + Alert.alert('Success', 'Notes updated successfully'); + setEditNotesDialogOpen(false); + setEditNotes(''); + postActionHandler?.(); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to update notes'); + }, + }); + + const handleEditNotes = async () => { + try { + await updateNotesMutation.mutateAsync({ + id: orderId, + userNotes: editNotes.trim() + }); + } catch (error) { + // Error handled in mutation + } + }; + + const handleCancelOrder = async () => { + if (!cancelReason.trim()) { + Alert.alert('Error', 'Please enter a reason for cancellation'); + return; + } + try { + await cancelOrderMutation.mutateAsync({ id: orderId, reason: cancelReason }); + Alert.alert('Success', 'Order cancelled successfully'); + setCancelDialogOpen(false); + setCancelReason(''); + postActionHandler?.(); + } catch (error: any) { + Alert.alert('Error', error.message || 'Failed to cancel order'); + } + }; + + const handleComplaintClose = () => { + setComplaintDialogOpen(false); + postActionHandler?.(); + }; + + return ( + <> + {/* Menu Trigger */} + setOpen(true)} + > + + + + {/* Menu Dialog */} + setOpen(false)}> + + {/* Handle */} + + + Order Options + Select an action for Order #{orderId} + + + + { + setEditNotes(''); + setEditNotesDialogOpen(true); + }} + > + + + + + Edit Notes + Add special instructions + + + + + setComplaintDialogOpen(true)} + > + + + + + Raise Complaint + Report an issue with this order + + + + + setCancelDialogOpen(true)} + > + + + + + Cancel Order + Request order cancellation + + + + + + + + {/* Edit Notes Dialog */} + setEditNotesDialogOpen(false)}> + + + + Edit Instructions + setEditNotesDialogOpen(false)}> + + + + + + + + {updateNotesMutation.isPending ? ( + + ) : ( + Save Instructions + )} + + + + + + {/* Cancel Order Dialog */} + setCancelDialogOpen(false)}> + + + + Cancel Order + setCancelDialogOpen(false)}> + + + + + + + Are you sure you want to cancel this order? This action cannot be undone. + + + + Reason for cancellation + + + + {cancelOrderMutation.isPending ? ( + + ) : ( + Confirm Cancellation + )} + + + + + + {/* Raise Complaint Dialog */} + + + + + ); +}; + +export default OrderMenu; \ No newline at end of file diff --git a/apps/user-ui/components/PaymentAndOrderComponent.tsx b/apps/user-ui/components/PaymentAndOrderComponent.tsx new file mode 100644 index 0000000..bf7b0a1 --- /dev/null +++ b/apps/user-ui/components/PaymentAndOrderComponent.tsx @@ -0,0 +1,394 @@ +import React, { useState, useMemo } from 'react'; +import { View, Alert, Platform } from 'react-native'; +import { useRouter } from 'expo-router'; +import { tw, MyTextInput, LoadingDialog, MyText, MyTouchableOpacity } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +// import RazorpayCheckout from 'react-native-razorpay'; + +import { trpc } from '@/src/trpc-client'; +import { clearLocalCart } from '@/hooks/cart-query-hooks'; +import { useQueryClient } from '@tanstack/react-query'; +import { FontAwesome5, FontAwesome6 } from '@expo/vector-icons'; + +interface PaymentAndOrderProps { + selectedAddress: number | null; + selectedSlots: Record; + selectedCouponId: number | null; + cartItems: any[]; + totalPrice: number; + discountAmount: number; + finalTotal: number; + finalTotalWithDelivery: number; + deliveryCharge: number; + constsData?: any; + selectedCoupons: any[]; + isFlashDelivery?: boolean; + onCancel?: () => void; +} + +const PaymentAndOrderComponent: React.FC = ({ + selectedAddress, + selectedSlots, + selectedCouponId, + cartItems, + totalPrice, + discountAmount, + finalTotal, + finalTotalWithDelivery, + deliveryCharge, + constsData, + selectedCoupons, + isFlashDelivery = false, + onCancel, +}) => { + + const router = useRouter(); + const queryClient = useQueryClient(); + const [userNotes, setUserNotes] = useState(''); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); + const [paymentMethod, setPaymentMethod] = useState<'online' | 'cod'>('cod'); + + // Helper function to clear cart and invalidate queries + const clearCartAndInvalidateQueries = async (cartType: 'regular' | 'flash' = 'regular') => { + await clearLocalCart(cartType); + queryClient.invalidateQueries({ queryKey: [`local-cart-${cartType}`] }); + }; + + const { data: productsData } = trpc.user.product.getAllProductsSummary.useQuery(); + + // Memoized flash-eligible product IDs + const flashEligibleProductIds = useMemo(() => { + if (!productsData) return new Set(); + return new Set( + productsData + .filter((product: any) => product.isFlashAvailable) + .map((product: any) => product.id) + ); + }, [productsData]); + + const placeOrderMutation = trpc.user.order.placeOrder.useMutation({ + onSuccess: (data) => { + const orders = data.data; // Now an array of orders + const firstOrder = orders[0]; // Use first order for payment flow + + if (!firstOrder.isCod) { + // createRazorpayOrderMutation.mutate({ orderId: firstOrder.id.toString() }); + } else { + // Clear cart and navigate to success page + clearCartAndInvalidateQueries(isFlashDelivery ? 'flash' : 'regular'); + const successPath = isFlashDelivery + ? '/(drawer)/(tabs)/flash-delivery/order-success' + : './order-success'; + router.replace(`${successPath}?orderId=${firstOrder.id}&totalAmount=${finalTotalWithDelivery}`); + } + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Failed to place order'); + }, + onSettled: () => { + setIsLoadingDialogOpen(false); + }, + }); + + // const createRazorpayOrderMutation = trpc.user.payment.createRazorpayOrder.useMutation({ + // onSuccess: (paymentData) => { + // initiateRazorpayPayment(paymentData.razorpayOrderId, paymentData.key, finalTotal); + // }, + // onError: (error: any) => { + // Alert.alert('Error', error.message || 'Failed to create payment order'); + // }, + // }); + + const verifyPaymentMutation = trpc.user.payment.verifyPayment.useMutation({ + onSuccess: () => { + const orders = placeOrderMutation.data?.data || []; + const firstOrder = orders[0]; + // Clear cart and navigate to success page + clearCartAndInvalidateQueries(isFlashDelivery ? 'flash' : 'regular'); + const successPath = isFlashDelivery + ? '/(drawer)/(tabs)/flash-delivery/order-success' + : './order-success'; + router.replace(`${successPath}?orderId=${firstOrder?.id}&totalAmount=${finalTotalWithDelivery}`); + }, + onError: (error: any) => { + Alert.alert('Error', error.message || 'Payment verification failed'); + }, + }); + + const markPaymentFailedMutation = trpc.user.payment.markPaymentFailed.useMutation(); + + + const handlePlaceOrder = () => { + if (!selectedAddress) { + Alert.alert('Error', 'Please select an address'); + return; + } + + const availableItems = cartItems + .filter(item => { + if (item.product?.isOutOfStock) return false; + // For flash delivery, check if product supports flash delivery + if (isFlashDelivery) { + return flashEligibleProductIds.has(item.productId); + } + // For regular delivery, only include items with assigned slots + return selectedSlots[item.id]; + }) + .map(item => item.id); + + if (availableItems.length === 0) { + Alert.alert('Error', 'No valid items to order'); + return; + } + + setIsLoadingDialogOpen(true); + + + const orderData = { + selectedItems: availableItems.map(itemId => { + const item = cartItems.find(cartItem => cartItem.id === itemId); + return { + productId: item.productId, + quantity: item.quantity, + slotId: isFlashDelivery ? null : selectedSlots[itemId] + }; + }), + addressId: selectedAddress, + paymentMethod: paymentMethod, + couponId: selectedCouponId || undefined, + userNotes: userNotes, + isFlashDelivery: isFlashDelivery, + }; + + console.log({orderData}) + + placeOrderMutation.mutate(orderData); + }; + + // const initiateRazorpayPayment = (razorpayOrderId: string, key: string, amount: number) => { + // const options = { + // key, + // amount: amount * 100, + // currency: 'INR', + // order_id: razorpayOrderId, + // name: 'Meat Farmer', + // description: 'Order Payment', + // prefill: {}, + // }; + + // RazorpayCheckout.open(options) + // .then((data: any) => { + // verifyPaymentMutation.mutate({ + // razorpay_payment_id: data.razorpay_payment_id, + // razorpay_order_id: data.razorpay_order_id, + // razorpay_signature: data.razorpay_signature, + // }); + // }) + // .catch((error: any) => { + // markPaymentFailedMutation.mutate({ merchantOrderId: razorpayOrderId }); + // Alert.alert( + // 'Payment Failed', + // 'Payment failed or was cancelled. What would you like to do?', + // [ + // { + // text: 'Retry Now', + // onPress: () => { + // const orders = placeOrderMutation.data?.data || []; + // const firstOrder = orders[0]; + // const orderId = firstOrder?.id.toString(); + // if (orderId) { + // createRazorpayOrderMutation.mutate({ orderId }); + // } + // } + // }, + // { + // text: 'Retry Later', + // onPress: () => router.push('/(drawer)/(tabs)/me/my-orders') + // } + // ] + // ); + // }); + // }; + + return ( + <> + {/* Back Button */} + {onCancel && ( + + + + Back to Cart + + + )} + + {/* Special Instructions */} + + Delivery Instructions + + + + {/* Payment Method */} + + Payment Method + + + + {/* No selection dot for disabled state */} + + + + + + Pay Online (Coming Soon) + UPI, Cards, Netbanking + + + + setPaymentMethod('cod')} + style={tw`flex-row items-center p-4 rounded-xl border ${paymentMethod === 'cod' ? 'border-brand500 bg-blue-50' : 'border-gray-200'}`} + > + + {paymentMethod === 'cod' && } + + + + + + Cash on Delivery + Pay when you receive + + + + + + + UPI accepted during COD + + + + Cash payment + + + + + {/* Bill Details */} + + Bill Details + + {/* Item Total */} + + Item Total + ₹{totalPrice} + + + {/* Discount */} + {discountAmount > 0 && ( + + Product Discount + -₹{discountAmount} + + )} + + {/* Delivery Fee */} + + + Delivery Fee + + + + {deliveryCharge === 0 && ( + isFlashDelivery + ? (constsData?.flashDeliveryCharge > 0 && ( + + ₹{constsData?.flashDeliveryCharge} + + )) + : (constsData?.deliveryCharge > 0 && ( + + ₹{constsData?.deliveryCharge} + + )) + )} + + {deliveryCharge === 0 ? 'Free' : `₹${deliveryCharge}`} + + + + + {/* Free Delivery Nudge */} + {deliveryCharge > 0 && (() => { + const threshold = isFlashDelivery + ? constsData?.flashFreeDeliveryThreshold + : constsData?.freeDeliveryThreshold; + return threshold > 0 && finalTotal < threshold && ( + + + + Add products worth ₹{(threshold - finalTotal).toFixed(0)} for free delivery + + + ); + })()} + + {/* Divider */} + + + {/* Grand Total */} + + To Pay + ₹{finalTotalWithDelivery} + + + {/* Savings Banner */} + {(discountAmount > 0 || deliveryCharge === 0) && ( + + + + You saved ₹{discountAmount + (deliveryCharge === 0 ? ( + isFlashDelivery + ? constsData?.flashDeliveryCharge + : constsData?.deliveryCharge + ) : 0)} on this order + + + )} + + + {/* Bottom Action Bar */} + + + + Place Order + + + + + + + ); +}; + +export default PaymentAndOrderComponent; \ No newline at end of file diff --git a/apps/user-ui/components/ProductCard.tsx b/apps/user-ui/components/ProductCard.tsx new file mode 100644 index 0000000..3315bbd --- /dev/null +++ b/apps/user-ui/components/ProductCard.tsx @@ -0,0 +1,174 @@ +import React from 'react'; +import { View, Alert, TouchableOpacity, Text } from 'react-native'; +import { Image } from 'expo-image'; +import { tw, theme, MyText, MyTouchableOpacity, Quantifier, MiniQuantifier } from 'common-ui'; +import CartIcon from '@/components/icons/CartIcon'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import Ionicons from '@expo/vector-icons/Ionicons'; +import dayjs from 'dayjs'; +import { + useGetCart, + useUpdateCartItem, + useRemoveFromCart, + useAddToCart, +} from '@/hooks/cart-query-hooks'; +import { useProductSlotIdentifier } from '@/hooks/useProductSlotIdentifier'; + + +interface ProductCardProps { + item: any; + itemWidth: number; + onPress?: () => void; + showDeliveryInfo?: boolean; + miniView?: boolean; +} + +const formatQuantity = (quantity: number, unit: string): { value: string; display: string } => { + if (unit?.toLowerCase() === 'kg' && quantity < 1) { + return { value: `${Math.round(quantity * 1000)} g`, display: `${Math.round(quantity * 1000)}g` }; + } + return { value: `${quantity} ${unit}(s)`, display: `${quantity}${unit}` }; +}; + +const ProductCard: React.FC = ({ + item, + itemWidth, + onPress, + showDeliveryInfo = true, + miniView = false, +}) => { + const { data: cartData } = useGetCart(); + const { getQuickestSlot } = useProductSlotIdentifier(); + const updateCartItem = useUpdateCartItem({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }); + const removeFromCart = useRemoveFromCart({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }); + const { addToCart = () => {} } = useAddToCart({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }) || {}; + + // Find current quantity from cart data + const cartItem = cartData?.items?.find((cartItem: any) => cartItem.productId === item.id); + const quantity = cartItem?.quantity || 0; + + // Precompute the next slot and determine display out of stock status + const slotId = getQuickestSlot(item.id); + const displayIsOutOfStock = item.isOutOfStock || !slotId; + + const handleQuantityChange = (newQuantity: number) => { + if (newQuantity === 0 && cartItem) { + removeFromCart.mutate({ itemId: cartItem.id }); + } else if (newQuantity === 1 && !cartItem) { + const slotId = getQuickestSlot(item.id); + if (!slotId) { + Alert.alert("Error", "No available delivery slot for this product"); + return; + } + addToCart(item.id, 1, slotId, () => {}); + } else if (cartItem) { + updateCartItem.mutate({ itemId: cartItem.id, quantity: newQuantity }); + } + }; + + return ( + {/* TODO: Navigate to product detail */})} + activeOpacity={0.9} + > + + + {displayIsOutOfStock && ( + + + Out of Stock + + + )} + {miniView && ( + + {quantity > 0 ? ( + + ) : ( + handleQuantityChange(1)} + activeOpacity={0.8} + > + + + )} + + )} + + + + + {item.name} + + + + ₹{item.price} + {item.marketPrice && Number(item.marketPrice) > Number(item.price) && ( + ₹{item.marketPrice} + )} + + + Quantity: {formatQuantity(item.productQuantity || 1, item.unit).display} + + + {showDeliveryInfo && item.nextDeliveryDate && ( + + + + {dayjs(item.nextDeliveryDate).format("ddd, DD MMM • h:mm A")} + + + )} + + {!miniView && ( + <> + {displayIsOutOfStock ? ( + + Unavailable + + ) : quantity > 0 ? ( + + ) : ( + handleQuantityChange(1)} + > + + + Add to Cart + + + )} + + )} + + + ); +}; + +export default ProductCard; \ No newline at end of file diff --git a/apps/user-ui/components/ProductDetail.tsx b/apps/user-ui/components/ProductDetail.tsx new file mode 100644 index 0000000..6b86149 --- /dev/null +++ b/apps/user-ui/components/ProductDetail.tsx @@ -0,0 +1,760 @@ +import React, { useState, useMemo } from 'react'; +import { View, ScrollView, Alert, Dimensions, FlatList, RefreshControl } from 'react-native'; +import { useRouter } from 'expo-router'; +import { ImageCarousel, tw, BottomDialog, useManualRefresh, useMarkDataFetchers, LoadingDialog, ImageUploader, MyText, MyTextInput, MyTouchableOpacity, Quantifier } from 'common-ui'; +import { LinearGradient } from 'expo-linear-gradient'; +import usePickImage from 'common-ui/src/components/use-pick-image'; +import { theme } from 'common-ui/src/theme'; +import dayjs from 'dayjs'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import FontAwesome5 from '@expo/vector-icons/FontAwesome5'; +import { trpc, trpcClient } from '@/src/trpc-client'; +import { useAddToCart, useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-hooks'; +import { useProductSlotIdentifier } from '@/hooks/useProductSlotIdentifier'; +import { useFlashNavigationStore } from '@/components/stores/flashNavigationStore'; +import FloatingCartBar from './floating-cart-bar'; + +const { width: screenWidth } = Dimensions.get("window"); +const carouselWidth = screenWidth; +const carouselHeight = carouselWidth * 0.8; + +const extractKeyFromUrl = (url: string): string => { + const u = new URL(url); + const rawKey = u.pathname.replace(/^\/+/, ""); + return decodeURIComponent(rawKey); +}; + +interface ProductDetailProps { + productId: string; + isFlashDelivery?: boolean; +} + +const ProductDetail: React.FC = ({ productId, isFlashDelivery = false }) => { + const router = useRouter(); + const [showAllSlots, setShowAllSlots] = useState(false); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = useState(false); + const [reviews, setReviews] = useState([]); + const [reviewsLoading, setReviewsLoading] = useState(false); + const [hasMore, setHasMore] = useState(true); + const [reviewsOffset, setReviewsOffset] = useState(0); + const [refreshing, setRefreshing] = useState(false); + const { data: productDetail, isLoading, error, refetch } = trpc.user.product.getProductDetails.useQuery({ id: productId }); + const cartType: "regular" | "flash" = isFlashDelivery ? "flash" : "regular"; + const { addToCart = () => {} } = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType) || {}; + const { addToCart:addTOFlashCart = () => {} } = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, 'flash') || {}; + const cartData = useGetCart({}, cartType); + const updateCartItem = useUpdateCartItem({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType); + const removeFromCart = useRemoveFromCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType); + const { getQuickestSlot } = useProductSlotIdentifier(); + const { setShouldNavigateToCart } = useFlashNavigationStore(); + + // Find current quantity from cart data + const cartItem = productDetail ? cartData?.data?.items?.find((item: any) => item.productId === productDetail.id) : null; + const quantity = cartItem?.quantity || 0; + + const handleQuantityChange = (newQuantity: number) => { + if (!productDetail) return; + + if (newQuantity === 0 && cartItem) { + removeFromCart.mutate({ itemId: cartItem.id }); + } else if (newQuantity === 1 && !cartItem) { + handleAddToCart(productDetail.id); + } else if (cartItem) { + updateCartItem.mutate({ itemId: cartItem.id, quantity: newQuantity }); + } + }; + + + useManualRefresh(() => { + refetch(); + }); + + useMarkDataFetchers(() => { + refetch(); + }); + + const handleAddToCart = (productId: number) => { + if (isFlashDelivery) { + if (!productDetail?.isFlashAvailable) { + Alert.alert("Error", "This product is not available for flash delivery"); + return; + } + setIsLoadingDialogOpen(true); + addToCart(productId, 1, 0, () => setIsLoadingDialogOpen(false)); + } else { + const slotId = getQuickestSlot(productId); + if (!slotId) { + Alert.alert("Error", "No available delivery slot for this product"); + return; + } + setIsLoadingDialogOpen(true); + addToCart(productId, 1, slotId, () => setIsLoadingDialogOpen(false)); + } + }; + + const handleBuyNow = (productId: number) => { + if (isFlashDelivery) { + if (!productDetail?.isFlashAvailable) { + Alert.alert("Error", "This product is not available for flash delivery"); + return; + } + setIsLoadingDialogOpen(true); + addToCart(productId, 1, 0, () => setIsLoadingDialogOpen(false)); + router.push(`/(drawer)/(tabs)/flash-delivery/(cart)/cart?select=${productId}`); + } else { + addTOFlashCart(productId, 1, 0); + setShouldNavigateToCart(true); + router.push('/(drawer)/(tabs)/flash-delivery'); + } + }; + + const handleSlotAddToCart = (productId: number, selectedSlotId: number) => { + const cartItem = cartData.data?.items?.find((item: any) => item.productId === productId); + setIsLoadingDialogOpen(true); + if (cartItem) { + removeFromCart.mutate( + { itemId: cartItem.id }, + { + onSuccess: () => { + addToCart(productId, cartItem.quantity + 1, selectedSlotId, () => setIsLoadingDialogOpen(false)); + }, + onError: () => setIsLoadingDialogOpen(false), + } + ); + } else { + addToCart(productId, 1, selectedSlotId, () => setIsLoadingDialogOpen(false)); + } + }; + + const discountPercentage = productDetail?.marketPrice + ? Math.round(((Number(productDetail.marketPrice) - Number(productDetail.price)) / Number(productDetail.marketPrice)) * 100) + : 0; + + const loadReviews = async (reset = false) => { + if (reviewsLoading || (!hasMore && !reset)) return; + setReviewsLoading(true); + try { + const { reviews: newReviews, hasMore: newHasMore } = await trpcClient.user.product.getProductReviews.query({ + productId: Number(productId), + limit: 10, + offset: reset ? 0 : reviewsOffset, + }); + setReviews(reset ? newReviews : [...reviews, ...newReviews]); + setHasMore(newHasMore); + setReviewsOffset(reset ? 10 : reviewsOffset + 10); + } catch (error) { + console.error('Error loading reviews:', error); + } finally { + setReviewsLoading(false); + } + }; + + const onRefresh = async () => { + setRefreshing(true); + await refetch(); // Refetch product details + await loadReviews(true); // Reset and reload reviews + setRefreshing(false); + }; + + const handleReviewSubmitted = () => { + loadReviews(true); + }; + + React.useEffect(() => { + if (productDetail?.id) { + loadReviews(true); + } + }, [productDetail?.id]); + + if (isLoading) { + return ( + + Loading product details... + + ); + } + + if (error || !productDetail) { + return ( + + + Oops! + Product not found or error loading + + ); + } + + + return ( + + {/* */} + + + } + > + {/* Image Carousel */} + + + + + {/* Product Info */} + + + + {productDetail.name} + + {productDetail.isFlashAvailable && ( + + + Flash Delivery + + )} + {productDetail.isOutOfStock && ( + + Out of Stock + + )} + + + + {productDetail.shortDescription} + + + {/* Main price display - always show regular price prominently */} + + + ₹{productDetail.price} + + / {productDetail.unit} + + {/* Show market price discount if available */} + {productDetail.marketPrice && ( + + ₹{productDetail.marketPrice} + + {discountPercentage}% OFF + + + )} + + + {/* Flash price on separate line - smaller and less prominent */} + {productDetail.isFlashAvailable && productDetail.flashPrice && productDetail.flashPrice !== productDetail.price && ( + + + Flash Delivery: ₹{productDetail.flashPrice} / {productDetail.unit} + + + )} + + + + + {/* Action Buttons */} + + {quantity > 0 ? ( + // Show quantifier when item is in cart + + + + ) : ( + // Show "Add to Cart" button when not in cart + !(productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) && handleAddToCart(productDetail.id)} + disabled={productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)} + > + + {(productDetail.isOutOfStock || (isFlashDelivery && !productDetail.isFlashAvailable)) ? 'Unavailable' : 'Add to Cart'} + + + )} + + {isFlashDelivery ? ( + !(productDetail.isOutOfStock || !productDetail.isFlashAvailable) && handleBuyNow(productDetail.id)} + disabled={productDetail.isOutOfStock || !productDetail.isFlashAvailable} + > + + {productDetail.isOutOfStock ? 'Out of Stock' : + (!productDetail.isFlashAvailable ? 'Not Flash Eligible' : 'Buy Now')} + + + ) : productDetail.isFlashAvailable ? ( + productDetail.deliverySlots.length > 0 && handleBuyNow(productDetail.id)} + disabled={productDetail.deliverySlots.length === 0} + > + + {productDetail.deliverySlots.length === 0 ? 'No Slots' : 'Buy Now'} + + + ) : ( + + )} + + + + + {/* Delivery Slots */} + + + + + + + Available Slots + + + {productDetail.deliverySlots.length === 0 ? ( + No delivery slots available currently + ) : ( + <> + {productDetail.deliverySlots.slice(0, 2).map((slot, index) => ( + handleSlotAddToCart(productDetail.id, slot.id)} + disabled={productDetail.isOutOfStock} + activeOpacity={0.7} + > + + + + {dayjs(slot.deliveryTime).format('ddd, DD MMM • h:mm A')} + + + Orders Close: {dayjs(slot.freezeTime).format('h:mm A')} + + + + + ))} + {productDetail.deliverySlots.length > 2 && ( + setShowAllSlots(true)} + style={tw`items-center py-2`} + > + View All {productDetail.deliverySlots.length} Slots + + )} + + )} + + + + + + {/* Description */} + + + About the Product + {!productDetail.longDescription ? ( + + No detailed description available. + + ) : ( + {productDetail.longDescription} + )} + + {productDetail.store && ( + + + + + + Sourced From + {productDetail.store.name} + + + )} + + + + {/* Package Deals */} + {productDetail.specialPackageDeals && productDetail.specialPackageDeals.length > 0 && ( + + + + + + + Bulk Savings + + + {productDetail.specialPackageDeals.map((deal, index) => ( + + Buy {deal.quantity} {productDetail.unit} + ₹{deal.price} + + ))} + + + )} + + {/* Reviews Section */} + + + {/* Review Form - Moved above or keep below? Usually users want to read reviews first, but if few reviews, writing is good. The original had form then reviews. I will keep format but make it nicer. */} + + + + + + + + Customer Reviews + What others are saying + + + + + + item.id.toString()} + renderItem={({ item }) => ( + + + {/* User Avatar Placeholder */} + + + {item.userName ? item.userName.charAt(0).toUpperCase() : 'U'} + + + + + + {item.userName} + {dayjs(item.reviewTime).format('MMM DD, YYYY')} + + + {[1, 2, 3, 4, 5].map((star) => ( + + ))} + + + + + {item.reviewBody} + + {item.signedImageUrls && item.signedImageUrls.length > 0 && ( + + + {/* Using ImageCarousel for simplicity if it handles list, but it seems to be a slideshow. + Original code used ImageCarousel. Let's make it more "gallery" like if possible or stick to carousel if it's robust. + Actually, a row of thumbnails is better for reviews. + But to avoid breaking changes if ImageCarousel is needed for signed URLs logic (headers etc), I will trust ImageCarousel or just map standard Images if standard urls. + The original code used ImageCarousel. I'll stick to it to ensure images load correctly. + */} + + + + + + )} + + {item.adminResponse && ( + + + + + + Seller Response + + {item.adminResponse} + {item.signedAdminImageUrls && item.signedAdminImageUrls.length > 0 && ( + + + + )} + + )} + + )} + onEndReached={() => loadReviews()} + onEndReachedThreshold={0.5} + ListEmptyComponent={ + + + + + No reviews yet. + Be the first to share your thoughts! + + } + ListFooterComponent={reviewsLoading ? Loading more reviews... : null} + scrollEnabled={false} + /> + + + + + + {/* All Slots Dialog */} + setShowAllSlots(false)}> + + + + + + All Delivery Slots + + + + {productDetail.deliverySlots.map((slot, index) => ( + handleSlotAddToCart(productDetail.id, slot.id)} + disabled={productDetail.isOutOfStock} + activeOpacity={0.7} + > + + + + {dayjs(slot.deliveryTime).format('ddd, DD MMM • h:mm A')} + + + Orders Close: {dayjs(slot.freezeTime).format('h:mm A')} + + + + + ))} + + + setShowAllSlots(false)} + > + Close + + + + + + + + + + + ); +}; + +interface ReviewFormProps { + productId: number; + onReviewSubmitted?: () => void; +} + +const ReviewForm = ({ productId, onReviewSubmitted }: ReviewFormProps) => { + const [reviewBody, setReviewBody] = useState(''); + const [ratings, setRatings] = useState(0); + const [selectedImages, setSelectedImages] = useState<{ blob: Blob; mimeType: string }[]>([]); + const [displayImages, setDisplayImages] = useState<{ uri?: string }[]>([]); + + + const createReview = trpc.user.product.createReview.useMutation(); + const generateUploadUrls = trpc.user.fileUpload.generateUploadUrls.useMutation(); + + const handleImagePick = usePickImage({ + setFile: async (assets: any) => { + if (!assets || (Array.isArray(assets) && assets.length === 0)) { + setSelectedImages([]); + setDisplayImages([]); + return; + } + + const files = Array.isArray(assets) ? assets : [assets]; + const blobPromises = files.map(async (asset) => { + const response = await fetch(asset.uri); + const blob = await response.blob(); + return { blob, mimeType: asset.mimeType || 'image/jpeg' }; + }); + + const blobArray = await Promise.all(blobPromises); + setSelectedImages(blobArray); + setDisplayImages(files.map(asset => ({ uri: asset.uri }))); + }, + multiple: true, + }); + + const handleRemoveImage = (uri: string) => { + const index = displayImages.findIndex(img => img.uri === uri); + if (index !== -1) { + const newDisplay = displayImages.filter((_, i) => i !== index); + const newFiles = selectedImages.filter((_, i) => i !== index); + + setDisplayImages(newDisplay); + setSelectedImages(newFiles); + + } + }; + + const handleSubmit = async () => { + if (!reviewBody.trim() || ratings === 0) { + Alert.alert('Error', 'Please provide a review and rating.'); + return; + } + + try { + // Generate upload URLs + const mimeTypes = selectedImages.map(s => s.mimeType); + const { uploadUrls: generatedUrls } = await generateUploadUrls.mutateAsync({ + contextString: 'review', + mimeTypes, + }); + const keys = generatedUrls.map(extractKeyFromUrl); + + // Upload images + for (let i = 0; i < generatedUrls.length; i++) { + const uploadUrl = generatedUrls[i]; + const key = keys[i]; + const { blob, mimeType } = selectedImages[i]; + + + const uploadResponse = await fetch(uploadUrl, { + method: 'PUT', + body: blob, + headers: { + 'Content-Type': mimeType, + }, + }); + + if (!uploadResponse.ok) { + throw new Error(`Upload failed with status ${uploadResponse.status}`); + } + } + + // Submit review with image URLs + await createReview.mutateAsync({ + productId, + reviewBody, + ratings, + imageUrls: keys, + uploadUrls: generatedUrls, + }); + + Alert.alert('Success', 'Review submitted!'); + onReviewSubmitted?.(); + // Reset form + setReviewBody(''); + setRatings(0); + setSelectedImages([]); + setDisplayImages([]); + } catch (error:any) { + + Alert.alert('Error', error.message || 'Failed to submit review.'); + } + }; + + return ( + + Rate this Product + Share your experience with others + + {/* Rating */} + + + {[1, 2, 3, 4, 5].map((star) => ( + setRatings(star)} activeOpacity={0.7}> + + + ))} + + + {ratings === 0 ? 'Tap to Rate' : ratings === 1 ? 'Poor' : ratings === 2 ? 'Fair' : ratings === 3 ? 'Good' : ratings === 4 ? 'Very Good' : 'Excellent'} + + + + {/* Review Text */} + + + + + {/* Images */} + + + + + {/* Submit */} + + + + {createReview.isPending ? 'Submitting...' : 'Submit Review'} + + + + + ); +}; + +export default ProductDetail; \ No newline at end of file diff --git a/apps/user-ui/components/ProfileChecker.tsx b/apps/user-ui/components/ProfileChecker.tsx new file mode 100644 index 0000000..c4ca3d7 --- /dev/null +++ b/apps/user-ui/components/ProfileChecker.tsx @@ -0,0 +1,49 @@ +import React from 'react'; +import { View } from 'react-native'; +import { BottomDialog, MyText, MyButton, useIsDevMode } from 'common-ui'; +import { trpc } from '../src/trpc-client'; +import { useRouter } from 'expo-router'; + +const ProfileChecker: React.FC = () => { + const router = useRouter(); + const isDevMode = useIsDevMode(); + const { data, isLoading } = trpc.user.user.checkProfileComplete.useQuery(); + const [dialogOpen, setDialogOpen] = React.useState(false); + + React.useEffect(() => { + if (!isLoading && data && !data.isComplete) { + setDialogOpen(true); + } + }, [data, isLoading]); + + if (isLoading || isDevMode) return null; + + return ( + setDialogOpen(false)}> + + + Complete Your Profile + + + Please complete your profile for a better experience. + + + setDialogOpen(false)} + fillColor="gray1" + textColor="black1" + /> + { setDialogOpen(false); router.push('/(drawer)/(tabs)/me/edit-profile'); }} + fillColor="brand500" + textColor="white1" + /> + + + + ); +}; + +export default ProfileChecker; \ No newline at end of file diff --git a/apps/user-ui/components/QuickDeliveryAddressSelector.tsx b/apps/user-ui/components/QuickDeliveryAddressSelector.tsx new file mode 100644 index 0000000..76e98dc --- /dev/null +++ b/apps/user-ui/components/QuickDeliveryAddressSelector.tsx @@ -0,0 +1,277 @@ +import React, { useState } from 'react'; +import { View, ScrollView, Dimensions } from 'react-native'; +import { useRouter } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { BottomDialog, MyTouchableOpacity, MyText, tw, theme } from 'common-ui'; +import { useAuth } from '@/src/contexts/AuthContext'; +import { trpc } from '@/src/trpc-client'; +import { useAddressStore } from '@/src/store/addressStore'; +import dayjs from 'dayjs'; + +interface QuickDeliveryAddressSelectorProps { + deliveryTime?: string; + slotId?: number; + onSlotChange?: (slotId: number) => void; + isForFlashDelivery?: boolean; +} + +const QuickDeliveryAddressSelector: React.FC = ({ + deliveryTime, + slotId, + onSlotChange, + isForFlashDelivery = false +}) => { + const router = useRouter(); + const [dialogOpen, setDialogOpen] = useState(false); + + const { isAuthenticated } = useAuth(); + const { selectedAddressId, setSelectedAddressId } = useAddressStore(); + + const { data: defaultAddressData } = trpc.user.address.getDefaultAddress.useQuery(); + const { data: addressesData } = trpc.user.address.getUserAddresses.useQuery(undefined, { + enabled: isAuthenticated, + }); + const { data: slotsData } = trpc.user.slots.getSlotsWithProducts.useQuery(); + + const defaultAddress = defaultAddressData?.data; + const addresses = addressesData?.data || []; + + // Find earliest slot for pre-selection + const earliestSlot = slotsData?.slots?.sort((a, b) => + dayjs(a.deliveryTime).diff(dayjs(b.deliveryTime)) + )[0]; + + // Transform addresses for display + const addressOptions = addresses.map(address => ({ + id: address.id, + name: address.name, + address: `${address.addressLine1}${address.addressLine2 ? `, ${address.addressLine2}` : ''}, ${address.city}, ${address.state} - ${address.pincode}`, + phone: address.phone, + })); + + // Transform slots for display + const slotOptions = slotsData?.slots?.map(slot => ({ + id: slot.id, + deliveryTime: dayjs(slot.deliveryTime).format('MMM DD, h:mm A'), + closeTime: dayjs(slot.freezeTime).format('h:mm A'), + })) || []; + + // Get current selected slot display + const getCurrentSlotDisplay = () => { + if (isForFlashDelivery) return '30 minutes'; + if (slotId) { + const slot = slotsData?.slots?.find(s => s.id === slotId); + return slot ? dayjs(slot.deliveryTime).format('MMM DD, h:mm A') : 'Select time'; + } + if (earliestSlot) { + return dayjs(earliestSlot.deliveryTime).format('MMM DD, h:mm A'); + } + return 'Select time'; + }; + + // Get current selected address display + const getCurrentAddressDisplay = () => { + if (selectedAddressId) { + const address = addresses.find(a => a.id === selectedAddressId); + if (address) return `${address.name} - ${address.addressLine1}`; + } + if (defaultAddress) { + return `${defaultAddress.name} - ${defaultAddress.addressLine1}`; + } + return 'Select address'; + }; + + + + return ( + <> + + {isForFlashDelivery && ( + + router.back()} + style={tw`p-2 -ml-2`} + activeOpacity={0.7} + > + + + + Delivery in 30 minutes + + + )} + + {!isForFlashDelivery && ( + + + router.back()} + style={tw`p-2 -ml-2`} + activeOpacity={0.7} + > + + + + Delivery At {getCurrentSlotDisplay()} + + + {/* Trigger Component with Separate Chevrons */} + + + /* Regular Delivery Time Section */ + setDialogOpen(true)} + style={tw`flex-row items-center justify-between mb-2`} + activeOpacity={0.7} + > + + {/* + Delivery Time + */} + + Delivery at: {getCurrentSlotDisplay()} + + + + + + + {/* Address Section */} + setDialogOpen(true)} + style={tw`flex-row items-center justify-between`} + activeOpacity={0.7} + > + + {/* + Delivery Address + */} + + TO: {getCurrentAddressDisplay()} + + + + + + + {/* Consolidated Dialog - 80% height */} + setDialogOpen(false)} + > + + + Select Delivery Options + + + + {/* Section 1: Delivery Time Selection */} + + + Select Delivery Time + + + + {isForFlashDelivery ? ( + + + + + Flash Delivery - 30 minutes + + + + Selected automatically for flash delivery + + + ) : ( + slotOptions.map(slot => ( + { + onSlotChange?.(slot.id); + setDialogOpen(false); + }} + activeOpacity={0.7} + > + + Delivery: {slot.deliveryTime} + + + Orders Close at: {slot.closeTime} + + + )) + )} + + + + {/* Divider */} + + + {/* Section 2: Address Selection */} + + + Select Delivery Address + + + + {!isAuthenticated ? ( + + + + + Authentication Required + + + + Please log in to select and manage delivery addresses. + + + ) : addressOptions.length === 0 ? ( + + + No delivery addresses available. Please add an address first. + + + ) : ( + addressOptions.map(address => ( + { + setSelectedAddressId(address.id); + setDialogOpen(false); + }} + activeOpacity={0.7} + > + + {address.name} + + + {address.address} + + + Phone: {address.phone} + + + )) + )} + + + + + + + )} + + + ); +}; + +export default QuickDeliveryAddressSelector; \ No newline at end of file diff --git a/apps/user-ui/components/SlotSpecificView.tsx b/apps/user-ui/components/SlotSpecificView.tsx new file mode 100644 index 0000000..2bc2c15 --- /dev/null +++ b/apps/user-ui/components/SlotSpecificView.tsx @@ -0,0 +1,510 @@ +import React, { useState } from 'react'; +import { Drawer } from 'expo-router/drawer'; +import { DrawerContentComponentProps } from '@react-navigation/drawer'; +import { View, ScrollView, Alert, Dimensions } from 'react-native'; +import { Image } from 'expo-image'; +import { useRouter, usePathname } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { tw, theme, MyText, MyTouchableOpacity, MyFlatList, AppContainer, MiniQuantifier } from 'common-ui'; +import { trpc } from '@/src/trpc-client'; +import { useQuickDeliveryStore } from '@/src/store/quickDeliveryStore'; +import { useAddToCart, useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-hooks'; +import { useHideTabNav } from '@/src/hooks/useHideTabNav'; +import CartIcon from '@/components/icons/CartIcon'; +import { useSlotStore } from '@/components/stores/slotStore'; + +import { LinearGradient } from 'expo-linear-gradient'; +import FloatingCartBar from '@/components/floating-cart-bar'; +import QuickDeliveryAddressSelector from '@/components/QuickDeliveryAddressSelector'; +import dayjs from 'dayjs'; + +const { width: screenWidth } = Dimensions.get("window"); +const drawerWidth = 85; // From layout drawerStyle +const itemWidth = (screenWidth - drawerWidth - 48) / 2; // Account for drawer width + +interface SlotLayoutProps { + slotId?: number; + storeId?: number; + baseUrl: string; + isForFlashDelivery?: boolean; +} + +function CustomDrawerContent(baseUrl: string, drawerProps: DrawerContentComponentProps, slotIdParent?: number, storeIdParent?: number) { + const router = useRouter(); + const pathname = usePathname(); + const { data: storesData } = trpc.user.stores.getStores.useQuery(); + const setStoreId = useSlotStore(state => state.setStoreId); + + const { slotId, storeId } = useSlotStore(); + + // Get current pathname to determine active item + const currentPath = pathname; + // Check if we are on the main 'quick-delivery' page (All products) + // const isAllActive = !currentPath.includes('/store/'); + const isAllActive = isNaN(storeId as number); + + + const allSlotsUrl = `${baseUrl}${slotId ? `?slotId=${slotId}` : ''}`; + + return ( + + + + {/* All Products Item */} + { + router.replace(allSlotsUrl as any); + }} + activeOpacity={0.8} + > + {isAllActive ? ( + + + + + + ALL + + + ) : ( + + + + + + ALL + + + )} + + + + + {/* Store Items */} + {storesData?.stores?.map(store => { + // Check if this specific store is active + + const isStoreActive = storeId === store.id; + // const isStoreActive = currentPath.includes(`/store/${store.id}`); + + return ( + { + setStoreId(store.id); + const targetUrl = `${baseUrl}${slotId ? `?slotId=${slotId}&storeId=${store.id}` : `?storeId=${store.id}`}`; + + router.replace(targetUrl as any); + }} + activeOpacity={0.8} + > + {isStoreActive ? ( + + + {store.signedImageUrl ? ( + + ) : ( + + )} + + + {store.name.replace(/^The\s+/i, '')} + + + {/* Active Pip/Indicator */} + + + ) : ( + + + {store.signedImageUrl ? ( + + ) : ( + + )} + + + {store.name.replace(/^The\s+/i, '')} + + + )} + + ); + }) || ( + Loading... + )} + + + + ); +} + +export function SlotLayout({ slotId, storeId, baseUrl, isForFlashDelivery }: SlotLayoutProps) { + const router = useRouter(); + + // const { slotId: paramsSlotId } = useLocalSearchParams(); + const isDrawerHidden = useQuickDeliveryStore(state => state.isDrawerHidden); + const setSelectedSlotId = useQuickDeliveryStore(state => state.setSelectedSlotId); + const setSlotId = useSlotStore(state => state.setSlotId); + + const handleSlotChange = (newSlotId: number) => { + setSelectedSlotId(newSlotId); + setSlotId(newSlotId); + router.replace(`${baseUrl}?slotId=${newSlotId}` as any); + }; + + const slotQuery = slotId + ? trpc.user.slots.getSlotById.useQuery({ slotId: Number(slotId) }) + : trpc.user.slots.nextMajorDelivery.useQuery(); + const deliveryTime = dayjs(slotQuery.data?.deliveryTime).format('DD MMM hh:mm A'); + + + return ( + <> + + + + CustomDrawerContent(baseUrl, props, slotId, storeId)} + screenOptions={{ + headerShown: false, + drawerType: 'permanent', + drawerStyle: { + width: 85, + ...(isDrawerHidden && { display: 'none' }), + }, + headerStyle: { + // width: 220, + backgroundColor: 'white', + }, + headerShadowVisible: false, + }} + > + + + {/* */} + + + {/* */} + + + ); +} + +const formatQuantity = (quantity: number, unit: string): { value: string; display: string } => { + if (unit?.toLowerCase() === 'kg' && quantity < 1) { + return { value: `${Math.round(quantity * 1000)} g`, display: `${Math.round(quantity * 1000)}g` }; + } + return { value: `${quantity} ${unit}(s)`, display: `${quantity}${unit}` }; +}; + +const CompactProductCard = ({ + item, + handleAddToCart, + onPress, + cartType = "regular", +}: { + item: any; + handleAddToCart: (productId: number) => void; + onPress?: () => void; + cartType?: "regular" | "flash"; +}) => { + + // Cart management for miniView + const { data: cartData } = useGetCart({}, cartType); + const updateCartItem = useUpdateCartItem({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }, cartType); + const removeFromCart = useRemoveFromCart({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }, cartType); + + const cartItem = cartData?.items?.find((cartItem: any) => cartItem.productId === item.id); + const quantity = cartItem?.quantity || 0; + + const handleQuantityChange = (newQuantity: number) => { + if (newQuantity === 0 && cartItem) { + removeFromCart.mutate({ itemId: cartItem.id }); + } else if (newQuantity === 1 && !cartItem) { + handleAddToCart(item.id); + } else if (cartItem) { + updateCartItem.mutate({ itemId: cartItem.id, quantity: newQuantity }); + } + }; + + return ( + + + + {item.isOutOfStock && ( + + Out of Stock + + )} + + {quantity > 0 ? ( + + ) : ( + handleQuantityChange(1)} + activeOpacity={0.8} + > + + + )} + + + + + + {item.name} + + + + + ₹{cartType === "flash" ? (item.flashPrice ?? item.price) : item.price} + {item.marketPrice && Number(item.marketPrice) > Number(item.price) && ( + ₹{item.marketPrice} + )} + Quantity: {formatQuantity(item.productQuantity || 1, item.unit).display} + + + + + + ); +}; + +interface SlotProductsProps { + slotId?: number; + storeId?: number; + baseUrl: string; +} + +export function SlotProducts({ slotId:slotIdParent, storeId:storeIdParent, baseUrl, }: SlotProductsProps) { + useHideTabNav('quick_delivery'); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = React.useState(false); + const router = useRouter(); + const slotId = slotIdParent; + const storeId = storeIdParent; + const storeIdNum = storeId; + // const { storeId, slotId: slotIdRaw } = useLocalSearchParams(); + // const slotId = Number(slotIdRaw); + + + // const storeIdNum = storeId ? Number(storeId) : undefined; + + const slotQuery = trpc.user.slots.getSlotById.useQuery({ slotId: slotId! }, { enabled: !!slotId }); + + const productsQuery = trpc.user.product.getAllProductsSummary.useQuery(); + + const { addToCart = () => { } } = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, "flash") || {}; + + const handleAddToCart = (productId: number) => { + setIsLoadingDialogOpen(true); + addToCart(productId, 1, slotId || 0, () => setIsLoadingDialogOpen(false)); + }; + + if (slotQuery.isLoading || (storeIdNum && productsQuery?.isLoading)) { + return ( + + + Loading slot delivery... + + + ); + } + + if (slotQuery.error || (storeIdNum && productsQuery?.error)) { + return ( + + + + Oops! + Failed to load slot delivery + + + ); + } + + if (!slotQuery.data) { + return ( + + + Quick Delivery + No delivery slot available. + + + ); + } + + const filteredProducts: any[] = storeIdNum ? productsQuery?.data?.filter(p => p.storeId === storeIdNum) || [] : slotQuery.data.products; + + return ( + + ( + router.push(`/(drawer)/(tabs)/home/product-detail/${item.id}`)} + cartType="regular" + /> + )} + keyExtractor={(item, index) => index.toString()} + columnWrapperStyle={{ gap: 16, justifyContent: 'flex-start' }} + contentContainerStyle={[tw`pb-24 px-4`, { gap: 16 }]} + onRefresh={() => slotQuery.refetch()} + ListEmptyComponent={ + storeIdNum ? ( + + No products from this store in this slot. + + ) : null + } + /> + + ); +} + +interface FlashDeliveryProductsProps { + storeId?: number; + baseUrl: string; + onProductPress?: (productId: number) => void; +} + +export function FlashDeliveryProducts({ storeId:storeIdParent, baseUrl, onProductPress }: FlashDeliveryProductsProps) { + useHideTabNav('quick_delivery'); + const [isLoadingDialogOpen, setIsLoadingDialogOpen] = React.useState(false); + const router = useRouter(); + const storeId = storeIdParent; + const storeIdNum = storeId; + + const productsQuery = trpc.user.product.getAllProductsSummary.useQuery(); + + const { addToCart = () => { } } = useAddToCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, "flash") || {}; + + const handleAddToCart = (productId: number) => { + setIsLoadingDialogOpen(true); + + addToCart(productId, 1, 0, () => setIsLoadingDialogOpen(false)); + }; + + if (storeIdNum && productsQuery?.isLoading) { + return ( + + + Loading Flash Delivery... + + + ); + } + + if (storeIdNum && productsQuery?.error) { + return ( + + + + Oops! + Failed to load Flash Delivery + + + ); + } + + // Filter products to only include those eligible for flash delivery + let flashProducts: any[] = []; + if (storeIdNum) { + // Filter by store and flash availability + flashProducts = productsQuery?.data?.filter(p => p.storeId === storeIdNum && p.isFlashAvailable) || []; + } else { + // Show all flash-available products (no slot filtering) + flashProducts = productsQuery?.data?.filter(p => p.isFlashAvailable) || []; + } + + return ( + + ( + { + if (onProductPress) { + onProductPress(item.id); + } else { + router.push(`/(drawer)/(tabs)/flash-delivery/product-detail/${item.id}`); + } + }} + cartType="flash" + /> + )} + keyExtractor={(item, index) => index.toString()} + columnWrapperStyle={{ gap: 16, justifyContent: 'flex-start' }} + contentContainerStyle={[tw`pb-24 px-4`, { gap: 16 }]} + onRefresh={() => productsQuery.refetch()} + ListEmptyComponent={ + + No Flash Delivery products available. + + } + /> + + ); +} \ No newline at end of file diff --git a/apps/user-ui/components/TabLayoutWrapper.tsx b/apps/user-ui/components/TabLayoutWrapper.tsx new file mode 100644 index 0000000..7292a0b --- /dev/null +++ b/apps/user-ui/components/TabLayoutWrapper.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { SafeAreaView } from 'react-native-safe-area-context'; +import { tw } from 'common-ui'; + +interface TabLayoutWrapperProps { + children: React.ReactNode; +} + +export default function TabLayoutWrapper({ children }: TabLayoutWrapperProps) { + return ( + + {children} + + ); +} \ No newline at end of file diff --git a/apps/user-ui/components/TestingPhaseNote.tsx b/apps/user-ui/components/TestingPhaseNote.tsx new file mode 100644 index 0000000..b856ffc --- /dev/null +++ b/apps/user-ui/components/TestingPhaseNote.tsx @@ -0,0 +1,33 @@ +import React from "react"; +import { View } from "react-native"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { MyText, tw } from "common-ui"; + +const TestingPhaseNote: React.FC = () => { + return ( + + + + + Testing Phase + + + + + • This app is in testing phase until Jan 23, 2026 + + + • Actual delivery service has not started yet + + + • Prices shown are not real + + + • Any feedback or issues found? WhatsApp on +91 9676651496 + + + + ); +}; + +export default TestingPhaseNote; diff --git a/apps/user-ui/components/UpdateChecker.tsx b/apps/user-ui/components/UpdateChecker.tsx new file mode 100644 index 0000000..cee29dd --- /dev/null +++ b/apps/user-ui/components/UpdateChecker.tsx @@ -0,0 +1,38 @@ +import React, { useEffect } from 'react'; +import * as Updates from 'expo-updates'; +import { Alert } from 'react-native'; + +interface UpdateCheckerProps { + children: React.ReactNode; +} + +const UpdateChecker: React.FC = ({ children }) => { + useEffect(() => { + const checkForUpdates = async () => { + try { + const update = await Updates.checkForUpdateAsync(); + if (update.isAvailable) { + Alert.alert( + "Update available", + "Restart app to apply the update?", + [ + { text: "Later", style: "cancel" }, + { text: "Restart", onPress: () => Updates.reloadAsync() } + ] + ); + } + } catch (error) { + console.log('Update check failed:', error); + } + }; + + // Only check on production builds + if (!__DEV__) { + checkForUpdates(); + } + }, []); + + return <>{children}; +}; + +export default UpdateChecker; \ No newline at end of file diff --git a/apps/user-ui/components/UserAddressHeader.tsx b/apps/user-ui/components/UserAddressHeader.tsx new file mode 100644 index 0000000..c3f52a2 --- /dev/null +++ b/apps/user-ui/components/UserAddressHeader.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { View } from 'react-native'; +import { useRouter } from 'expo-router'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { trpc } from '@/src/trpc-client'; +import { tw, MyText, MyTouchableOpacity } from 'common-ui'; + +export default function UserAddressHeader() { + const router = useRouter(); + const { data: defaultAddressResponse } = trpc.user.address.getDefaultAddress.useQuery(); + const defaultAddress = defaultAddressResponse?.data; + + // Use a cleaner, white aesthetic that doesn't dominate the eye but feels premium + return ( + + + router.push('/(drawer)/(tabs)/me/addresses')} + style={tw`flex-1`} + > + + {/* Small subtle brand indicator */} + + + + Delivering to + + + {defaultAddress?.name ? defaultAddress.name.split(' ')[0] : 'Home'} + + + + + + {defaultAddress ? `${defaultAddress.addressLine1}, ${defaultAddress.city}` : 'Add a delivery address'} + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/components/WebViewWrapper.tsx b/apps/user-ui/components/WebViewWrapper.tsx new file mode 100644 index 0000000..2f64735 --- /dev/null +++ b/apps/user-ui/components/WebViewWrapper.tsx @@ -0,0 +1,59 @@ +import React, { useState } from 'react'; +import { View, ActivityIndicator } from 'react-native'; +import { WebView } from 'react-native-webview'; +import { trpc } from '@/src/trpc-client'; +import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'; +import { theme, MyText, MyTouchableOpacity } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; + +interface WebViewWrapperProps { + children: React.ReactNode; +} + +export default function WebViewWrapper({ children }: WebViewWrapperProps) { + const { data: constsData, isLoading } = useGetEssentialConsts(); + const [isClosed, setIsClosed] = useState(false); + + if (isLoading) { + return ( + + + Loading... + + ); + } + + const webviewHtml = constsData?.webviewHtml; + const isWebviewClosable = constsData?.isWebviewClosable; + + if (webviewHtml && !isClosed) { + return ( + + + {isWebviewClosable && ( + + setIsClosed(true)} + style={{ + backgroundColor: 'rgba(0,0,0,0.5)', + borderRadius: 20, + padding: 8, + }} + > + + + + )} + + ); + } + + return <>{children}; +} \ No newline at end of file diff --git a/apps/user-ui/components/cart-page.tsx b/apps/user-ui/components/cart-page.tsx new file mode 100644 index 0000000..70cf8f0 --- /dev/null +++ b/apps/user-ui/components/cart-page.tsx @@ -0,0 +1,1044 @@ +import React, { useState, useEffect, useMemo } from "react"; +import { + View, + ScrollView, + Image, + Alert, + Platform, + TouchableOpacity, +} from "react-native"; +import { useRouter } from "expo-router"; +import { + tw, + useManualRefresh, + AppContainer, + useMarkDataFetchers, + MyText, + MyTouchableOpacity, + BottomDropdown, BottomDialog , Quantifier } from "common-ui"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { useHideTabNav } from "@/src/hooks/useHideTabNav"; + +import TestingPhaseNote from "@/components/TestingPhaseNote"; + +import dayjs from "dayjs"; +import { trpc } from "@/src/trpc-client"; +import { useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-hooks'; +import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'; + +interface CartItem { + id: number; + productId: number; + quantity: number; + product: { + price: number; + isOutOfStock: boolean; + name: string; + images: string[]; + unit?: string; + incrementStep?: number; + productQuantity?: number; + } | null; +} + +interface CartPageProps { + isFlashDelivery?: boolean; +} + +export default function CartPage({ isFlashDelivery = false }: CartPageProps) { + // Hide tabs when cart page is active + useHideTabNav(); + + const cartType: "regular" | "flash" = isFlashDelivery ? "flash" : "regular"; + + const [quantities, setQuantities] = useState>({}); + const { + data: cartData, + isLoading, + error, + refetch: refetchCart, + } = useGetCart({ refetchOnWindowFocus: true }, cartType); + + // Extract product IDs from cart items + const productIds = cartData?.items.map(item => item.productId) || []; + + // Get cart slots for the products in cart + const { data: slotsData, refetch: refetchSlots, error: slotsError } = trpc.user.cart.getCartSlots.useQuery( + { productIds }, + { + enabled: productIds.length > 0, + refetchOnWindowFocus: false + } + ); + + const generateCouponDescription = (coupon: any): string => { + let desc = ""; + + if (coupon.discountPercent) { + desc += `${coupon.discountPercent}% off`; + } else if (coupon.flatDiscount) { + desc += `₹${coupon.flatDiscount} off`; + } + + if (coupon.minOrder) { + desc += ` on orders above ₹${coupon.minOrder}`; + } + + if (coupon.maxValue) { + desc += ` (max discount ₹${coupon.maxValue})`; + } + + return desc; + }; + + const { data: couponsRaw, error: couponsError } = trpc.user.coupon.getEligible.useQuery(); + const { data: constsData } = useGetEssentialConsts(); + const { data: productsData } = trpc.user.product.getAllProductsSummary.useQuery(); + + const cartItems = cartData?.items || []; + + + // Memoized flash-eligible product IDs + const flashEligibleProductIds = useMemo(() => { + if (!productsData) return new Set(); + return new Set( + productsData + .filter((product: any) => product.isFlashAvailable) + .map((product: any) => product.id) + ); + }, [productsData]); + + // Base total price without discounts for coupon eligibility check + const baseTotalPrice = useMemo( + () => + cartItems + .filter((item) => !item.product?.isOutOfStock) + .reduce( + (sum, item) => + sum + + (item.product?.price || 0) * (quantities[item.id] || item.quantity), + 0 + ), + [cartItems, quantities] + ); + + const eligibleCoupons = useMemo(() => { + if (!couponsRaw?.data) return []; + return couponsRaw.data + .map((coupon) => { + let isEligible = true; + let ineligibilityReason = ""; + if ( + coupon.maxLimitForUser && + coupon.usages.length >= coupon.maxLimitForUser + ) { + isEligible = false; + ineligibilityReason = "Usage limit exceeded"; + } + if (coupon.minOrder && parseFloat(coupon.minOrder) > baseTotalPrice) { + isEligible = false; + ineligibilityReason = `Min order ₹${coupon.minOrder}`; + } + return { + id: coupon.id, + code: coupon.couponCode, + discountType: coupon.discountPercent ? "percentage" : "flat", + discountValue: parseFloat( + coupon.discountPercent || coupon.flatDiscount || "0" + ), + maxValue: coupon.maxValue ? parseFloat(coupon.maxValue) : undefined, + minOrder: coupon.minOrder ? parseFloat(coupon.minOrder) : undefined, + description: generateCouponDescription(coupon), + exclusiveApply: coupon.exclusiveApply, + isEligible, + ineligibilityReason: isEligible ? undefined : ineligibilityReason, + }; + }) + .filter( + (coupon) => coupon.ineligibilityReason !== "Usage limit exceeded" + ); + }, [couponsRaw, baseTotalPrice]); + + const updateCartItem = useUpdateCartItem({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType); + const removeFromCart = useRemoveFromCart({ showSuccessAlert: false, showErrorAlert: false, refetchCart: true }, cartType); + + useMarkDataFetchers(() => { + refetchCart(); + refetchSlots(); + }); + useManualRefresh(() => { + refetchCart(); + refetchSlots(); + }); + const [selectedSlots, setSelectedSlots] = useState>({}); + const [selectedCouponId, setSelectedCouponId] = useState(null); + const [couponDialogOpen, setCouponDialogOpen] = useState(false); + + const router = useRouter(); + + // Process slots: flatten and unique + const availableSlots = React.useMemo(() => { + if (!slotsData) return []; + const allSlots = Object.values(slotsData).flat(); + const uniqueSlots = allSlots.filter( + (slot, index, self) => index === self.findIndex((s) => s.id === slot.id) + ); + return uniqueSlots.map((slot) => ({ + label: `Delivery: ${dayjs(slot.deliveryTime).format( + "ddd DD MMM, h:mm a" + )} - Close time: ${dayjs(slot.freezeTime).format("h:mm a")}`, + value: slot.id, + })); + }, [slotsData]); + + // Get available slots for a specific product + const getAvailableSlotsForProduct = React.useMemo(() => { + return (productId: number) => { + if (!slotsData || !slotsData[productId]) return []; + return slotsData[productId].map((slot) => ({ + label: `Delivery: ${dayjs(slot.deliveryTime).format( + "ddd DD MMM, h:mm a" + )} - Close time: ${dayjs(slot.freezeTime).format("h:mm a")}`, + value: slot.id, + })); + }; + }, [slotsData]); + + // Calculate coupon discount + const selectedCoupons = useMemo( + () => + selectedCouponId ? eligibleCoupons?.filter((coupon) => coupon.id === selectedCouponId) : [], + [eligibleCoupons, selectedCouponId] + ); + + const totalPrice = cartItems + .filter((item) => !item.product?.isOutOfStock) + .reduce((sum, item) => { + const quantity = quantities[item.id] || item.quantity; + const price = isFlashDelivery ? (item.product?.flashPrice ?? item.product?.price ?? 0) : (item.product?.price || 0); + return sum + price * quantity; + }, 0); + const dropdownData = useMemo( + () => + eligibleCoupons?.map((coupon) => { + const discount = + coupon.discountType === "percentage" + ? Math.min( + (totalPrice * coupon.discountValue) / 100, + coupon.maxValue || Infinity + ) + : Math.min(coupon.discountValue, coupon.maxValue || totalPrice); + const saveString = !isNaN(discount) ? ` (Save ₹${discount})` : ""; + const baseLabel = `${coupon.code} - ${coupon.description}${coupon.isEligible ? saveString : "" + }`; + const label = coupon.isEligible + ? baseLabel + : `${baseLabel} (${coupon.ineligibilityReason})`; + return { + label, + value: coupon.id, + disabled: !coupon.isEligible, + }; + }) || [], + [eligibleCoupons, totalPrice] + ); + + const discountAmount = useMemo( + () => + selectedCoupons?.reduce( + (sum, coupon) => + sum + + (coupon.discountType === "percentage" + ? Math.min( + (totalPrice * coupon.discountValue) / 100, + coupon.maxValue || Infinity + ) + : Math.min(coupon.discountValue, coupon.maxValue || totalPrice)), + 0 + ) || 0, + [selectedCoupons, totalPrice] + ); + + const finalTotal = totalPrice - discountAmount; + + const deliveryCharge = useMemo( + () => { + const threshold = isFlashDelivery + ? constsData?.flashFreeDeliveryThreshold + : constsData?.freeDeliveryThreshold; + const charge = isFlashDelivery + ? constsData?.flashDeliveryCharge + : constsData?.deliveryCharge; + return finalTotal < threshold ? charge : 0; + }, + [finalTotal, constsData, isFlashDelivery] + ); + + const finalTotalWithDelivery = finalTotal + deliveryCharge; + + const hasAvailableItems = cartItems.some(item => !item.product?.isOutOfStock); + + useEffect(() => { + const initial: Record = {}; + cartItems.forEach((item) => { + initial[item.id] = item.quantity; + }); + setQuantities(initial); + }, [cartData]); + + // Auto-select delivery slots for each cart item + useEffect(() => { + if (cartItems.length > 0) { + const newSelectedSlots = { ...selectedSlots }; + + cartItems.forEach(item => { + // Skip if already has a selected slot + if (selectedSlots[item.id]) return; + + if (isFlashDelivery) { + // For flash delivery, always use slot 0 + newSelectedSlots[item.id] = 0; + } else { + // For regular delivery, find earliest available slot + const productSlots = slotsData?.[item.productId]; + if (!productSlots || productSlots.length === 0) return; + + const now = dayjs(); + const upcomingSlots = productSlots.filter(slot => + dayjs(slot.deliveryTime).isAfter(now) + ).sort((a, b) => + dayjs(a.deliveryTime).diff(dayjs(b.deliveryTime)) + ); + + if (upcomingSlots.length > 0) { + // Select the earliest available slot for this product + const earliestSlot = upcomingSlots[0]; + newSelectedSlots[item.id] = earliestSlot.id; + } + } + }); + + setSelectedSlots(newSelectedSlots); + } + }, [slotsData, cartItems, isFlashDelivery]); + + + + if (isLoading) { + return ( + + Loading cart... + + ); + } + + if (error) { + return ( + + + Oops! + Failed to load your cart + + ); + } + + return ( + + {/* Fixed Cart Type Header */} + + + router.back()} + style={tw`p-2 -ml-2 mr-1`} + activeOpacity={0.7} + > + + + + + {isFlashDelivery ? "Flash Delivery Cart" : "Scheduled Delivery Cart"} + + + + + + + + {/* Cart Items */} + {cartItems.length === 0 ? ( + + + + + + Your cart is empty + + + Looks like you haven't added anything to your cart yet. + + router.push("/(drawer)/(tabs)/home")} + > + Start Shopping + + + ) : ( + <> + + {cartItems.map((item, index) => { + const productSlots = getAvailableSlotsForProduct(item.productId); + const selectedSlotForItem = selectedSlots[item.id]; + const isFlashEligible = isFlashDelivery ? flashEligibleProductIds.has(item.productId) : true; + // const isAvailable = (productSlots.length > 0 || isFlashDelivery) && !item.product?.isOutOfStock && isFlashEligible; + let isAvailable = true; + + if(item.product?.isOutOfStock) { + isAvailable = false; + } else if(isFlashDelivery) { + if(!isFlashEligible) { + isAvailable = false; + } + } else { + if(productSlots.length === 0) { + isAvailable = false; + } + } + // if (item.product?.isOutOfStock) { + // isAvailable = false; + // } else if (isFlashDelivery) { + // isAvailable = isFlashEligible; + // } + const quantity = quantities[item.id] || item.quantity; + const price = isFlashDelivery ? (item.product?.flashPrice ?? item.product?.price ?? 0) : (item.product?.price || 0); + const itemPrice = price * quantity; + + return ( + + + + + + + {item.product.name} + + + {(() => { + const qty = item.product?.productQuantity || 1; + const unit = item.product?.unit || ''; + if (unit?.toLowerCase() === 'kg' && qty < 1) { + return `${Math.round(qty * 1000)}g`; + } + return `${qty}${unit}`; + })()} + + + + + { + if (value === 0) { + // Show confirmation alert before removing item + Alert.alert( + "Remove Item", + "Are you sure you want to remove this item from your cart?", + [ + { + text: "Cancel", + style: "cancel", + onPress: () => { + // Reset quantity back to 1 + setQuantities((prev) => ({ ...prev, [item.id]: 1 })); + } + }, + { + text: "Remove", + style: "destructive", + onPress: () => { + // Proceed with removal + removeFromCart.mutate( + { itemId: item.id }, + { + onSuccess: () => { + refetchCart(); + }, + onError: (error: any) => { + Alert.alert("Error", error.message || "Failed to remove item"); + // Restore quantity on error + setQuantities((prev) => ({ ...prev, [item.id]: 1 })); + }, + } + ); + } + } + ] + ); + } else { + // Update quantity normally + setQuantities((prev) => ({ + ...prev, + [item.id]: value, + })); + updateCartItem.mutate({ + itemId: item.id, + quantity: value, + }); + } + }} + step={item.product.incrementStep} + unit={item.product?.unit} + /> + + + + + {/* Delivery Slot Selection per Product - Hidden for Flash Delivery */} + {!isFlashDelivery && ( + + + { + setSelectedSlots((prev) => ({ + ...prev, + [item.id]: Number(value) + })); + }} + disabled={productSlots.length === 0} + + triggerComponent={({ onPress, disabled, displayText }) => { + const selectedSlotForItem = selectedSlots[item.id]; + const selectedSlot = productSlots.find(slot => slot.value === selectedSlotForItem); + + const deliveryTimeText = selectedSlot + ? selectedSlot.label.split(' - ')[0].replace('Delivery: ', '') + : null; + + return ( + + + + {deliveryTimeText || (productSlots.length === 0 + ? "No delivery slots available" + : "Choose delivery slot")} + + + + Change + + + + ); + }} + /> + + + + + ₹{itemPrice} + + { + Alert.alert( + "Remove Item", + `Remove ${item.product.name} from cart?`, + [ + { text: "Cancel", style: "cancel" }, + { + text: "Remove", + style: "destructive", + onPress: () => { + removeFromCart.mutate( + { itemId: item.id }, + { + onSuccess: () => { + refetchCart(); + }, + onError: (error: any) => { + Alert.alert( + "Error", + error.message || + "Failed to remove item" + ); + }, + } + ); + }, + }, + ] + ); + }} + style={tw`p-1`} + > + + + + + + )} + + {/* Price for Flash Delivery (already in same row as slot) */} + {isFlashDelivery && ( + + + + ₹{itemPrice} + + { + Alert.alert( + "Remove Item", + `Remove ${item.product.name} from cart?`, + [ + { text: "Cancel", style: "cancel" }, + { + text: "Remove", + style: "destructive", + onPress: () => { + removeFromCart.mutate( + { itemId: item.id }, + { + onSuccess: () => { + refetchCart(); + }, + onError: (error: any) => { + Alert.alert( + "Error", + error.message || + "Failed to remove item" + ); + }, + } + ); + }, + }, + ] + ); + }} + style={tw`p-1`} + > + + + + + )} + + {!isAvailable && ( + + + {item.product?.isOutOfStock + ? "Out of Stock" + : isFlashDelivery && !flashEligibleProductIds.has(item.productId) + ? "Not available for flash delivery. Please remove" + : "No delivery slots available"} + + + )} + + + {/* Gray horizontal line between items (except for the last item) */} + {index < cartItems.length - 1 && ( + + )} + + ); + })} + + + )} + + {/* Cart Type Switcher */} + {cartItems.length > 0 && ( + + + {/* First row: Text content */} + + + + + + + {isFlashDelivery ? "Flash Delivery" : "Scheduled Delivery"} + + + {isFlashDelivery + ? "30 min delivery • Immediate pickup" + : "Choose your preferred delivery time" + } + + + + + {/* Second row: Navigation trigger */} + { + if (isFlashDelivery) { + // Switch from flash to scheduled delivery + router.push("/(drawer)/(tabs)/home" as any); + } else { + // Switch from scheduled to flash delivery + router.push("/(drawer)/(tabs)/flash-delivery/(products)"); + } + }} + activeOpacity={0.8} + > + + {isFlashDelivery ? "Go to Scheduled Delivery" : "Go to Flash Delivery"} + + + + + + )} + + {/* Coupon Selection */} + {hasAvailableItems && ( + + + + + + + Offers & Coupons + + + + { + setSelectedCouponId(value ? Number(value) : null); + }} + placeholder={ + eligibleCoupons.length === 0 + ? "No coupons available" + : "Select a coupon" + } + /> + + {eligibleCoupons.length === 0 && ( + + No coupons available for this order + + )} + + + + {selectedCouponId && ( + setSelectedCouponId(null)} + > + + Remove coupon + + + )} + + )} + + + + {/* Bottom Checkout Bar - Now Static */} + {hasAvailableItems && ( + + + {/* Bill Header */} + + Bill Details + + + + {/* Item Total */} + + Item Total + ₹{totalPrice} + + + {/* Discount */} + {discountAmount > 0 && ( + + Product Discount + -₹{discountAmount} + + )} + + {/* Applied Coupon */} + {selectedCoupons.length > 0 && ( + + Coupon Applied + setCouponDialogOpen(true)}> + {selectedCoupons[0].code} + + + )} + + {/* Delivery Fee */} + + + Delivery Fee + + + + {deliveryCharge === 0 && (constsData?.deliveryCharge || 0) > 0 && ( + + ₹{constsData?.deliveryCharge} + + )} + + {deliveryCharge === 0 ? 'Free' : `₹${deliveryCharge}`} + + + + + {/* Free Delivery Nudge */} + {deliveryCharge > 0 && (constsData?.freeDeliveryThreshold || 0) > 0 && finalTotal < (constsData?.freeDeliveryThreshold || 0) && ( + + + + Add products worth ₹{((constsData?.freeDeliveryThreshold || 0) - finalTotal).toFixed(0)} for free delivery + + + )} + + {/* Divider */} + + + {/* Grand Total */} + + To Pay + ₹{finalTotalWithDelivery} + + + {/* Savings Banner */} + {(discountAmount > 0 || deliveryCharge === 0) && ( + + + + You saved ₹{discountAmount + (deliveryCharge === 0 ? (constsData?.deliveryCharge || 0) : 0)} on this order + + + )} + + + {/* Action Buttons */} + + + router.push(isFlashDelivery ? "/(drawer)/(tabs)/flash-delivery" : "/(drawer)/(tabs)/home")} + > + Shop More + + { + const availableItems = cartItems + .filter(item => { + if (item.product?.isOutOfStock) return false; + if (isFlashDelivery) { + // Check if product supports flash delivery + return flashEligibleProductIds.has(item.productId); + } + return selectedSlots[item.id]; // Regular delivery requires slot selection + }) + .map(item => item.id); + + + + if (availableItems.length === 0) { + // Determine why no items are available + const outOfStockItems = cartItems.filter(item => item.product?.isOutOfStock); + const inStockItems = cartItems.filter(item => !item.product?.isOutOfStock); + + let errorTitle = "Cannot Proceed"; + let errorMessage = ""; + + if (outOfStockItems.length === cartItems.length) { + // All items are out of stock + errorTitle = "Items Unavailable"; + errorMessage = "All items in your cart are currently out of stock. Please remove them and add available items."; + } else if (isFlashDelivery) { + // Check if any items are flash-eligible + const flashEligibleItems = inStockItems.filter(item => + flashEligibleProductIds.has(item.productId) + ); + if (flashEligibleItems.length === 0) { + errorTitle = "Flash Delivery Unavailable"; + errorMessage = "None of the items in your cart are available for flash delivery. Please remove ineligible items or switch to regular delivery."; + } else { + errorTitle = "Some Items Not Available"; + errorMessage = "Some items in your cart are not available for flash delivery. You can proceed with only the eligible items, or remove ineligible items."; + } + } else { + // Regular delivery - check slot selection + const itemsWithoutSlots = inStockItems.filter(item => !selectedSlots[item.id]); + if (itemsWithoutSlots.length > 0) { + errorTitle = "Delivery Slot Required"; + errorMessage = `${itemsWithoutSlots.length} item(s) don't have a delivery slot. Please remove them or select a slot for each item.`; + } else { + errorTitle = "Cannot Proceed"; + errorMessage = "Please check your cart items and try again."; + } + } + + Alert.alert(errorTitle, errorMessage); + return; + } + + // Check if there are items without slots (for regular delivery) + if (!isFlashDelivery && availableItems.length < cartItems.length) { + const itemsWithoutSlots = cartItems.filter(item => !selectedSlots[item.id] && !item.product?.isOutOfStock); + if (itemsWithoutSlots.length > 0) { + Alert.alert( + "Delivery Slot Required", + `${itemsWithoutSlots.length} item(s) don't have a delivery slot. Please select a slot or remove the item.` + ); + return; + } + } + + // Group items by selected slot + const itemsBySlot: Record = {}; + availableItems.forEach(itemId => { + const slotId = isFlashDelivery ? 0 : selectedSlots[itemId]; + if (!itemsBySlot[slotId]) { + itemsBySlot[slotId] = []; + } + itemsBySlot[slotId].push(itemId); + }); + + // Create checkout URL with slot groupings + const slotParams = Object.entries(itemsBySlot) + .map(([slotId, itemIds]) => `${slotId}:${itemIds.join(',')}`) + .join(';'); + + router.push( + `${isFlashDelivery ? '/(drawer)/(tabs)/flash-delivery/checkout' : '/(drawer)/(tabs)/home/checkout'}?slots=${encodeURIComponent(slotParams)}${selectedCouponId ? `&coupons=${selectedCouponId}` : ''}&deliveryPrice=${deliveryCharge}` as any + ); + }} + > + Checkout + + + + + + )} + + + + {/* Coupon Details Dialog */} + setCouponDialogOpen(false)} + > + + + + + + + Applied Coupons + + + + {selectedCoupons.map((coupon) => ( + + + + + {coupon.code} + + + {coupon.description} + + + + + {coupon.discountType === "percentage" + ? `${coupon.discountValue}% OFF` + : `₹${coupon.discountValue} OFF`} + + + + {coupon.maxValue && ( + + Maximum discount up to ₹{coupon.maxValue} + + )} + + ))} + + setCouponDialogOpen(false)} + > + Close + + + + + ); +} \ No newline at end of file diff --git a/apps/user-ui/components/checkout-page.tsx b/apps/user-ui/components/checkout-page.tsx new file mode 100644 index 0000000..817215d --- /dev/null +++ b/apps/user-ui/components/checkout-page.tsx @@ -0,0 +1,273 @@ +import React, { useState, useMemo } from 'react'; +import { View, ScrollView } from 'react-native'; +import { useLocalSearchParams, useRouter } from 'expo-router'; +import { tw, useMarkDataFetchers , BottomDialog, MyText, MyTouchableOpacity } from 'common-ui'; +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { useQueryClient } from '@tanstack/react-query'; +import AddressForm from '@/src/components/AddressForm'; +import { useAuthenticatedRoute } from '@/hooks/useAuthenticatedRoute'; + +import { trpc } from '@/src/trpc-client'; +import { useGetCart } from '@/hooks/cart-query-hooks'; +import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'; +import PaymentAndOrderComponent from '@/components/PaymentAndOrderComponent'; +import CheckoutAddressSelector from '@/components/CheckoutAddressSelector'; +import { useAddressStore } from '@/src/store/addressStore'; + +interface CheckoutPageProps { + isFlashDelivery?: boolean; +} + +const CheckoutPage: React.FC = ({ isFlashDelivery = false }) => { + const params = useLocalSearchParams(); + const queryClient = useQueryClient(); + const router = useRouter(); + + // Protect checkout route and preserve query params + useAuthenticatedRoute({ + targetUrl: isFlashDelivery ? '/(drawer)/(tabs)/flash-delivery/checkout' : '/(drawer)/(tabs)/home/checkout', + queryParams: params + }); + + const cartType: "regular" | "flash" = isFlashDelivery ? "flash" : "regular"; + const { data: cartData, refetch: refetchCart } = useGetCart({}, cartType); + console.log({cartType}) + + const { data: addresses, refetch: refetchAddresses } = trpc.user.address.getUserAddresses.useQuery(); + const { data: slotsData, refetch: refetchSlots } = trpc.user.slots.getSlots.useQuery(); + const { data: constsData } = useGetEssentialConsts(); + const { data: productsData } = trpc.user.product.getAllProductsSummary.useQuery(); + + useMarkDataFetchers(() => { + refetchCart(); + refetchAddresses(); + refetchSlots(); + }); + + const { selectedAddressId, setSelectedAddressId } = useAddressStore(); + const [showAddAddress, setShowAddAddress] = useState(false); + const [selectedCouponId, setSelectedCouponId] = useState(null); + + + + const cartItems = cartData?.items || []; + + // Memoized flash-eligible product IDs + const flashEligibleProductIds = useMemo(() => { + if (!productsData) return new Set(); + return new Set( + productsData + .filter((product: any) => product.isFlashAvailable) + .map((product: any) => product.id) + ); + }, [productsData]); + + // Parse slots parameter from URL (format: "1:1,2,3;2:4,5") + const selectedSlots = useMemo(() => { + const slots: Record = {}; + if (params.slots) { + const slotGroups = (params.slots as string).split(';'); + slotGroups.forEach(group => { + const [slotIdStr, itemIdsStr] = group.split(':'); + const slotId = Number(slotIdStr); + const itemIds = itemIdsStr.split(',').map(Number); + itemIds.forEach(itemId => { + slots[itemId] = slotId; + }); + }); + } + return slots; + }, [params.slots]); + + const selectedItems = cartItems.filter(item => { + // For flash delivery, check if product supports flash delivery + if (isFlashDelivery) { + return flashEligibleProductIds.has(item.productId); + } + // For regular delivery, only include items with assigned slots + return selectedSlots[item.id]; + }); + + React.useEffect(() => { + if (params.coupons) { + const couponId = Number(params.coupons as string); + setSelectedCouponId(couponId); + } + }, [params.coupons]); + + // Handle empty cart case + if (selectedItems.length === 0) { + return ( + + + + {cartItems.length === 0 ? "Your cart is empty" : "No items to checkout"} + + + {cartItems.length === 0 + ? "Add some delicious items to your cart before checking out" + : isFlashDelivery + ? "None of your cart items are available for flash delivery" + : "Please select delivery slots for your items" + } + + router.back()} + > + Back to Shopping + + + ); + } + + + + const totalPrice = selectedItems + .filter((item) => !item.product?.isOutOfStock) + .reduce( + (sum, item) => { + const price = isFlashDelivery ? (item.product?.flashPrice ?? item.product?.price ?? 0) : (item.product?.price || 0); + return sum + price * item.quantity; + }, + 0 + ); + + const { data: couponsRaw } = trpc.user.coupon.getEligible.useQuery(); + + const eligibleCoupons = useMemo(() => { + if (!couponsRaw?.data) return []; + return couponsRaw.data.map(coupon => { + let isEligible = true; + let ineligibilityReason = ''; + if (coupon.maxLimitForUser && coupon.usages.length >= coupon.maxLimitForUser) { + isEligible = false; + ineligibilityReason = 'Usage limit exceeded'; + } + if (coupon.minOrder && parseFloat(coupon.minOrder) > totalPrice) { + isEligible = false; + ineligibilityReason = `Min order ₹${coupon.minOrder}`; + } + return { + id: coupon.id, + code: coupon.couponCode, + discountType: coupon.discountPercent ? 'percentage' : 'flat', + discountValue: parseFloat(coupon.discountPercent || coupon.flatDiscount || '0'), + maxValue: coupon.maxValue ? parseFloat(coupon.maxValue) : undefined, + minOrder: coupon.minOrder ? parseFloat(coupon.minOrder) : undefined, + description: '', + exclusiveApply: coupon.exclusiveApply, + isEligible, + ineligibilityReason: isEligible ? undefined : ineligibilityReason, + }; + }).filter(coupon => coupon.ineligibilityReason !== 'Usage limit exceeded'); + }, [couponsRaw, totalPrice]); + + const selectedCoupons = useMemo( + () => + selectedCouponId ? eligibleCoupons?.filter((coupon) => coupon.id === selectedCouponId) : [], + [eligibleCoupons, selectedCouponId] + ); + + const discountAmount = useMemo( + () => + selectedCoupons?.reduce( + (sum, coupon) => + sum + + (coupon.discountType === "percentage" + ? Math.min( + (totalPrice * coupon.discountValue) / 100, + coupon.maxValue || Infinity + ) + : Math.min(coupon.discountValue, coupon.maxValue || totalPrice)), + 0 + ) || 0, + [selectedCoupons, totalPrice] + ); + + const finalTotal = totalPrice - discountAmount; + + const deliveryCharge = useMemo(() => { + const threshold = isFlashDelivery + ? constsData?.flashFreeDeliveryThreshold + : constsData?.freeDeliveryThreshold; + const charge = isFlashDelivery + ? constsData?.flashDeliveryCharge + : constsData?.deliveryCharge; + return finalTotal < threshold ? charge : 0; + }, [finalTotal, constsData, isFlashDelivery]); + + const finalTotalWithDelivery = finalTotal + deliveryCharge; + + + + + return ( + + + {/* Checkout Type Header */} + + + router.back()} + style={tw`p-2 -ml-2 mr-1`} + activeOpacity={0.7} + > + + + + + {isFlashDelivery ? "Flash Delivery Checkout" : "Scheduled Delivery Checkout"} + + + + + + + + + + + + + setShowAddAddress(false)}> + { + setShowAddAddress(false); + queryClient.invalidateQueries(); + }} + /> + + + + ); +}; + +export default CheckoutPage; \ No newline at end of file diff --git a/apps/user-ui/components/floating-cart-bar.tsx b/apps/user-ui/components/floating-cart-bar.tsx new file mode 100644 index 0000000..914d84e --- /dev/null +++ b/apps/user-ui/components/floating-cart-bar.tsx @@ -0,0 +1,343 @@ +import React, { useState, useEffect } from "react"; +import { View, ScrollView, Dimensions, Alert } from "react-native"; +import { Image } from 'expo-image'; +import { useRouter } from "expo-router"; +import MaterialIcons from "@expo/vector-icons/MaterialIcons"; +import { + StorageServiceCasual, + tw, + MyText, + MyTouchableOpacity, + MiniQuantifier, + BottomDropdown, + BottomDialog, + theme, + updateStatusBarColor, +} from "common-ui"; +import { trpc } from "@/src/trpc-client"; +import { + useGetCart, + useUpdateCartItem, + useRemoveFromCart, + useAddToCart, + type CartType, +} from "@/hooks/cart-query-hooks"; +import { useGetEssentialConsts } from "@/src/api-hooks/essential-consts.api"; +import { useProductSlotIdentifier } from "@/hooks/useProductSlotIdentifier"; +import dayjs from "dayjs"; +import { LinearGradient } from "expo-linear-gradient"; + +const { height: screenHeight } = Dimensions.get("window"); + +interface FloatingCartBarProps { + isFlashDelivery?: boolean; + isExpanded?: boolean; + setIsExpanded?: (value: boolean) => void; +} + +const FloatingCartBar: React.FC = ({ + isFlashDelivery = false, + isExpanded: controlledIsExpanded, + setIsExpanded: controlledSetIsExpanded, +}) => { + const cartBarColor = isFlashDelivery ? '#f81260' : theme.colors.brand600; + const cartBarBorderColor = isFlashDelivery ? '#e11d48' : theme.colors.brand500; + const router = useRouter(); + const [localIsExpanded, setLocalIsExpanded] = useState(false); + const [quantities, setQuantities] = useState>({}); + const cartType: CartType = isFlashDelivery ? "flash" : "regular"; + + const isExpanded = controlledIsExpanded ?? localIsExpanded; + const setIsExpanded = controlledSetIsExpanded ?? setLocalIsExpanded; + const { data: cartData, refetch: refetchCart } = useGetCart({}, cartType); + const { data: constsData } = useGetEssentialConsts(); + const { data: slotsData } = trpc.user.slots.getSlotsWithProducts.useQuery(); + const { productSlotsMap } = useProductSlotIdentifier(); + const cartItems = cartData?.items || []; + const itemCount = cartItems.length; + + const updateCartItem = useUpdateCartItem({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }, cartType); + const removeFromCart = useRemoveFromCart({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }, cartType); + const { addToCart = () => { } } = useAddToCart({ + showSuccessAlert: false, + showErrorAlert: false, + refetchCart: true, + }, cartType) || {}; + + useEffect(() => { + const initial: Record = {}; + cartItems.forEach((item) => { + initial[item.id] = item.quantity; + }); + setQuantities(initial); + }, [cartData]); + + useEffect(() => { + if (!cartItems.length || !slotsData?.slots || !productSlotsMap) return; + + const itemsToUpdate = cartItems.filter(item => { + if (!item.slotId) return true; // No slotId + const slotExists = slotsData.slots.some(slot => slot.id === item.slotId); + return !slotExists; // Slot doesn't exist + }); + + itemsToUpdate.forEach((item) => { + + const availableSlots = productSlotsMap.get(item.productId) || []; + if (availableSlots.length > 0 && !isFlashDelivery) { // don't bother updating slot for flash delivery + const nearestSlotId = availableSlots[0]; + removeFromCart.mutate({ itemId: item.id }); + addToCart(item.productId, item.quantity, nearestSlotId); + } + }); + }, []); + + const firstItem = cartItems[0]; + const expandedHeight = screenHeight * 0.7; + + // Calculate total cart value and free delivery info + const totalCartValue = cartItems.reduce( + (sum, item) => { + const price = isFlashDelivery ? (item.product.flashPrice ?? item.product.price) : item.product.price; + return sum + price * item.quantity; + }, + 0 + ); + const freeDeliveryThreshold = isFlashDelivery + ? constsData?.flashFreeDeliveryThreshold + : constsData?.freeDeliveryThreshold; + const remainingForFreeDelivery = Math.max( + 0, + freeDeliveryThreshold - totalCartValue + ); + + return ( + <> + + {!isExpanded && ( + // --- Collapsed View --- + itemCount > 0 && setIsExpanded(true)} + activeOpacity={0.9} + > + + + + + + + {itemCount === 0 ? (isFlashDelivery ? "No Flash Items" : "No Items In Cart") : ( + <> + + ₹{totalCartValue} + + {` • ${itemCount} ${itemCount === 1 ? "Item" : "Items"}`} + + )} + + {itemCount > 0 && } + + + {remainingForFreeDelivery > 0 ? ( + + ₹{remainingForFreeDelivery} more for FREE Delivery + + ) : itemCount > 0 ? ( + + + + Free Delivery Unlocked + + + ) : ( + Shop for ₹{freeDeliveryThreshold}+ for free shipping + )} + + + + router.push( + isFlashDelivery + ? "/(drawer)/(tabs)/flash-delivery/(cart)/cart" + : "/(drawer)/(tabs)/home/cart" + )} + > + Go to Cart + + + )} + + setIsExpanded(false)} enableDismiss={true}> + + {/* Header */} + + + + Your Cart + + + {itemCount} Items + + + setIsExpanded(false)} + > + + + + + {/* Progress Bar Header */} + {remainingForFreeDelivery > 0 && ( + + + + Free Delivery Progress + {Math.round((totalCartValue / freeDeliveryThreshold) * 100)}% + + + + + + + Needed + +₹{remainingForFreeDelivery} + + + )} + + {/* Items List */} + + {cartItems.map((item, index) => ( + + + + + + + + + {item.product.name.length > 30 ? item.product.name.substring(0, 30) + '...' : item.product.name} + + { + if (value === 0) { + removeFromCart.mutate({ itemId: item.id }); + } else { + setQuantities((prev) => ({ ...prev, [item.id]: value })); + updateCartItem.mutate({ itemId: item.id, quantity: value }); + } + }} + step={item.product.incrementStep} + showUnits={true} + unit={item.product?.unit} + /> + + + {item.slotId && slotsData && productSlotsMap.has(item.productId) && ( + { + const slot = slotsData.slots.find(s => s.id === slotId); + return { + label: slot ? dayjs(slot.deliveryTime).format("ddd, MMM DD • h:mm A") : "N/A", + value: slotId, + }; + })} + onValueChange={(val) => { + const newSlot = slotsData.slots.find(s => s.id === val); + Alert.alert("Delivery Updated", `Scheduled for ${dayjs(newSlot?.deliveryTime).format("MMM DD, h:mm A")}`); + }} + triggerComponent={({ onPress, displayText }) => ( + + + + {displayText} + + + + )} + /> + )} + + ₹{(isFlashDelivery ? (item.product.flashPrice ?? item.product.price) : item.product.price) * item.quantity} + + + + + + + + {index < cartItems.length - 1 && ( + + )} + + ))} + + + {/* Fancy Footer */} + + + + Subtotal + ₹{totalCartValue} + + {remainingForFreeDelivery === 0 && ( + + + Free Delivery + + )} + + + router.push( + isFlashDelivery + ? "/(drawer)/(tabs)/flash-delivery/(cart)/cart" + : "/(drawer)/(tabs)/home/cart" + )} + activeOpacity={0.9} + > + + + Go to cart + + + + + + + + + ); +}; + +export default FloatingCartBar; diff --git a/apps/user-ui/components/icons/CartIcon.tsx b/apps/user-ui/components/icons/CartIcon.tsx new file mode 100644 index 0000000..aaa878c --- /dev/null +++ b/apps/user-ui/components/icons/CartIcon.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import Svg, { Path } from 'react-native-svg'; + +interface CartIconProps { + focused: boolean; + size: number; + color: string; +} + +const CartIcon: React.FC = ({ focused, size, color }) => { + if (focused) { + // Focused state SVG (cart without handle) + return ( + + + + + + ); + } else { + // Unfocused state SVG (full cart) + return ( + + + + + + ); + } +}; + +export default CartIcon; \ No newline at end of file diff --git a/apps/user-ui/components/icons/HomeIcon.tsx b/apps/user-ui/components/icons/HomeIcon.tsx new file mode 100644 index 0000000..b2629ec --- /dev/null +++ b/apps/user-ui/components/icons/HomeIcon.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import Svg, { Path } from 'react-native-svg'; + +interface HomeIconProps { + focused: boolean; + size: number; + color: string; +} + +const HomeIcon: React.FC = ({ focused, size, color }) => { + if (focused) { + // Selected state SVG (filled house) + return ( + + + + ); + } else { + // Unselected state SVG (outlined house) + return ( + + + + ); + } +}; + +export default HomeIcon; \ No newline at end of file diff --git a/apps/user-ui/components/icons/MeIcon.tsx b/apps/user-ui/components/icons/MeIcon.tsx new file mode 100644 index 0000000..cf9a3c0 --- /dev/null +++ b/apps/user-ui/components/icons/MeIcon.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import Svg, { Path } from 'react-native-svg'; + +interface MeIconProps { + focused: boolean; + size: number; + color: string; +} + +const MeIcon: React.FC = ({ focused, size, color }) => { + if (focused) { + // Selected state SVG (filled user) + return ( + + + + + ); + } else { + // Unselected state SVG (outlined user) + return ( + + + + + ); + } +}; + +export default MeIcon; \ No newline at end of file diff --git a/apps/user-ui/components/icons/OrderAgainIcon.tsx b/apps/user-ui/components/icons/OrderAgainIcon.tsx new file mode 100644 index 0000000..8f2e3fb --- /dev/null +++ b/apps/user-ui/components/icons/OrderAgainIcon.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Svg, { Path } from 'react-native-svg'; + +interface OrderAgainIconProps { + focused: boolean; + size: number; + color: string; +} + +const OrderAgainIcon: React.FC = ({ focused, size, color }) => { + const iconColor = focused ? '#2563EB' : '#2D264B'; // Use focused color when focused, original color when not + + return ( + + + + + ); +}; + +export default OrderAgainIcon; \ No newline at end of file diff --git a/apps/user-ui/components/icons/StoresIcon.tsx b/apps/user-ui/components/icons/StoresIcon.tsx new file mode 100644 index 0000000..575a631 --- /dev/null +++ b/apps/user-ui/components/icons/StoresIcon.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import Svg, { Path } from 'react-native-svg'; + +interface StoresIconProps { + focused: boolean; + size: number; + color: string; +} + +const StoresIcon: React.FC = ({ focused, size, color }) => { + if (focused) { + // Selected state SVG (filled squares) + return ( + + + + + + + ); + } else { + // Unselected state SVG (outlined squares) + return ( + + + + + + + ); + } +}; + +export default StoresIcon; \ No newline at end of file diff --git a/apps/user-ui/components/registration-form.tsx b/apps/user-ui/components/registration-form.tsx new file mode 100644 index 0000000..3f98b1f --- /dev/null +++ b/apps/user-ui/components/registration-form.tsx @@ -0,0 +1,485 @@ +import React, { useState } from "react"; +import { View, TextInput, Alert } from "react-native"; +import { useForm, Controller } from "react-hook-form"; + +import { MyButton, MyText, MyTextInput, ProfileImage, tw, BottomDialog } from "common-ui"; +import { trpc } from "@/src/trpc-client"; + +interface RegisterFormInputs { + name: string; + email: string; + mobile: string; + password: string; + confirmPassword: string; + termsAccepted: boolean; + profileImageUri?: string; +} + +interface RegistrationFormProps { + onSubmit: (data: FormData) => void | Promise; + isLoading?: boolean; + initialValues?: Partial; + isEdit?: boolean; +} + +function RegistrationForm({ onSubmit, isLoading = false, initialValues, isEdit = false }: RegistrationFormProps) { + const [profileImageUri, setProfileImageUri] = useState(); + const [profileImageFile, setProfileImageFile] = useState(); + const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState(false); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const updatePasswordMutation = trpc.user.auth.updatePassword.useMutation(); + + // Set initial profile image URI for edit mode + React.useEffect(() => { + if (isEdit && initialValues?.profileImageUri) { + setProfileImageUri(initialValues.profileImageUri); + } + }, [isEdit, initialValues?.profileImageUri]); + + const { + control, + handleSubmit, + formState: { errors }, + setError, + clearErrors, + watch, + } = useForm({ + defaultValues: { + name: "", + email: "", + mobile: "", + password: "", + confirmPassword: "", + termsAccepted: false, + ...initialValues, + }, + }); + + + + const validateMobile = (mobile: string): boolean => { + // Remove all non-digit characters + const cleanMobile = mobile.replace(/\D/g, ''); + // Check if it's a valid Indian mobile number (10 digits, starts with 6-9) + return cleanMobile.length === 10 && /^[6-9]/.test(cleanMobile); + }; + + const validateEmail = (email: string): boolean => { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return emailRegex.test(email); + }; + + const handleFormSubmit = async (data: RegisterFormInputs) => { + clearErrors(); + + // Validate name + if (!data.name.trim()) { + setError("name", { + type: "manual", + message: "Name is required", + }); + return; + } + + if (data.name.trim().length < 2) { + setError("name", { + type: "manual", + message: "Name must be at least 2 characters", + }); + return; + } + + // Validate email + if (!data.email.trim()) { + setError("email", { + type: "manual", + message: "Email is required", + }); + return; + } + + if (!validateEmail(data.email)) { + setError("email", { + type: "manual", + message: "Please enter a valid email address", + }); + return; + } + + // Validate mobile number + if (!data.mobile.trim()) { + setError("mobile", { + type: "manual", + message: "Mobile number is required", + }); + return; + } + + if (!validateMobile(data.mobile)) { + setError("mobile", { + type: "manual", + message: "Please enter a valid 10-digit mobile number", + }); + return; + } + + // Validate password (only in registration mode) + if (!isEdit) { + if (!data.password) { + setError("password", { + type: "manual", + message: "Password is required", + }); + return; + } + + if (data.password.length < 6) { + setError("password", { + type: "manual", + message: "Password must be at least 6 characters", + }); + return; + } + + // Validate confirm password + if (data.password !== data.confirmPassword) { + setError("confirmPassword", { + type: "manual", + message: "Passwords do not match", + }); + return; + } + } + + // Validate terms (only in registration mode) + if (!isEdit && !data.termsAccepted) { + setError("termsAccepted", { + type: "manual", + message: "You must accept the terms and conditions", + }); + return; + } + + // Create FormData + const formData = new FormData(); + formData.append('name', data.name.trim()); + formData.append('email', data.email.trim().toLowerCase()); + formData.append('mobile', data.mobile.replace(/\D/g, '')); + + // Only include password if provided (for edit mode) + if (data.password) { + formData.append('password', data.password); + } + + if (profileImageFile) { + + formData.append('profileImage', { + uri: profileImageFile.uri, + type: profileImageFile.mimeType || 'image/jpeg', + name: profileImageFile.name || 'profile.jpg', + } as any); + } + + await onSubmit(formData); + }; + + const handleUpdatePassword = async () => { + if (password !== confirmPassword) { + Alert.alert('Error', 'Passwords do not match'); + return; + } + if (password.length < 6) { + Alert.alert('Error', 'Password must be at least 6 characters'); + return; + } + + try { + await updatePasswordMutation.mutateAsync({ password }); + Alert.alert('Success', 'Password updated successfully'); + setIsPasswordDialogOpen(false); + setPassword(''); + setConfirmPassword(''); + } catch (error: any) { + Alert.alert('Error', error.message || 'Failed to update password'); + } + }; + + return ( + <> + + + { + setProfileImageUri(uri); + setProfileImageFile(file); + }} + size={100} + editable={true} + /> + + ( + + + + )} + /> + {errors.name && ( + + {errors.name.message} + + )} + + ( + + + + )} + /> + {errors.email && ( + + {errors.email.message} + + )} + + ( + + { + // Format mobile number as user types + const clean = text.replace(/\D/g, ''); + if (clean.length <= 10) { + onChange(clean); + } + }} + onBlur={onBlur} + keyboardType="phone-pad" + maxLength={10} + style={tw`bg-gray-50`} + error={!!errors.mobile} + /> + + )} + /> + {errors.mobile && ( + + {errors.mobile.message} + + )} + + {!isEdit && ( + <> + ( + + + + )} + /> + {errors.password && ( + + {errors.password.message} + + )} + + ( + + + + )} + /> + {errors.confirmPassword && ( + + {errors.confirmPassword.message} + + )} + + ( + + onChange(!value)} + > + + {value && ( + + ✓ + + )} + + + I agree to the{" "} + + Terms and Conditions + {" "} + and{" "} + + Privacy Policy + + + + + )} + /> + {errors.termsAccepted && ( + + {errors.termsAccepted.message} + + )} + + )} + + + {isLoading ? (isEdit ? "Updating..." : "Creating Account...") : (isEdit ? "Update Profile" : "Create Account")} + + + {isEdit && ( + + setIsPasswordDialogOpen(true)} + fillColor="brand500" + textColor="white1" + fullWidth + /> + + )} + + + {isEdit && ( + setIsPasswordDialogOpen(false)}> + + + Update Password + + + + + setIsPasswordDialogOpen(false)} + fillColor="gray1" + textColor="white1" + /> + + + + + )} + + ); +} + +export default RegistrationForm; \ No newline at end of file diff --git a/apps/user-ui/components/stores/flashNavigationStore.ts b/apps/user-ui/components/stores/flashNavigationStore.ts new file mode 100644 index 0000000..17e2e95 --- /dev/null +++ b/apps/user-ui/components/stores/flashNavigationStore.ts @@ -0,0 +1,13 @@ +import { create } from 'zustand'; + +interface FlashNavigationState { + shouldNavigateToCart: boolean; + setShouldNavigateToCart: (value: boolean) => void; + reset: () => void; +} + +export const useFlashNavigationStore = create((set) => ({ + shouldNavigateToCart: false, + setShouldNavigateToCart: (value) => set({ shouldNavigateToCart: value }), + reset: () => set({ shouldNavigateToCart: false }), +})); diff --git a/apps/user-ui/components/stores/slotStore.ts b/apps/user-ui/components/stores/slotStore.ts new file mode 100644 index 0000000..8ba258a --- /dev/null +++ b/apps/user-ui/components/stores/slotStore.ts @@ -0,0 +1,15 @@ +import { create } from 'zustand'; + +interface SlotStore { + slotId?: number; + storeId?: number; + setSlotId: (id?: number) => void; + setStoreId: (id?: number) => void; +} + +export const useSlotStore = create((set) => ({ + slotId: undefined, + storeId: undefined, + setSlotId: (slotId) => set({ slotId }), + setStoreId: (storeId) => set({ storeId }), +})); \ No newline at end of file diff --git a/apps/user-ui/components/ui/IconSymbol.ios.tsx b/apps/user-ui/components/ui/IconSymbol.ios.tsx new file mode 100755 index 0000000..9177f4d --- /dev/null +++ b/apps/user-ui/components/ui/IconSymbol.ios.tsx @@ -0,0 +1,32 @@ +import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols'; +import { StyleProp, ViewStyle } from 'react-native'; + +export function IconSymbol({ + name, + size = 24, + color, + style, + weight = 'regular', +}: { + name: SymbolViewProps['name']; + size?: number; + color: string; + style?: StyleProp; + weight?: SymbolWeight; +}) { + return ( + + ); +} diff --git a/apps/user-ui/components/ui/IconSymbol.tsx b/apps/user-ui/components/ui/IconSymbol.tsx new file mode 100755 index 0000000..b7ece6b --- /dev/null +++ b/apps/user-ui/components/ui/IconSymbol.tsx @@ -0,0 +1,41 @@ +// Fallback for using MaterialIcons on Android and web. + +import MaterialIcons from '@expo/vector-icons/MaterialIcons'; +import { SymbolWeight, SymbolViewProps } from 'expo-symbols'; +import { ComponentProps } from 'react'; +import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native'; + +type IconMapping = Record['name']>; +type IconSymbolName = keyof typeof MAPPING; + +/** + * Add your SF Symbols to Material Icons mappings here. + * - see Material Icons in the [Icons Directory](https://icons.expo.fyi). + * - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app. + */ +const MAPPING = { + 'house.fill': 'home', + 'paperplane.fill': 'send', + 'chevron.left.forwardslash.chevron.right': 'code', + 'chevron.right': 'chevron-right', +} as IconMapping; + +/** + * An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web. + * This ensures a consistent look across platforms, and optimal resource usage. + * Icon `name`s are based on SF Symbols and require manual mapping to Material Icons. + */ +export function IconSymbol({ + name, + size = 24, + color, + style, +}: { + name: IconSymbolName; + size?: number; + color: string | OpaqueColorValue; + style?: StyleProp; + weight?: SymbolWeight; +}) { + return ; +} diff --git a/apps/user-ui/components/ui/TabBarBackground.ios.tsx b/apps/user-ui/components/ui/TabBarBackground.ios.tsx new file mode 100755 index 0000000..495b2d4 --- /dev/null +++ b/apps/user-ui/components/ui/TabBarBackground.ios.tsx @@ -0,0 +1,19 @@ +import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs'; +import { BlurView } from 'expo-blur'; +import { StyleSheet } from 'react-native'; + +export default function BlurTabBarBackground() { + return ( + + ); +} + +export function useBottomTabOverflow() { + return useBottomTabBarHeight(); +} diff --git a/apps/user-ui/components/ui/TabBarBackground.tsx b/apps/user-ui/components/ui/TabBarBackground.tsx new file mode 100755 index 0000000..70d1c3c --- /dev/null +++ b/apps/user-ui/components/ui/TabBarBackground.tsx @@ -0,0 +1,6 @@ +// This is a shim for web and Android where the tab bar is generally opaque. +export default undefined; + +export function useBottomTabOverflow() { + return 0; +} diff --git a/apps/user-ui/constants/Colors.ts b/apps/user-ui/constants/Colors.ts new file mode 100755 index 0000000..14e6784 --- /dev/null +++ b/apps/user-ui/constants/Colors.ts @@ -0,0 +1,26 @@ +/** + * Below are the colors that are used in the app. The colors are defined in the light and dark mode. + * There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc. + */ + +const tintColorLight = '#0a7ea4'; +const tintColorDark = '#fff'; + +export const Colors = { + light: { + text: '#11181C', + background: '#fff', + tint: tintColorLight, + icon: '#687076', + tabIconDefault: '#687076', + tabIconSelected: tintColorLight, + }, + dark: { + text: '#ECEDEE', + background: '#151718', + tint: tintColorDark, + icon: '#9BA1A6', + tabIconDefault: '#9BA1A6', + tabIconSelected: tintColorDark, + }, +}; diff --git a/apps/user-ui/eas.json b/apps/user-ui/eas.json new file mode 100755 index 0000000..a9e57d3 --- /dev/null +++ b/apps/user-ui/eas.json @@ -0,0 +1,24 @@ +{ + "cli": { + "version": ">= 16.17.4", + "appVersionSource": "remote" + }, + "build": { + "development": { + "developmentClient": true, + "distribution": "internal", + "channel": "development" + }, + "preview": { + "channel": "preview", + "autoIncrement": true + }, + "production": { + "autoIncrement": true, + "channel": "production" + } + }, + "submit": { + "production": {} + } +} diff --git a/apps/user-ui/eslint.config.js b/apps/user-ui/eslint.config.js new file mode 100755 index 0000000..5025da6 --- /dev/null +++ b/apps/user-ui/eslint.config.js @@ -0,0 +1,10 @@ +// https://docs.expo.dev/guides/using-eslint/ +const { defineConfig } = require('eslint/config'); +const expoConfig = require('eslint-config-expo/flat'); + +module.exports = defineConfig([ + expoConfig, + { + ignores: ['dist/*'], + }, +]); diff --git a/apps/user-ui/hooks/cart-query-hooks.tsx b/apps/user-ui/hooks/cart-query-hooks.tsx new file mode 100644 index 0000000..8480897 --- /dev/null +++ b/apps/user-ui/hooks/cart-query-hooks.tsx @@ -0,0 +1,501 @@ +import { trpc } from '@/src/trpc-client'; +import { Alert } from 'react-native'; +import { useState, useEffect } from 'react'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { StorageServiceCasual } from 'common-ui/src/services/StorageServiceCasual'; + +// Cart type definition +export type CartType = "regular" | "flash"; + +// const CART_MODE: 'remote' | 'local' = 'remote'; +const CART_MODE: 'remote' | 'local' = 'local'; + +const getCartStorageKey = (cartType: CartType = "regular"): string => { + return cartType === "flash" ? "flash_cart_items" : "cart_items"; +}; + +interface LocalCartItem { + id: number; + productId: number; + quantity: number; + slotId: number; + addedAt: string; +} + +interface ProductSummary { + id: number; + name: string; + price: number; + unit: string; + isOutOfStock: boolean; + images: string[]; + incrementStep?: number; +} + +interface CartItem { + id: number; + productId: number; + quantity: number; + addedAt: string; + product: ProductSummary; + subtotal: number; +} + +const getLocalCart = async (cartType: CartType = "regular"): Promise => { + const key = getCartStorageKey(cartType); + const data = await StorageServiceCasual.getItem(key); + return data ? JSON.parse(data) : []; +}; + +const saveLocalCart = async (items: LocalCartItem[], cartType: CartType = "regular"): Promise => { + const key = getCartStorageKey(cartType); + await StorageServiceCasual.setItem(key, JSON.stringify(items)); + const fetchedItems = await getLocalCart(cartType); + +}; + +const getNextCartItemId = (items: LocalCartItem[]): number => { + const maxId = items.length > 0 ? Math.max(...items.map(item => item.id)) : 0; + return maxId + 1; +}; + +const addToLocalCart = async (productId: number, quantity: number, slotId?: number, cartType: CartType = "regular"): Promise => { + + const items = await getLocalCart(cartType); + const existingIndex = items.findIndex(item => item.productId === productId); + + if (existingIndex >= 0) { + items[existingIndex].quantity += quantity; + if (slotId !== undefined) { + items[existingIndex].slotId = slotId; + } + } else { + const newId = getNextCartItemId(items); + const cartItem = { + id: newId, + productId, + quantity, + slotId: slotId ?? 0, // Default to 0 if not provided + addedAt: new Date().toISOString(), + } + + items.push(cartItem); + } + + await saveLocalCart(items, cartType); + return items; +}; + +const updateLocalCartItem = async (itemId: number, quantity: number, cartType: CartType = "regular"): Promise => { + const items = await getLocalCart(cartType); + const item = items.find(i => i.id === itemId); + if (item) { + item.quantity = quantity; + await saveLocalCart(items, cartType); + } + return items; +}; + +const removeFromLocalCart = async (itemId: number, cartType: CartType = "regular"): Promise => { + const items = await getLocalCart(cartType); + const filtered = items.filter(i => i.id !== itemId); + await saveLocalCart(filtered, cartType); + return filtered; +}; + +const clearLocalCart = async (cartType: CartType = "regular"): Promise => { + const key = getCartStorageKey(cartType); + await StorageServiceCasual.setItem(key, JSON.stringify([])); +}; + +export function useGetCart(options?: { + refetchOnWindowFocus?: boolean; + enabled?: boolean; +}, cartType: CartType = "regular") { + if (CART_MODE === 'remote') { + const query = trpc.user.cart.getCart.useQuery(undefined, { + refetchOnWindowFocus: options?.refetchOnWindowFocus ?? true, + enabled: options?.enabled ?? true, + ...options + }); + + return { + // Original tRPC returns + data: query.data, + isLoading: query.isLoading, + error: query.error, + refetch: query.refetch, + + // Computed properties + cartItems: query.data?.items || [], + totalItems: query.data?.totalItems || 0, + totalPrice: query.data?.totalAmount || 0, + + // Helper methods + isEmpty: !query.data?.items?.length, + hasItems: Boolean(query.data?.items?.length), + }; + } else { + + const { data: products } = trpc.user.product.getAllProductsSummary.useQuery(); + const query = useQuery({ + queryKey: [`local-cart-${cartType}`], + queryFn: async () => { + + const cartItems = await getLocalCart(cartType); + + // const productMap = Object.fromEntries(products?.map((p: ProductSummary) => [p.id, p]) || []); + const productMap = Object.fromEntries(products?.map((p) => [p.id, p]) || []); + + const items: CartItem[] = cartItems.map(cartItem => { + const product = productMap[cartItem.productId]; + + if (!product) return null as any; + return { + id: cartItem.id, + productId: cartItem.productId, + quantity: cartItem.quantity, + addedAt: cartItem.addedAt, + product, + incrementStep: product.incrementStep, + subtotal: Number(product.price) * cartItem.quantity, + slotId: cartItem.slotId, + }; + }).filter(Boolean) as CartItem[]; + const totalAmount = items.reduce((sum, item) => sum + item.subtotal, 0); + + return { + items, + totalItems: items.length, + totalAmount, + }; + }, + refetchOnWindowFocus: options?.refetchOnWindowFocus ?? true, + enabled: (options?.enabled ?? true) && !!products, + }); + + return { + data: query.data, + isLoading: query.isLoading, + error: query.error, + refetch: query.refetch, + + // Computed properties + cartItems: query.data?.items || [], + totalItems: query.data?.totalItems || 0, + totalPrice: query.data?.totalAmount || 0, + + // Helper methods + isEmpty: !query.data?.items?.length, + hasItems: Boolean(query.data?.items?.length), + }; + } +} + +interface UseAddToCartReturn { + mutate: any; + mutateAsync: any; + isLoading: boolean; + error: any; + data: any; + addToCart: (productId: number, quantity?: number, slotId?: number, onSettled?: (data: any, error: any) => void) => void; + addToCartAsync: (productId: number, quantity?: number, slotId?: number) => Promise; +} + +export function useAddToCart(options?: { + onSuccess?: (data: any, variables: any) => void; + onError?: (error: any) => void; + showSuccessAlert?: boolean; + showErrorAlert?: boolean; + refetchCart?: boolean; +}, cartType: CartType = "regular"): UseAddToCartReturn { + if (CART_MODE === 'remote') { + const utils = trpc.useUtils(); + + const mutation = trpc.user.cart.addToCart.useMutation({ + onSuccess: (data, variables) => { + // Default success handling + if (options?.showSuccessAlert !== false) { + Alert.alert("Success", "Item added to cart!"); + } + + // Auto-refetch cart if requested + if (options?.refetchCart) { + utils.user.cart.getCart.invalidate(); + } + + // Custom success callback + options?.onSuccess?.(data, variables); + }, + onError: (error) => { + // Default error handling + if (options?.showErrorAlert !== false) { + Alert.alert("Error", error.message || "Failed to add item to cart"); + } + + // Custom error callback + options?.onError?.(error); + }, + }) as any; + + const addToCart = (productId: number, quantity = 1, slotId?: number, onSettled?: (data: any, error: any) => void) => { + + if (slotId == null) { + throw new Error('slotId is required for adding to cart'); + } + return mutation.mutate({ productId, quantity, slotId }, { + onSettled: (data: any, error: any) => { + onSettled?.(data, error); + } + }); + }; + + return { + // Original mutation returns + mutate: mutation.mutate, + mutateAsync: mutation.mutateAsync, + isLoading: mutation.isPending, + error: mutation.error, + data: mutation.data, + + addToCart, + + addToCartAsync: (productId: number, quantity = 1, slotId?: number) => { + if (slotId == null) { + throw new Error('slotId is required for adding to cart'); + } + return mutation.mutateAsync({ productId, quantity, slotId }); + }, + }; + } else { + + const queryClient = useQueryClient(); + + const mutation = useMutation({ + mutationFn: async ({ productId, quantity, slotId }: { productId: number, quantity: number, slotId: number }) => { + return await addToLocalCart(productId, quantity, slotId, cartType); + }, + onSuccess: (data, variables) => { + queryClient.invalidateQueries({ queryKey: [`local-cart-${cartType}`] }); + if (options?.showSuccessAlert !== false) { + Alert.alert("Success", "Item added to cart!"); + } + options?.onSuccess?.(data, variables); + }, + onError: (error) => { + if (options?.showErrorAlert !== false) { + Alert.alert("Error", error.message || "Failed to add item to cart"); + } + options?.onError?.(error); + }, + }); + + const addToCart = (productId: number, quantity = 1, slotId?: number, onSettled?: (data: any, error: any) => void) => { + + if (slotId == null) { + throw new Error('slotId is required for adding to cart'); + } + return mutation.mutate({ productId, quantity, slotId }, { + onSettled: (data: any, error: any) => { + onSettled?.(data, error); + } + }); + }; + + return { + mutate: mutation.mutate, + mutateAsync: mutation.mutateAsync, + isLoading: mutation.isPending, + error: mutation.error, + data: mutation.data, + addToCart, + addToCartAsync: (productId: number, quantity = 1, slotId?: number) => { + if (slotId == null) { + throw new Error('slotId is required for adding to cart'); + } + return mutation.mutateAsync({ productId, quantity, slotId }); + }, + }; + } +} + +export function useUpdateCartItem(options?: { + onSuccess?: (data: any, variables: any) => void; + onError?: (error: any) => void; + showSuccessAlert?: boolean; + showErrorAlert?: boolean; + refetchCart?: boolean; +}, cartType: CartType = "regular") { + if (CART_MODE === 'remote') { + const utils = trpc.useUtils(); + + const mutation = trpc.user.cart.updateCartItem.useMutation({ + onSuccess: (data, variables) => { + // Default success handling + if (options?.showSuccessAlert !== false) { + Alert.alert("Success", "Cart item updated!"); + } + + // Auto-refetch cart if requested + if (options?.refetchCart) { + utils.user.cart.getCart.invalidate(); + } + + // Custom success callback + options?.onSuccess?.(data, variables); + }, + onError: (error) => { + // Default error handling + if (options?.showErrorAlert !== false) { + Alert.alert("Error", error.message || "Failed to update cart item"); + } + + // Custom error callback + options?.onError?.(error); + }, + }); + + return { + // Original mutation returns + mutate: mutation.mutate, + mutateAsync: mutation.mutateAsync, + isLoading: mutation.isPending, + error: mutation.error, + data: mutation.data, + + // Helper methods + updateCartItem: (itemId: number, quantity: number) => + mutation.mutate({ itemId, quantity }), + + updateCartItemAsync: (itemId: number, quantity: number) => + mutation.mutateAsync({ itemId, quantity }), + }; + } else { + const queryClient = useQueryClient(); + + const mutation = useMutation({ + mutationFn: async ({ itemId, quantity }: { itemId: number, quantity: number }) => { + return await updateLocalCartItem(itemId, quantity, cartType); + }, + onSuccess: (data, variables) => { + queryClient.invalidateQueries({ queryKey: [`local-cart-${cartType}`] }); + if (options?.showSuccessAlert !== false) { + Alert.alert("Success", "Cart item updated!"); + } + options?.onSuccess?.(data, variables); + }, + onError: (error) => { + if (options?.showErrorAlert !== false) { + Alert.alert("Error", error.message || "Failed to update cart item"); + } + options?.onError?.(error); + }, + }); + + return { + mutate: mutation.mutate, + mutateAsync: mutation.mutateAsync, + isLoading: mutation.isPending, + error: mutation.error, + data: mutation.data, + + updateCartItem: (itemId: number, quantity: number) => + mutation.mutate({ itemId, quantity }), + + updateCartItemAsync: (itemId: number, quantity: number) => + mutation.mutateAsync({ itemId, quantity }), + }; + } +} + +export function useRemoveFromCart(options?: { + onSuccess?: (data: any, variables: any) => void; + onError?: (error: any) => void; + showSuccessAlert?: boolean; + showErrorAlert?: boolean; + refetchCart?: boolean; +}, cartType: CartType = "regular") { + if (CART_MODE === 'remote') { + const utils = trpc.useUtils(); + + const mutation = trpc.user.cart.removeFromCart.useMutation({ + onSuccess: (data, variables) => { + // Default success handling + if (options?.showSuccessAlert !== false) { + Alert.alert("Success", "Item removed from cart!"); + } + + // Auto-refetch cart if requested + if (options?.refetchCart) { + utils.user.cart.getCart.invalidate(); + } + + // Custom success callback + options?.onSuccess?.(data, variables); + }, + onError: (error) => { + // Default error handling + if (options?.showErrorAlert !== false) { + Alert.alert("Error", error.message || "Failed to remove item from cart"); + } + + // Custom error callback + options?.onError?.(error); + }, + }); + + return { + // Original mutation returns + mutate: mutation.mutate, + mutateAsync: mutation.mutateAsync, + isLoading: mutation.isPending, + error: mutation.error, + data: mutation.data, + + // Helper methods + removeFromCart: (itemId: number) => + mutation.mutate({ itemId }), + + removeFromCartAsync: (itemId: number) => + mutation.mutateAsync({ itemId }), + }; + } else { + const queryClient = useQueryClient(); + + const mutation = useMutation({ + mutationFn: async ({ itemId }: { itemId: number }) => { + return await removeFromLocalCart(itemId, cartType); + }, + onSuccess: (data, variables) => { + queryClient.invalidateQueries({ queryKey: [`local-cart-${cartType}`] }); + if (options?.showSuccessAlert !== false) { + Alert.alert("Success", "Item removed from cart!"); + } + options?.onSuccess?.(data, variables); + }, + onError: (error) => { + if (options?.showErrorAlert !== false) { + Alert.alert("Error", error.message || "Failed to remove item from cart"); + } + options?.onError?.(error); + }, + }); + + return { + mutate: mutation.mutate, + mutateAsync: mutation.mutateAsync, + isLoading: mutation.isPending, + error: mutation.error, + data: mutation.data, + + removeFromCart: (itemId: number) => + mutation.mutate({ itemId }), + + removeFromCartAsync: (itemId: number) => + mutation.mutateAsync({ itemId }), + }; + } +} + +// Export clear cart function for direct use +export { clearLocalCart }; \ No newline at end of file diff --git a/apps/user-ui/hooks/useAuthenticatedRoute.ts b/apps/user-ui/hooks/useAuthenticatedRoute.ts new file mode 100644 index 0000000..d8e750d --- /dev/null +++ b/apps/user-ui/hooks/useAuthenticatedRoute.ts @@ -0,0 +1,55 @@ +import { useFocusEffect } from '@react-navigation/native'; +import { useRouter } from 'expo-router'; +import { useAuth } from '@/src/contexts/AuthContext'; +import { StorageServiceCasual } from 'common-ui'; +import constants from '@/src/constants'; + +interface AuthenticatedRouteOptions { + targetUrl?: string; + queryParams?: Record; +} + +interface RedirectState { + targetUrl: string; + queryParams: Record; + timestamp: number; +} + +export function useAuthenticatedRoute(options: AuthenticatedRouteOptions = {}) { + const { isAuthenticated, isLoading } = useAuth(); + const router = useRouter(); + + console.log({ops: options.queryParams}) + + useFocusEffect(() => { + // Don't redirect while auth is loading + if (isLoading) return; + + // If user is authenticated, no need to do anything + if (isAuthenticated) return; + + // User is not authenticated, store redirect state and navigate to login + const redirectState: RedirectState = { + targetUrl: options.targetUrl || '/', + queryParams: options.queryParams || {}, + timestamp: Date.now(), + }; + + // Store the redirect state + StorageServiceCasual.setItem(constants.AUTH_REDIRECT_KEY, JSON.stringify(redirectState)) + .then(() => { + // Navigate to login page (push to keep original route in stack) + router.push('/(auth)/login'); + }) + .catch((error) => { + console.error('Failed to store redirect state:', error); + // Still navigate to login even if storage fails + router.push('/(auth)/login'); + }); + }); + + return { + isAuthenticated, + isLoading, + }; +} \ No newline at end of file diff --git a/apps/user-ui/hooks/useColorScheme.ts b/apps/user-ui/hooks/useColorScheme.ts new file mode 100755 index 0000000..17e3c63 --- /dev/null +++ b/apps/user-ui/hooks/useColorScheme.ts @@ -0,0 +1 @@ +export { useColorScheme } from 'react-native'; diff --git a/apps/user-ui/hooks/useColorScheme.web.ts b/apps/user-ui/hooks/useColorScheme.web.ts new file mode 100755 index 0000000..7eb1c1b --- /dev/null +++ b/apps/user-ui/hooks/useColorScheme.web.ts @@ -0,0 +1,21 @@ +import { useEffect, useState } from 'react'; +import { useColorScheme as useRNColorScheme } from 'react-native'; + +/** + * To support static rendering, this value needs to be re-calculated on the client side for web + */ +export function useColorScheme() { + const [hasHydrated, setHasHydrated] = useState(false); + + useEffect(() => { + setHasHydrated(true); + }, []); + + const colorScheme = useRNColorScheme(); + + if (hasHydrated) { + return colorScheme; + } + + return 'light'; +} diff --git a/apps/user-ui/hooks/useCurrentUserId.ts b/apps/user-ui/hooks/useCurrentUserId.ts new file mode 100755 index 0000000..7f92190 --- /dev/null +++ b/apps/user-ui/hooks/useCurrentUserId.ts @@ -0,0 +1,13 @@ +import React, { useEffect, useState } from 'react'; +import { getCurrentUserId } from '@/utils/getCurrentUserId'; + +export function useCurrentUserId(): {userId:number|null, refetchUserId: () => void} { + const [userId, setUserId] = useState(null); + const refetchUserId = React.useCallback(() => { + getCurrentUserId().then(setUserId); + },[]) + useEffect(() => { + getCurrentUserId().then(setUserId); + }, []); + return {userId,refetchUserId}; +} diff --git a/apps/user-ui/hooks/useHideDrawerHeader.ts b/apps/user-ui/hooks/useHideDrawerHeader.ts new file mode 100755 index 0000000..c277ec2 --- /dev/null +++ b/apps/user-ui/hooks/useHideDrawerHeader.ts @@ -0,0 +1,26 @@ +import { useFocusEffect, useNavigation } from "expo-router"; +import React from "react"; + + +function useHideDrawerHeader() { + + const navigation = useNavigation(); + useFocusEffect(() => { + let drawerNav = navigation.getParent(); + const drawerNavList:any = []; + // Collect all parent navigators + while (drawerNav) { + drawerNavList.push(drawerNav); + drawerNav = drawerNav.getParent(); + } + + drawerNavList.at(-3)?.setOptions({ headerShown: false }); + + return () => { + drawerNavList.at(-3)?.setOptions({ headerShown: true }); + }; + }); + return null; +} + +export default useHideDrawerHeader; diff --git a/apps/user-ui/hooks/useJWT.ts b/apps/user-ui/hooks/useJWT.ts new file mode 100755 index 0000000..33e742b --- /dev/null +++ b/apps/user-ui/hooks/useJWT.ts @@ -0,0 +1,49 @@ +// import { StorageService } from '@/lib/StorageService'; +import {StorageService} from 'common-ui'; + +export const AUTH_TOKEN_KEY = 'authToken'; +export const ROLES_KEY = 'user_roles'; +export const USER_ID_KEY = 'userId'; + +export async function saveUserId(userId:string) { + await StorageService.setItem(USER_ID_KEY, userId); +} + +export async function getUserId() { + return await StorageService.getItem(USER_ID_KEY); +} + +export async function saveAuthToken(token: string) { + await StorageService.setItem(AUTH_TOKEN_KEY, token); +} + +export async function getAuthToken() { + return await StorageService.getItem(AUTH_TOKEN_KEY); +} + +export async function deleteAuthToken() { + await StorageService.removeItem(AUTH_TOKEN_KEY); +} + +export async function saveRoles(roles: string[]) { + await StorageService.setItem(ROLES_KEY, JSON.stringify(roles)); +} + +export async function getRoles(): Promise { + const token = await getAuthToken(); + if (!token) { + StorageService.removeItem(ROLES_KEY); + return null; + } + const rolesStr = await StorageService.getItem(ROLES_KEY); + if (!rolesStr) return null; + try { + return JSON.parse(rolesStr); + } catch { + return null; + } +} + +export async function deleteRoles() { + await StorageService.removeItem(ROLES_KEY); +} diff --git a/apps/user-ui/hooks/usePhonepeSdk.ts b/apps/user-ui/hooks/usePhonepeSdk.ts new file mode 100755 index 0000000..2ec5276 --- /dev/null +++ b/apps/user-ui/hooks/usePhonepeSdk.ts @@ -0,0 +1,34 @@ + +import { useEffect } from 'react'; +import PhonePePaymentSDK from 'react-native-phonepe-pg'; + +export function usePhonepeSdk() { + // const { data: creds, isLoading, isError } = usePhonepeCreds(); + const creds: any = {}; + const isError = false; + const isLoading = false; + + useEffect(() => { + if (creds && creds.clientId && creds.clientVersion) { + PhonePePaymentSDK.init('SANDBOX', creds.clientId, creds.clientId, true); + } + }, [creds]); + + const startTransaction = async (orderId: string, token: string) => { + try { + const request = { + orderId, + token, + merchantId: creds?.merchantId, + paymentMode: { type: 'PAY_PAGE' } + }; + const stringReq = JSON.stringify(request); + const response = await PhonePePaymentSDK.startTransaction(stringReq, null); + return response; + } catch (error) { + throw error; + } + }; + + return { startTransaction, isLoading, isError, creds }; +} diff --git a/apps/user-ui/hooks/useProductSlotIdentifier.ts b/apps/user-ui/hooks/useProductSlotIdentifier.ts new file mode 100644 index 0000000..6a781ac --- /dev/null +++ b/apps/user-ui/hooks/useProductSlotIdentifier.ts @@ -0,0 +1,48 @@ +import { trpc } from '@/src/trpc-client'; +import dayjs from 'dayjs'; + +export function useProductSlotIdentifier() { + // Fetch all slots with products + const { data: slotsData } = trpc.user.slots.getSlotsWithProducts.useQuery(); + + const productSlotsMap = new Map(); + + if (slotsData?.slots) { + const now = dayjs(); + + // Build map of productId to available slot IDs + slotsData.slots.forEach(slot => { + if (dayjs(slot.deliveryTime).isAfter(now)) { + slot.products.forEach(product => { + if (!productSlotsMap.has(product.id)) { + productSlotsMap.set(product.id, []); + } + productSlotsMap.get(product.id)!.push(slot.id); + }); + } + }); + } + + const getQuickestSlot = (productId: number): number | null => { + if (!slotsData?.slots) return null; + + const now = dayjs(); + + // Find slots that contain this product and have future delivery time + const availableSlots = slotsData.slots.filter(slot => + slot.products.some(product => product.id === productId) && + dayjs(slot.deliveryTime).isAfter(now) + ); + + if (availableSlots.length === 0) return null; + + // Return earliest slot ID (sorted by delivery time) + const earliestSlot = availableSlots.sort((a, b) => + dayjs(a.deliveryTime).diff(dayjs(b.deliveryTime)) + )[0]; + + return earliestSlot.id; + }; + + return { getQuickestSlot, productSlotsMap }; +} \ No newline at end of file diff --git a/apps/user-ui/hooks/useThemeColor.ts b/apps/user-ui/hooks/useThemeColor.ts new file mode 100755 index 0000000..0608e73 --- /dev/null +++ b/apps/user-ui/hooks/useThemeColor.ts @@ -0,0 +1,21 @@ +/** + * Learn more about light and dark modes: + * https://docs.expo.dev/guides/color-schemes/ + */ + +import { Colors } from '@/constants/Colors'; +import { useColorScheme } from '@/hooks/useColorScheme'; + +export function useThemeColor( + props: { light?: string; dark?: string }, + colorName: keyof typeof Colors.light & keyof typeof Colors.dark +) { + const theme = useColorScheme() ?? 'light'; + const colorFromProps = props[theme]; + + if (colorFromProps) { + return colorFromProps; + } else { + return Colors[theme][colorName]; + } +} diff --git a/apps/user-ui/metro.config.js b/apps/user-ui/metro.config.js new file mode 100755 index 0000000..fbbf1eb --- /dev/null +++ b/apps/user-ui/metro.config.js @@ -0,0 +1,6 @@ +// Learn more on how to setup config for the app: https://docs.expo.dev/guides/config-plugins/#metro-config +const { getDefaultConfig } = require('expo/metro-config'); + +const config = getDefaultConfig(__dirname); + +module.exports = config; diff --git a/apps/user-ui/package-lock.json b/apps/user-ui/package-lock.json new file mode 100644 index 0000000..3821a2a --- /dev/null +++ b/apps/user-ui/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "user-ui", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/apps/user-ui/package.json b/apps/user-ui/package.json new file mode 100644 index 0000000..026136f --- /dev/null +++ b/apps/user-ui/package.json @@ -0,0 +1,81 @@ +{ + "name": "user-ui", + "main": "expo-router/entry", + "version": "1.0.0", + "scripts": { + "start": "expo start", + "reset-project": "node ./scripts/reset-project.js", + "android": "expo run:android", + "ios": "expo run:ios", + "web": "expo start --web", + "lint": "expo lint" + }, + "dependencies": { + "@expo/vector-icons": "^14.1.0", + "@react-native-community/datetimepicker": "8.4.1", + "@react-native-google-signin/google-signin": "^16.0.0", + "@react-native-picker/picker": "2.11.1", + "@react-navigation/bottom-tabs": "^7.3.10", + "@react-navigation/drawer": "^7.3.9", + "@react-navigation/elements": "^2.3.8", + "@react-navigation/native": "^7.1.6", + "@tanstack/react-query": "^5.85.9", + "@trpc/client": "^11.6.0", + "@trpc/react-query": "^11.6.0", + "axios": "^1.11.0", + "buffer": "^6.0.3", + "dayjs": "^1.11.18", + "expo": "~53.0.22", + "expo-blur": "~14.1.5", + "expo-constants": "~17.1.7", + "expo-crypto": "~14.1.5", + "expo-device": "~7.1.4", + "expo-document-picker": "~13.1.6", + "expo-font": "~13.3.2", + "expo-haptics": "~14.1.4", + "expo-image": "2.4.1", + "expo-image-picker": "~16.1.4", + "expo-linear-gradient": "~14.1.5", + "expo-linking": "~7.1.7", + "expo-location": "~18.1.6", + "expo-notifications": "~0.31.4", + "expo-router": "~5.1.5", + "expo-secure-store": "~14.2.4", + "expo-splash-screen": "~0.30.10", + "expo-status-bar": "~2.2.3", + "expo-symbols": "~0.4.5", + "expo-system-ui": "~5.0.11", + "expo-updates": "~0.28.17", + "expo-web-browser": "~14.2.0", + "formik": "^2.4.6", + "jwt-decode": "^4.0.0", + "react": "19.0.0", + "react-dom": "19.0.0", + "react-hook-form": "^7.62.0", + "react-native": "0.79.6", + "react-native-element-dropdown": "^2.12.4", + "react-native-gesture-handler": "~2.24.0", + "react-native-pager-view": "6.7.1", + "react-native-paper": "^5.14.5", + "react-native-razorpay": "^2.3.1", + "react-native-reanimated": "~3.17.4", + "react-native-safe-area-context": "5.4.0", + "react-native-screens": "~4.11.1", + "react-native-svg": "15.11.2", + "react-native-tab-view": "^4.1.3", + "react-native-toast-message": "^2.3.3", + "react-native-web": "~0.20.0", + "react-native-webview": "13.13.5", + "twrnc": "^4.9.1", + "yup": "^1.7.0" + }, + "devDependencies": { + "@babel/core": "^7.25.2", + "@types/react": "~19.0.10", + "@types/react-native-razorpay": "^2.2.6", + "eslint": "^9.25.0", + "eslint-config-expo": "~9.2.0", + "typescript": "~5.8.3" + }, + "private": true +} diff --git a/apps/user-ui/scripts/reset-project.js b/apps/user-ui/scripts/reset-project.js new file mode 100755 index 0000000..51dff15 --- /dev/null +++ b/apps/user-ui/scripts/reset-project.js @@ -0,0 +1,112 @@ +#!/usr/bin/env node + +/** + * This script is used to reset the project to a blank state. + * It deletes or moves the /app, /components, /hooks, /scripts, and /constants directories to /app-example based on user input and creates a new /app directory with an index.tsx and _layout.tsx file. + * You can remove the `reset-project` script from package.json and safely delete this file after running it. + */ + +const fs = require("fs"); +const path = require("path"); +const readline = require("readline"); + +const root = process.cwd(); +const oldDirs = ["app", "components", "hooks", "constants", "scripts"]; +const exampleDir = "app-example"; +const newAppDir = "app"; +const exampleDirPath = path.join(root, exampleDir); + +const indexContent = `import { Text, View } from "react-native"; + +export default function Index() { + return ( + + Edit app/index.tsx to edit this screen. + + ); +} +`; + +const layoutContent = `import { Stack } from "expo-router"; + +export default function RootLayout() { + return ; +} +`; + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); + +const moveDirectories = async (userInput) => { + try { + if (userInput === "y") { + // Create the app-example directory + await fs.promises.mkdir(exampleDirPath, { recursive: true }); + console.log(`📁 /${exampleDir} directory created.`); + } + + // Move old directories to new app-example directory or delete them + for (const dir of oldDirs) { + const oldDirPath = path.join(root, dir); + if (fs.existsSync(oldDirPath)) { + if (userInput === "y") { + const newDirPath = path.join(root, exampleDir, dir); + await fs.promises.rename(oldDirPath, newDirPath); + console.log(`➡️ /${dir} moved to /${exampleDir}/${dir}.`); + } else { + await fs.promises.rm(oldDirPath, { recursive: true, force: true }); + console.log(`❌ /${dir} deleted.`); + } + } else { + console.log(`➡️ /${dir} does not exist, skipping.`); + } + } + + // Create new /app directory + const newAppDirPath = path.join(root, newAppDir); + await fs.promises.mkdir(newAppDirPath, { recursive: true }); + console.log("\n📁 New /app directory created."); + + // Create index.tsx + const indexPath = path.join(newAppDirPath, "index.tsx"); + await fs.promises.writeFile(indexPath, indexContent); + console.log("📄 app/index.tsx created."); + + // Create _layout.tsx + const layoutPath = path.join(newAppDirPath, "_layout.tsx"); + await fs.promises.writeFile(layoutPath, layoutContent); + console.log("📄 app/_layout.tsx created."); + + console.log("\n✅ Project reset complete. Next steps:"); + console.log( + `1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${ + userInput === "y" + ? `\n3. Delete the /${exampleDir} directory when you're done referencing it.` + : "" + }` + ); + } catch (error) { + console.error(`❌ Error during script execution: ${error.message}`); + } +}; + +rl.question( + "Do you want to move existing files to /app-example instead of deleting them? (Y/n): ", + (answer) => { + const userInput = answer.trim().toLowerCase() || "y"; + if (userInput === "y" || userInput === "n") { + moveDirectories(userInput).finally(() => rl.close()); + } else { + console.log("❌ Invalid input. Please enter 'Y' or 'N'."); + rl.close(); + } + } +); diff --git a/apps/user-ui/services/axios-user-ui.ts b/apps/user-ui/services/axios-user-ui.ts new file mode 100644 index 0000000..9b36cc7 --- /dev/null +++ b/apps/user-ui/services/axios-user-ui.ts @@ -0,0 +1,61 @@ +import axiosParent from 'axios'; +import { FORCE_LOGOUT_EVENT } from 'common-ui/src/lib/const-strs'; +import { DeviceEventEmitter } from 'react-native' +// import { getJWT } from '@/hooks/useJWT'; +import { BASE_API_URL } from 'common-ui'; +import { getAuthToken } from '@/hooks/useJWT'; + +// export const API_BASE_URL = 'http://192.168.100.95:4000'; // Change to your API base URL +// const API_BASE_URL = 'https://www.technocracy.ovh/mf'; // Change to your API base URL +// const API_BASE_URL = 'http://10.195.26.42:4000'; // Change to your API base URL +// const API_BASE_URL = 'http://localhost:4000/api/mobile/'; // Change to your API base URL +// const API_BASE_URL = 'https://car-safar.com/api/mobile/'; // Change to your API base URL + +const axios = axiosParent.create({ + baseURL: BASE_API_URL + '/api/v1', + timeout: 60000, + // headers: { + // 'Content-Type': 'application/json', + // }, +}); + + +axios.interceptors.request.use( + async (config) => { + // const token = await getJWT(); + const token = await getAuthToken(); + + if (token) { + config.headers = config.headers || {}; + config.headers['Authorization'] = `Bearer ${token}`; + } + return config; + }, + (error) => Promise.reject(error) +); + +axios.interceptors.response.use( + (response) => response, + (error) => { + + const status = error?.status; + const msg = error.response?.data?.error; + + if (status === 401 && msg.startsWith('Access denied')) { + // Handle unauthorized access + DeviceEventEmitter.emit(FORCE_LOGOUT_EVENT); + } + const message = error?.response?.data?.error; + + if (msg) { + // Optionally, you can attach the message to the error object or throw a new error + const err = new Error(msg); + // Optionally attach the original error for debugging + (err as any).original = error; + return Promise.reject(err); + } + return Promise.reject(error); + } +); + +export default axios; diff --git a/apps/user-ui/services/notif-service/notif-checker.tsx b/apps/user-ui/services/notif-service/notif-checker.tsx new file mode 100755 index 0000000..b9cc93d --- /dev/null +++ b/apps/user-ui/services/notif-service/notif-checker.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import { useNotification } from "./notif-context"; +import { BottomDialog } from "common-ui"; +import { MyText } from "common-ui"; +import { View, Linking } from "react-native"; +import { tw } from "common-ui"; +import { MyButton } from "common-ui"; +import { useAuth } from "@/components/context/auth-context"; + +interface Props {} + +function NotifChecker(props: Props) { + const {} = props; + const [showPermissionDialog, setShowPermissionDialog] = React.useState(false); + + const {isLoggedIn} = useAuth(); + // const { data: hasPushToken, isLoading, isError } = useHasPushToken({enabled: isLoggedIn}); + const hasPushToken = false; + // const { mutate: addPushToken } = useAddPushToken(); + const addPushToken = (input:any) => {}; + const { notifPermission, expoPushToken } = useNotification(); + React.useEffect(() => { + if(isLoggedIn && !hasPushToken && notifPermission =='granted') { + addPushToken(expoPushToken!); + } + },[isLoggedIn, hasPushToken]) + + React.useEffect(() => { + if (notifPermission === "denied") { + setShowPermissionDialog(true); + } + }, [notifPermission]); + + return ( + <> + setShowPermissionDialog(false)} + > + + + Notification Permission Denied + + + It seems you have denied notification permissions. Please enable + them in your device settings. + + + setShowPermissionDialog(false)} + style={tw`flex-1`} + > + Cancel + + { + Linking.openSettings(); + }} + style={tw`flex-1`} + > + Settings + + + + + + ); +} + +export default NotifChecker; diff --git a/apps/user-ui/services/notif-service/notif-context.tsx b/apps/user-ui/services/notif-service/notif-context.tsx new file mode 100755 index 0000000..db392b1 --- /dev/null +++ b/apps/user-ui/services/notif-service/notif-context.tsx @@ -0,0 +1,111 @@ +import React, { + createContext, + useContext, + useState, + useEffect, + useRef, + ReactNode, +} from "react"; +import * as Notifications from "expo-notifications"; +import { registerForPushNotificationsAsync } from "./notif-register"; +import { useRouter } from "expo-router"; +import { NotificationToast } from "../toaster"; +import { NOTIF_PERMISSION_DENIED } from "common-ui/src/lib/const-strs"; + +interface NotificationContextType { + expoPushToken: string | null; + notification: Notifications.Notification | null; + error: Error | null; + notifPermission: 'pending' | 'granted' | 'denied' +} + +export const NotificationContext = createContext< + NotificationContextType | undefined +>(undefined); + +export const useNotification = () => { + const context = useContext(NotificationContext); + if (context === undefined) { + throw new Error( + "useNotification must be used within a NotificationProvider" + ); + } + return context; +}; + +interface NotificationProviderProps { + children: ReactNode; +} + +export const NotificationProvider: React.FC = ({ + children, +}) => { + const [expoPushToken, setExpoPushToken] = useState(null); + const [notification, setNotification] = + useState(null); + const [error, setError] = useState(null); + const [notifPermission, setNotifPermission] = React.useState("pending"); + + const notificationListener = useRef(null); + const responseListener = useRef(null); + const router = useRouter(); + + useEffect(() => { + registerForPushNotificationsAsync() + .then((token) => { + setExpoPushToken(token); + setNotifPermission("granted"); + }) + .catch((errorRaw) => { + + const err = String(errorRaw).slice(7); //remove the "Error: " string component in beginning + + if (err === NOTIF_PERMISSION_DENIED) { + setNotifPermission("denied"); + } + }); + + notificationListener.current = + Notifications.addNotificationReceivedListener((notification) => { + setNotification(notification); + // Show a visible toast when app is in foreground + const content = notification.request?.content; + if (content) { + NotificationToast( + content.title || "Notification", + content.body || "", + content.data || {} + ); + } + }); + + responseListener.current = + Notifications.addNotificationResponseReceivedListener((response) => { + const data = response.notification.request.content.data; + if (data && data.doctorId) { + router.push(`/(drawer)/(tabs)/home`); + } else if (data && data.tokenId) { + router.push(`/(drawer)/(tabs)/home`); + } + }); + + return () => { + if (notificationListener.current) { + Notifications.removeNotificationSubscription( + notificationListener.current + ); + } + if (responseListener.current) { + Notifications.removeNotificationSubscription(responseListener.current); + } + }; + }, []); + + return ( + + {children} + + ); +}; diff --git a/apps/user-ui/services/notif-service/notif-register.ts b/apps/user-ui/services/notif-service/notif-register.ts new file mode 100755 index 0000000..dc317f6 --- /dev/null +++ b/apps/user-ui/services/notif-service/notif-register.ts @@ -0,0 +1,51 @@ +import * as Notifications from "expo-notifications"; +import * as Device from "expo-device"; +import Constants from "expo-constants"; +import { Platform } from "react-native"; +import { NOTIF_PERMISSION_DENIED } from "common-ui/src/lib/const-strs"; + +export async function registerForPushNotificationsAsync() { + if (Platform.OS === "android") { + await Notifications.setNotificationChannelAsync("default", { + name: "default", + importance: Notifications.AndroidImportance.MAX, + vibrationPattern: [0, 250, 250, 250], + lightColor: "#FF231F7C", + }); + } + + if (Device.isDevice) { + const { status: existingStatus } = + await Notifications.getPermissionsAsync(); + let finalStatus = existingStatus; + if (existingStatus !== "granted") { + const { status } = await Notifications.requestPermissionsAsync(); + finalStatus = status; + } + + if (finalStatus !== "granted") { + throw new Error( + NOTIF_PERMISSION_DENIED + ); + } + const projectId = + Constants?.expoConfig?.extra?.eas?.projectId ?? + Constants?.easConfig?.projectId; + if (!projectId) { + throw new Error("Project ID not found"); + } + try { + const pushTokenString = ( + await Notifications.getExpoPushTokenAsync({ + projectId, + }) + ).data; + console.log(pushTokenString); + return pushTokenString; + } catch (e: unknown) { + throw new Error(`${e}`); + } + } else { + throw new Error("Must use physical device for push notifications"); + } +} \ No newline at end of file diff --git a/apps/user-ui/services/toaster.tsx b/apps/user-ui/services/toaster.tsx new file mode 100755 index 0000000..55e6697 --- /dev/null +++ b/apps/user-ui/services/toaster.tsx @@ -0,0 +1,57 @@ +import Toast from "react-native-toast-message"; +import React from "react"; +import { useRouter } from "expo-router"; + +export function InfoToast(message: string) { + Toast.show({ + type: "info", + text1: message, + position: "top", + visibilityTime: 10000, + onPress: () => { + Toast.hide(); + }, + }); +} + +export function ErrorToast(message: string) { + Toast.show({ + type: "error", + text1: message, + position: "top", + onPress: () => { + Toast.hide(); + }, + }); +} + +export function SuccessToast(message: string) { + Toast.show({ + type: "success", + text1: message, + position: "top", + onPress: () => { + Toast.hide(); + }, + }); +} + +export function NotificationToast(title: string, subtitle: string, data: any) { + const router = useRouter(); + Toast.show({ + type: "info", + text1: title, + text2: subtitle, + position: "top", + onPress: () => { + if (data && data.rideId) { + // router.push(`/(drawer)/dashboard/ride-details?id=${data.rideId}`); + } else if (data && data.carId) { + // router.push(`/(drawer)/my-cars/car-details?id=${data.carId}`); + } + Toast.hide(); + }, + }); +} + +export default Toast; diff --git a/apps/user-ui/src/api-hooks/auth.api.ts b/apps/user-ui/src/api-hooks/auth.api.ts new file mode 100644 index 0000000..a462431 --- /dev/null +++ b/apps/user-ui/src/api-hooks/auth.api.ts @@ -0,0 +1,64 @@ +import { useMutation } from "@tanstack/react-query"; +import axios from 'common-ui/src/services/axios'; +import { LoginCredentials, RegisterData } from '@/src/types/auth'; + +// API response types +interface RegisterResponse { + token: string; + user: { + id: number; + name: string; + email: string; + mobile: string; + profileImage?: string; + createdAt: string; + }; +} + +interface UpdateProfileResponse { + token: string; + user: { + id: number; + name: string; + email: string | null; + mobile: string | null; + profileImage?: string | null; + bio?: string | null; + dateOfBirth?: string | null; + gender?: string | null; + occupation?: string | null; + }; +} + +// API functions +const registerApi = async (data: FormData): Promise => { + const response = await axios.post('/uv/auth/register', data, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data.data; // response.data is {success, data}, we want the inner data +}; + +const updateProfileApi = async (data: FormData): Promise => { + const response = await axios.put('/uv/auth/profile', data, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); + return response.data.data; // response.data is {success, data}, we want the inner data +}; + +// React Query hooks +export const useRegister = () => { + return useMutation({ + mutationFn: registerApi, + }); +}; + +export const useUpdateProfile = () => { + return useMutation({ + mutationFn: updateProfileApi, + onError: e => console.log(JSON.stringify(e)) + }); +}; \ No newline at end of file diff --git a/apps/user-ui/src/api-hooks/essential-consts.api.ts b/apps/user-ui/src/api-hooks/essential-consts.api.ts new file mode 100644 index 0000000..586592c --- /dev/null +++ b/apps/user-ui/src/api-hooks/essential-consts.api.ts @@ -0,0 +1,7 @@ +import { trpc } from '@/src/trpc-client'; + +export const useGetEssentialConsts = () => { + return trpc.common.essentialConsts.useQuery(undefined, { + refetchInterval: 60000, + }); +}; diff --git a/apps/user-ui/src/components/AddressForm.tsx b/apps/user-ui/src/components/AddressForm.tsx new file mode 100644 index 0000000..c824913 --- /dev/null +++ b/apps/user-ui/src/components/AddressForm.tsx @@ -0,0 +1,213 @@ +import React, { useState } from 'react'; +import { View, Alert, ScrollView } from 'react-native'; +import { useMutation } from '@tanstack/react-query'; +import { Formik } from 'formik'; +import * as Yup from 'yup'; +import * as Location from 'expo-location'; +import { tw, MyText, MyTouchableOpacity , Checkbox , MyTextInput , LoadingDialog } from 'common-ui'; +import { trpc } from '../trpc-client'; + +interface AddressFormProps { + onSuccess: () => void; + initialValues?: { + name: string; + phone: string; + addressLine1: string; + addressLine2: string; + city: string; + state: string; + pincode: string; + isDefault: boolean; + }; + isEdit?: boolean; +} + +const AddressForm: React.FC = ({ onSuccess, initialValues, isEdit = false }) => { + const [locationLoading, setLocationLoading] = useState(false); + const [locationError, setLocationError] = useState(null); + const [isSubmitting, setIsSubmitting] = useState(false); + + const createAddressMutation = trpc.user.address.createAddress.useMutation({ + onSuccess: () => { + setIsSubmitting(false); + onSuccess(); + }, + onError: (error: any) => { + setIsSubmitting(false); + Alert.alert('Error', error.message || 'Failed to save address'); + }, + }); + + const attachCurrentLocation = async (setFieldValue: (field: string, value: any) => void) => { + setLocationLoading(true); + setLocationError(null); + + try { + // Request location permission + const { status } = await Location.requestForegroundPermissionsAsync(); + + if (status !== 'granted') { + setLocationError('Location Permission denied'); + return; + } + + // Get current position + const location = await Location.getCurrentPositionAsync({ + accuracy: Location.Accuracy.High, + }); + + // Reverse geocode to get address + const address = await Location.reverseGeocodeAsync({ + latitude: location.coords.latitude, + longitude: location.coords.longitude, + }); + + // Populate form fields with geocoded data + if (address[0]) { + const addr = address[0]; + const addressLine1 = `${addr.streetNumber || ''} ${addr.street || ''}`.trim(); + setFieldValue('addressLine1', addressLine1 || addr.name || ''); + setFieldValue('city', addr.city || addr.subregion || ''); + setFieldValue('state', addr.region || ''); + setFieldValue('pincode', addr.postalCode || ''); + } else { + setLocationError('Unable to determine address from your location'); + } + } catch (error) { + console.error('Location error:', error); + setLocationError('Unable to fetch location. Please check your GPS settings.'); + } finally { + setLocationLoading(false); + } + }; + + const validationSchema = Yup.object({ + name: Yup.string().required('Name is required'), + phone: Yup.string().required('Phone is required').matches(/^\d{10}$/, 'Phone must be 10 digits'), + addressLine1: Yup.string().required('Address Line 1 is required'), + addressLine2: Yup.string(), + city: Yup.string().required('City is required'), + state: Yup.string().required('State is required'), + pincode: Yup.string().required('Pincode is required').matches(/^\d{6}$/, 'Pincode must be 6 digits'), + isDefault: Yup.boolean(), + }); + + return ( + + {isEdit ? 'Edit Address' : 'Add Address'} + { + setIsSubmitting(true); + createAddressMutation.mutate(values); + }} + > + {({ handleChange, handleBlur, handleSubmit, values, errors, touched, setFieldValue }) => ( + + + {touched.name && errors.name && {errors.name}} + + + {touched.phone && errors.phone && {errors.phone}} + + + {touched.addressLine1 && errors.addressLine1 && {errors.addressLine1}} + + + + + {touched.city && errors.city && {errors.city}} + + + {touched.state && errors.state && {errors.state}} + + + {touched.pincode && errors.pincode && {errors.pincode}} + + + setFieldValue('isDefault', !values.isDefault)} + /> + Set as default address + + + handleSubmit()} + disabled={isSubmitting} + > + + {isSubmitting ? (isEdit ? 'Updating...' : 'Adding...') : (isEdit ? 'Update Address' : 'Add Address')} + + + + )} + + + + + ); +}; + +export default AddressForm; \ No newline at end of file diff --git a/apps/user-ui/src/components/google-sign-in.tsx b/apps/user-ui/src/components/google-sign-in.tsx new file mode 100644 index 0000000..fdc2423 --- /dev/null +++ b/apps/user-ui/src/components/google-sign-in.tsx @@ -0,0 +1,47 @@ +import * as React from 'react'; +import * as AuthSession from 'expo-auth-session'; +import * as WebBrowser from 'expo-web-browser'; +import { Button, View } from 'react-native'; +import * as Google from 'expo-auth-session/providers/google'; + + +WebBrowser.maybeCompleteAuthSession(); + +const discovery = { + authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth', + tokenEndpoint: 'https://oauth2.googleapis.com/token', +}; + + +WebBrowser.maybeCompleteAuthSession(); +export default function GoogleSignInPKCE() { + + + + + // const [request, response, promptAsync] = Google.useAuthRequest({ + // androidClientId: androidClientId, + // iosClientId: iosClientId, + // webClientId: webClientId, + // redirectUri: 'https://www.freshyo.in/oauthredirect', + // // redirectUri: AuthSession.makeRedirectUri({ scheme: 'freshyo', path: 'oauthredirect' }), + // scopes: ["openid", "profile", "email"], + // }); + + + + // React.useEffect(() => { + // if (response?.type === "success") { + // const { authentication } = response; + // console.log("Access token:", authentication?.accessToken); + // } + // }, [response]); + + + return ( + +