This commit is contained in:
shafi54 2026-03-24 20:50:14 +05:30
parent 44e53d2978
commit 97812fa4c5
190 changed files with 197764 additions and 356 deletions

File diff suppressed because one or more lines are too long

View file

@ -227,7 +227,6 @@ export default function Layout() {
<Drawer.Screen name="slots" options={{ title: "Slots" }} /> <Drawer.Screen name="slots" options={{ title: "Slots" }} />
<Drawer.Screen name="vendor-snippets" options={{ title: "Vendor Snippets" }} /> <Drawer.Screen name="vendor-snippets" options={{ title: "Vendor Snippets" }} />
<Drawer.Screen name="stores" options={{ title: "Stores" }} /> <Drawer.Screen name="stores" options={{ title: "Stores" }} />
<Drawer.Screen name="address-management" options={{ title: "Address Management" }} />
<Drawer.Screen name="product-tags" options={{ title: "Product Tags" }} /> <Drawer.Screen name="product-tags" options={{ title: "Product Tags" }} />
<Drawer.Screen name="rebalance-orders" options={{ title: "Rebalance Orders" }} /> <Drawer.Screen name="rebalance-orders" options={{ title: "Rebalance Orders" }} />
<Drawer.Screen name="user-management" options={{ title: "User Management" }} /> <Drawer.Screen name="user-management" options={{ title: "User Management" }} />

View file

@ -1,108 +0,0 @@
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<Set<number>>(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<number, typeof areas[0][]>) || {}
const unzonedAreas = areas?.filter(a => !a.zoneId) || []
return (
<View style={tw`flex-1 bg-white`}>
<View style={tw`flex-row justify-between p-4`}>
<TouchableOpacity style={tw`bg-blue1 px-4 py-2 rounded`} onPress={handleAddZone}>
<Text style={tw`text-white`}>Add Zone</Text>
</TouchableOpacity>
<TouchableOpacity style={tw`bg-green1 px-4 py-2 rounded`} onPress={handleAddPlace}>
<Text style={tw`text-white`}>Add Place</Text>
</TouchableOpacity>
</View>
<ScrollView style={tw`flex-1 p-4`}>
{zones?.map(zone => (
<View key={zone.id} style={tw`mb-4 border border-gray-300 rounded`}>
<TouchableOpacity style={tw`flex-row items-center p-3 bg-gray-100`} onPress={() => toggleZone(zone.id)}>
<Text style={tw`flex-1 text-lg font-semibold`}>{zone.zoneName}</Text>
<MaterialIcons name={expandedZones.has(zone.id) ? 'expand-less' : 'expand-more'} size={24} />
</TouchableOpacity>
{expandedZones.has(zone.id) && (
<View style={tw`p-3`}>
{groupedAreas[zone.id]?.map(area => (
<Text key={area.id} style={tw`text-base mb-1`}>- {area.placeName}</Text>
)) || <Text style={tw`text-gray-500`}>No places in this zone</Text>}
</View>
)}
</View>
))}
<View style={tw`mt-6`}>
<Text style={tw`text-xl font-bold mb-2`}>Unzoned Places</Text>
{unzonedAreas.map(area => (
<Text key={area.id} style={tw`text-base mb-1`}>- {area.placeName}</Text>
))}
{unzonedAreas.length === 0 && <Text style={tw`text-gray-500`}>No unzoned places</Text>}
</View>
</ScrollView>
<BottomDialog open={dialogOpen} onClose={() => setDialogOpen(false)}>
{dialogType === 'zone' && <AddressZoneForm onSubmit={createZone.mutate} onClose={() => setDialogOpen(false)} />}
{dialogType === 'place' && <AddressPlaceForm onSubmit={createArea.mutate} onClose={() => setDialogOpen(false)} />}
</BottomDialog>
</View>
)
}
export default AddressManagement

View file

@ -175,15 +175,6 @@ export default function Dashboard() {
category: 'marketing', category: 'marketing',
iconColor: '#F97316', iconColor: '#F97316',
iconBg: '#FFEDD5', 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', title: 'App Constants',

Binary file not shown.

View file

@ -17,10 +17,10 @@ S3_REGION=apac
S3_ACCESS_KEY_ID=8fab47503efb9547b50e4fb317e35cc7 S3_ACCESS_KEY_ID=8fab47503efb9547b50e4fb317e35cc7
S3_SECRET_ACCESS_KEY=47c2eb5636843cf568dda7ad0959a3e42071303f26dbdff94bd45a3c33dcd950 S3_SECRET_ACCESS_KEY=47c2eb5636843cf568dda7ad0959a3e42071303f26dbdff94bd45a3c33dcd950
S3_URL=https://da9b1aa7c1951c23e2c0c3246ba68a58.r2.cloudflarestorage.com S3_URL=https://da9b1aa7c1951c23e2c0c3246ba68a58.r2.cloudflarestorage.com
S3_BUCKET_NAME=meatfarmer S3_BUCKET_NAME=meatfarmer-dev
EXPO_ACCESS_TOKEN=Asvpy8cByRh6T4ksnWScO6PLcio2n35-BwES5zK- EXPO_ACCESS_TOKEN=Asvpy8cByRh6T4ksnWScO6PLcio2n35-BwES5zK-
JWT_SECRET=my_meatfarmer_jwt_secret_key JWT_SECRET=my_meatfarmer_jwt_secret_key
ASSETS_DOMAIN=https://assets.freshyo.in/ ASSETS_DOMAIN=https://assets2.freshyo.in/
API_CACHE_KEY=api-cache-dev API_CACHE_KEY=api-cache-dev
# CLOUDFLARE_API_TOKEN=I8Vp4E9TX58E8qEDeH0nTFDS2d2zXNYiXvbs4Ckj # CLOUDFLARE_API_TOKEN=I8Vp4E9TX58E8qEDeH0nTFDS2d2zXNYiXvbs4Ckj
CLOUDFLARE_API_TOKEN=N7jAg5X-RUj_fVfMW6zbfJ8qIYc81TSIKKlbZ6oh CLOUDFLARE_API_TOKEN=N7jAg5X-RUj_fVfMW6zbfJ8qIYc81TSIKKlbZ6oh

View file

@ -0,0 +1,15 @@
// Database Service - Central export for all database-related imports
// This file re-exports everything from postgresService to provide a clean abstraction layer
// Implementation is the responsibility of postgresService package
// Re-export database connection
export { db } from 'postgresService';
// Re-export all schema exports
export * from 'postgresService';
// Re-export methods from postgresService (implementation lives there)
export { getBanners, getBannerById, createBanner, updateBanner, deleteBanner } from 'postgresService';
// Re-export types from local types file (to avoid circular dependencies)
export type { Banner } from './types/db.types';

View file

@ -1,32 +0,0 @@
import { z } from 'zod';
import { addressZones, addressAreas } from '@/src/db/schema'
import { eq, desc } from 'drizzle-orm';
import { db } from '@/src/db/db_index'
import { router,protectedProcedure } from '@/src/trpc/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;

View file

@ -2,7 +2,6 @@
import { router } from '@/src/trpc/trpc-index' import { router } from '@/src/trpc/trpc-index'
import { complaintRouter } from '@/src/trpc/apis/admin-apis/apis/complaint' import { complaintRouter } from '@/src/trpc/apis/admin-apis/apis/complaint'
import { couponRouter } from '@/src/trpc/apis/admin-apis/apis/coupon' import { couponRouter } from '@/src/trpc/apis/admin-apis/apis/coupon'
import { cancelledOrdersRouter } from '@/src/trpc/apis/admin-apis/apis/cancelled-orders'
import { orderRouter } from '@/src/trpc/apis/admin-apis/apis/order' import { orderRouter } from '@/src/trpc/apis/admin-apis/apis/order'
import { vendorSnippetsRouter } from '@/src/trpc/apis/admin-apis/apis/vendor-snippets' import { vendorSnippetsRouter } from '@/src/trpc/apis/admin-apis/apis/vendor-snippets'
import { slotsRouter } from '@/src/trpc/apis/admin-apis/apis/slots' import { slotsRouter } from '@/src/trpc/apis/admin-apis/apis/slots'
@ -10,7 +9,6 @@ import { productRouter } from '@/src/trpc/apis/admin-apis/apis/product'
import { staffUserRouter } from '@/src/trpc/apis/admin-apis/apis/staff-user' import { staffUserRouter } from '@/src/trpc/apis/admin-apis/apis/staff-user'
import { storeRouter } from '@/src/trpc/apis/admin-apis/apis/store' import { storeRouter } from '@/src/trpc/apis/admin-apis/apis/store'
import { adminPaymentsRouter } from '@/src/trpc/apis/admin-apis/apis/payments' import { adminPaymentsRouter } from '@/src/trpc/apis/admin-apis/apis/payments'
import addressRouter from '@/src/trpc/apis/admin-apis/apis/address'
import { bannerRouter } from '@/src/trpc/apis/admin-apis/apis/banner' import { bannerRouter } from '@/src/trpc/apis/admin-apis/apis/banner'
import { userRouter } from '@/src/trpc/apis/admin-apis/apis/user' import { userRouter } from '@/src/trpc/apis/admin-apis/apis/user'
import { constRouter } from '@/src/trpc/apis/admin-apis/apis/const' import { constRouter } from '@/src/trpc/apis/admin-apis/apis/const'
@ -18,7 +16,6 @@ import { constRouter } from '@/src/trpc/apis/admin-apis/apis/const'
export const adminRouter = router({ export const adminRouter = router({
complaint: complaintRouter, complaint: complaintRouter,
coupon: couponRouter, coupon: couponRouter,
cancelledOrders: cancelledOrdersRouter,
order: orderRouter, order: orderRouter,
vendorSnippets: vendorSnippetsRouter, vendorSnippets: vendorSnippetsRouter,
slots: slotsRouter, slots: slotsRouter,
@ -26,7 +23,6 @@ export const adminRouter = router({
staffUser: staffUserRouter, staffUser: staffUserRouter,
store: storeRouter, store: storeRouter,
payments: adminPaymentsRouter, payments: adminPaymentsRouter,
address: addressRouter,
banner: bannerRouter, banner: bannerRouter,
user: userRouter, user: userRouter,
const: constRouter, const: constRouter,

View file

@ -1,23 +1,34 @@
import { z } from 'zod'; import { z } from 'zod';
import { db } from '@/src/db/db_index'
import { homeBanners } from '@/src/db/schema'
import { eq, and, desc, sql } from 'drizzle-orm';
import { protectedProcedure, router } from '@/src/trpc/trpc-index' import { protectedProcedure, router } from '@/src/trpc/trpc-index'
import { extractKeyFromPresignedUrl, generateSignedUrlFromS3Url } from '@/src/lib/s3-client' import { extractKeyFromPresignedUrl, generateSignedUrlFromS3Url } from '@/src/lib/s3-client'
import { ApiError } from '@/src/lib/api-error'; import { ApiError } from '@/src/lib/api-error';
import { scheduleStoreInitialization } from '@/src/stores/store-initializer' import { scheduleStoreInitialization } from '@/src/stores/store-initializer'
import {
getBanners as getBannersFromDb,
getBannerById as getBannerByIdFromDb,
createBanner as createBannerInDb,
updateBanner as updateBannerInDb,
deleteBanner as deleteBannerFromDb,
} from '@/src/dbService'
import type { Banner } from '@packages/shared'
export const bannerRouter = router({ export const bannerRouter = router({
// Get all banners // Get all banners
getBanners: protectedProcedure getBanners: protectedProcedure
.query(async () => { .query(async (): Promise<{ banners: Banner[] }> => {
try { try {
const banners = await db.query.homeBanners.findMany({ // Using dbService helper (new implementation)
orderBy: desc(homeBanners.createdAt), // Order by creation date instead const banners = await getBannersFromDb();
// Old implementation - direct DB query:
// 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 // Removed product relationship since we now use productIds array
}); // });
// Convert S3 keys to signed URLs for client // Convert S3 keys to signed URLs for client
const bannersWithSignedUrls = await Promise.all( const bannersWithSignedUrls = await Promise.all(
@ -55,11 +66,17 @@ export const bannerRouter = router({
// Get single banner by ID // Get single banner by ID
getBanner: protectedProcedure getBanner: protectedProcedure
.input(z.object({ id: z.number() })) .input(z.object({ id: z.number() }))
.query(async ({ input }) => { .query(async ({ input }): Promise<Banner | null> => {
// Using dbService helper (new implementation)
const banner = await getBannerByIdFromDb(input.id);
/*
// Old implementation - direct DB query:
const banner = await db.query.homeBanners.findFirst({ const banner = await db.query.homeBanners.findFirst({
where: eq(homeBanners.id, input.id), where: eq(homeBanners.id, input.id),
// Removed product relationship since we now use productIds array // Removed product relationship since we now use productIds array
}); });
*/
if (banner) { if (banner) {
try { try {
@ -91,8 +108,22 @@ export const bannerRouter = router({
redirectUrl: z.string().url().optional(), redirectUrl: z.string().url().optional(),
// serialNum removed completely // serialNum removed completely
})) }))
.mutation(async ({ input }) => { .mutation(async ({ input }): Promise<Banner> => {
try { try {
// Using dbService helper (new implementation)
const imageUrl = extractKeyFromPresignedUrl(input.imageUrl)
const banner = await createBannerInDb({
name: input.name,
imageUrl: imageUrl,
description: input.description ?? null,
productIds: input.productIds || [],
redirectUrl: input.redirectUrl ?? null,
serialNum: 999, // Default value, not used
isActive: false, // Default to inactive
});
/*
// Old implementation - direct DB query:
const imageUrl = extractKeyFromPresignedUrl(input.imageUrl) const imageUrl = extractKeyFromPresignedUrl(input.imageUrl)
const [banner] = await db.insert(homeBanners).values({ const [banner] = await db.insert(homeBanners).values({
name: input.name, name: input.name,
@ -103,6 +134,7 @@ export const bannerRouter = router({
serialNum: 999, // Default value, not used serialNum: 999, // Default value, not used
isActive: false, // Default to inactive isActive: false, // Default to inactive
}).returning(); }).returning();
*/
// Reinitialize stores to reflect changes // Reinitialize stores to reflect changes
scheduleStoreInitialization() scheduleStoreInitialization()
@ -126,9 +158,28 @@ export const bannerRouter = router({
serialNum: z.number().nullable().optional(), serialNum: z.number().nullable().optional(),
isActive: z.boolean().optional(), isActive: z.boolean().optional(),
})) }))
.mutation(async ({ input }) => { .mutation(async ({ input }): Promise<Banner> => {
try { try {
// Using dbService helper (new implementation)
const { id, ...updateData } = input;
// Extract S3 key from presigned URL if imageUrl is provided
const processedData = {
...updateData,
...(updateData.imageUrl && {
imageUrl: extractKeyFromPresignedUrl(updateData.imageUrl)
}),
};
// Handle serialNum null case
if ('serialNum' in processedData && processedData.serialNum === null) {
processedData.serialNum = null;
}
const banner = await updateBannerInDb(id, processedData);
/*
// Old implementation - direct DB query:
const { id, ...updateData } = input; const { id, ...updateData } = input;
const incomingProductIds = input.productIds; const incomingProductIds = input.productIds;
// Extract S3 key from presigned URL if imageUrl is provided // Extract S3 key from presigned URL if imageUrl is provided
@ -150,6 +201,7 @@ export const bannerRouter = router({
.set({ ...finalData, lastUpdated: new Date(), }) .set({ ...finalData, lastUpdated: new Date(), })
.where(eq(homeBanners.id, id)) .where(eq(homeBanners.id, id))
.returning(); .returning();
*/
// Reinitialize stores to reflect changes // Reinitialize stores to reflect changes
scheduleStoreInitialization() scheduleStoreInitialization()
@ -164,8 +216,14 @@ export const bannerRouter = router({
// Delete banner // Delete banner
deleteBanner: protectedProcedure deleteBanner: protectedProcedure
.input(z.object({ id: z.number() })) .input(z.object({ id: z.number() }))
.mutation(async ({ input }) => { .mutation(async ({ input }): Promise<{ success: true }> => {
// Using dbService helper (new implementation)
await deleteBannerFromDb(input.id);
/*
// Old implementation - direct DB query:
await db.delete(homeBanners).where(eq(homeBanners.id, input.id)); await db.delete(homeBanners).where(eq(homeBanners.id, input.id));
*/
// Reinitialize stores to reflect changes // Reinitialize stores to reflect changes
scheduleStoreInitialization() scheduleStoreInitialization()

View file

@ -1,179 +0,0 @@
import { router, protectedProcedure } from '@/src/trpc/trpc-index'
import { z } from 'zod';
import { db } from '@/src/db/db_index'
import { orders, orderStatus, users, addresses, orderItems, productInfo, units, refunds } from '@/src/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.id,
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.id,
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];
}),
});

View file

@ -0,0 +1,4 @@
// Database Types - Re-exports from shared package
// Central type definitions for backend database operations
export type { Banner } from '@packages/shared';

View file

@ -35,6 +35,8 @@
"@commonTypes/*": ["../../packages/ui/shared-types/*"], "@commonTypes/*": ["../../packages/ui/shared-types/*"],
"@packages/shared": ["../../packages/shared"], "@packages/shared": ["../../packages/shared"],
"@packages/shared/*": ["../../packages/shared/*"], "@packages/shared/*": ["../../packages/shared/*"],
"postgresService": ["../../packages/db_helper_postgres"],
"postgresService/*": ["../../packages/db_helper_postgres/*"],
"global-shared": ["../../packages/shared"], "global-shared": ["../../packages/shared"],
"global-shared/*": ["../../packages/shared/*"] "global-shared/*": ["../../packages/shared/*"]
}, },

View file

@ -11,6 +11,7 @@ import { CreateCouponRoute } from './routes/create-coupon'
import { LocationMarkerRoute } from './routes/location-marker' import { LocationMarkerRoute } from './routes/location-marker'
import { UserConnectRoute } from './routes/user-connect' import { UserConnectRoute } from './routes/user-connect'
import Inauguration from './routes/inauguration' import Inauguration from './routes/inauguration'
import { DemoRoute } from './routes/demo'
import { AuthWrapper } from './components/AuthWrapper' import { AuthWrapper } from './components/AuthWrapper'
import { SuperAdminGuard } from './components/SuperAdminGuard' import { SuperAdminGuard } from './components/SuperAdminGuard'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
@ -124,6 +125,16 @@ const locationMarkerRoute = new Route({
) )
}) })
const demoRoute = new Route({
getParentRoute: () => rootRoute,
path: '/demo',
component: () => (
<Suspense fallback={<p>Loading demo</p>}>
<DemoRoute />
</Suspense>
)
})
const routeTree = rootRoute.addChildren([ const routeTree = rootRoute.addChildren([
dashboardRoute, dashboardRoute,
vendorOrderListRoute, vendorOrderListRoute,
@ -133,7 +144,8 @@ const routeTree = rootRoute.addChildren([
createCouponRoute, createCouponRoute,
userConnectRoute, userConnectRoute,
locationMarkerRoute, locationMarkerRoute,
inaugurationRoute inaugurationRoute,
demoRoute
]) ])
export function createAppRouter() { export function createAppRouter() {

View file

@ -0,0 +1,259 @@
import { useState } from 'react'
import { getAuthToken } from '@/services/auth'
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000'
export function DemoRoute() {
const [method, setMethod] = useState<string>('GET')
const [endpoint, setEndpoint] = useState<string>('/api/test')
const [headers, setHeaders] = useState<string>('{}')
const [body, setBody] = useState<string>('{}')
const [response, setResponse] = useState<any>(null)
const [error, setError] = useState<string>('')
const [loading, setLoading] = useState(false)
const [history, setHistory] = useState<Array<{ method: string; endpoint: string; timestamp: string }>>([])
const handleSubmit = async () => {
setLoading(true)
setError('')
setResponse(null)
try {
const token = await getAuthToken()
const url = `${API_BASE_URL}${endpoint}`
let parsedHeaders: Record<string, string> = {}
try {
parsedHeaders = JSON.parse(headers)
} catch {
throw new Error('Invalid headers JSON')
}
const fetchOptions: RequestInit = {
method,
headers: {
'Content-Type': 'application/json',
...(token && { Authorization: `Bearer ${token}` }),
...parsedHeaders,
},
}
if (method !== 'GET' && method !== 'HEAD') {
try {
const parsedBody = JSON.parse(body)
fetchOptions.body = JSON.stringify(parsedBody)
} catch {
throw new Error('Invalid body JSON')
}
}
const startTime = performance.now()
const res = await fetch(url, fetchOptions)
const endTime = performance.now()
const duration = Math.round(endTime - startTime)
let data
const contentType = res.headers.get('content-type')
if (contentType && contentType.includes('application/json')) {
data = await res.json()
} else {
data = await res.text()
}
setResponse({
status: res.status,
statusText: res.statusText,
duration: `${duration}ms`,
headers: Object.fromEntries(res.headers.entries()),
data,
})
// Add to history
setHistory(prev => [
{ method, endpoint, timestamp: new Date().toLocaleTimeString() },
...prev.slice(0, 9), // Keep last 10
])
} catch (err: any) {
setError(err.message || 'An error occurred')
} finally {
setLoading(false)
}
}
const loadFromHistory = (item: { method: string; endpoint: string }) => {
setMethod(item.method)
setEndpoint(item.endpoint)
}
const getStatusColor = (status: number) => {
if (status >= 200 && status < 300) return 'bg-green-500'
if (status >= 300 && status < 400) return 'bg-yellow-500'
if (status >= 400) return 'bg-red-500'
return 'bg-gray-500'
}
return (
<div className="max-w-6xl mx-auto p-6 space-y-6">
<div className="flex items-center justify-between mb-6">
<h1 className="text-3xl font-bold text-gray-900">API Demo & Testing</h1>
<span className="px-3 py-1 bg-gray-200 rounded-full text-sm text-gray-700">
{API_BASE_URL}
</span>
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
{/* Request Panel */}
<div className="lg:col-span-2 bg-white rounded-lg shadow-md p-6">
<h2 className="text-xl font-semibold mb-4">Request</h2>
<div className="space-y-4">
<div className="flex gap-2">
<select
value={method}
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => setMethod(e.target.value)}
className="px-4 py-2 border rounded-md bg-white w-32"
>
<option value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
<option value="PATCH">PATCH</option>
<option value="DELETE">DELETE</option>
</select>
<input
type="text"
placeholder="/api/endpoint"
value={endpoint}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setEndpoint(e.target.value)}
className="flex-1 px-4 py-2 border rounded-md"
/>
<button
onClick={handleSubmit}
disabled={loading}
className="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:bg-blue-400 transition-colors"
>
{loading ? 'Sending...' : 'Send'}
</button>
</div>
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700">Headers (JSON)</label>
<textarea
value={headers}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => setHeaders(e.target.value)}
placeholder='{"Custom-Header": "value"}'
className="w-full px-4 py-2 border rounded-md font-mono text-sm min-h-[80px]"
/>
</div>
{method !== 'GET' && method !== 'HEAD' && (
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700">Body (JSON)</label>
<textarea
value={body}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => setBody(e.target.value)}
placeholder='{"key": "value"}'
className="w-full px-4 py-2 border rounded-md font-mono text-sm min-h-[120px]"
/>
</div>
)}
</div>
</div>
{/* History Panel */}
<div className="bg-white rounded-lg shadow-md p-6">
<h2 className="text-xl font-semibold mb-4">History</h2>
<div className="space-y-2 max-h-[400px] overflow-y-auto">
{history.length === 0 ? (
<p className="text-gray-500 text-sm">No requests yet</p>
) : (
history.map((item, index) => (
<button
key={index}
onClick={() => loadFromHistory(item)}
className="w-full text-left p-3 rounded hover:bg-gray-100 transition-colors text-sm border"
>
<div className="flex items-center gap-2">
<span className={`px-2 py-0.5 rounded text-xs font-medium ${
item.method === 'GET' ? 'bg-blue-100 text-blue-700' : 'bg-gray-100 text-gray-700'
}`}>
{item.method}
</span>
<span className="truncate flex-1 text-gray-900">{item.endpoint}</span>
</div>
<div className="text-xs text-gray-500 mt-1">
{item.timestamp}
</div>
</button>
))
)}
</div>
</div>
{/* Response Panel */}
<div className="lg:col-span-3 bg-white rounded-lg shadow-md p-6">
<h2 className="text-xl font-semibold mb-4">Response</h2>
{error ? (
<div className="p-4 bg-red-50 border border-red-200 rounded-md text-red-700">
<p className="font-medium">Error</p>
<p className="text-sm">{error}</p>
</div>
) : response ? (
<div className="space-y-4">
<div className="flex items-center gap-4">
<span className={`px-3 py-1 rounded-full text-white text-sm font-medium ${getStatusColor(response.status)}`}>
{response.status} {response.statusText}
</span>
<span className="px-3 py-1 border rounded-full text-sm">
{response.duration}
</span>
</div>
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700">Response Headers</label>
<pre className="bg-gray-100 p-3 rounded-md overflow-x-auto text-xs">
{JSON.stringify(response.headers, null, 2)}
</pre>
</div>
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700">Response Body</label>
<pre className="bg-gray-100 p-3 rounded-md overflow-x-auto text-xs">
{typeof response.data === 'string'
? response.data
: JSON.stringify(response.data, null, 2)}
</pre>
</div>
</div>
) : (
<div className="text-center py-12 text-gray-500">
<p>Send a request to see the response</p>
</div>
)}
</div>
</div>
{/* Quick Links */}
<div className="bg-white rounded-lg shadow-md p-6">
<h2 className="text-xl font-semibold mb-4">Quick Test Endpoints</h2>
<div className="flex flex-wrap gap-2">
{[
{ method: 'GET', endpoint: '/trpc/user.banner.getActiveBanners' },
{ method: 'GET', endpoint: '/trpc/user.product.getAllProducts' },
{ method: 'GET', endpoint: '/trpc/user.user.getCurrentUser' },
{ method: 'POST', endpoint: '/trpc/user.auth.login' },
].map((item, index) => (
<button
key={index}
onClick={() => loadFromHistory(item)}
className="px-4 py-2 border rounded-md hover:bg-gray-50 transition-colors text-sm"
>
<span className="mr-2 px-2 py-0.5 bg-gray-200 rounded text-xs">
{item.method}
</span>
{item.endpoint}
</button>
))}
</div>
</div>
</div>
)
}

Binary file not shown.

View file

@ -272,6 +272,22 @@
"typescript": "~5.8.3", "typescript": "~5.8.3",
}, },
}, },
"packages/db_helper_postgres": {
"name": "@packages/db_helper_postgres",
"version": "1.0.0",
"dependencies": {
"dotenv": "^17.2.1",
"drizzle-orm": "^0.44.5",
"pg": "^8.16.3",
},
"devDependencies": {
"@types/node": "^24.5.2",
"@types/pg": "^8.15.5",
"drizzle-kit": "^0.31.4",
"tsx": "^4.20.5",
"typescript": "^5.9.2",
},
},
"packages/shared": { "packages/shared": {
"name": "@packages/shared", "name": "@packages/shared",
"version": "1.0.0", "version": "1.0.0",
@ -839,6 +855,8 @@
"@nolyfill/is-core-module": ["@nolyfill/is-core-module@1.0.39", "", {}, "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA=="], "@nolyfill/is-core-module": ["@nolyfill/is-core-module@1.0.39", "", {}, "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA=="],
"@packages/db_helper_postgres": ["@packages/db_helper_postgres@workspace:packages/db_helper_postgres"],
"@packages/shared": ["@packages/shared@workspace:packages/shared"], "@packages/shared": ["@packages/shared@workspace:packages/shared"],
"@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="], "@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],
@ -3437,6 +3455,10 @@
"@maplibre/maplibre-gl-style-spec/quickselect": ["quickselect@2.0.0", "", {}, "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw=="], "@maplibre/maplibre-gl-style-spec/quickselect": ["quickselect@2.0.0", "", {}, "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw=="],
"@packages/db_helper_postgres/drizzle-orm": ["drizzle-orm@0.44.7", "", { "peerDependencies": { "@aws-sdk/client-rds-data": ">=3", "@cloudflare/workers-types": ">=4", "@electric-sql/pglite": ">=0.2.0", "@libsql/client": ">=0.10.0", "@libsql/client-wasm": ">=0.10.0", "@neondatabase/serverless": ">=0.10.0", "@op-engineering/op-sqlite": ">=2", "@opentelemetry/api": "^1.4.1", "@planetscale/database": ">=1.13", "@prisma/client": "*", "@tidbcloud/serverless": "*", "@types/better-sqlite3": "*", "@types/pg": "*", "@types/sql.js": "*", "@upstash/redis": ">=1.34.7", "@vercel/postgres": ">=0.8.0", "@xata.io/client": "*", "better-sqlite3": ">=7", "bun-types": "*", "expo-sqlite": ">=14.0.0", "gel": ">=2", "knex": "*", "kysely": "*", "mysql2": ">=2", "pg": ">=8", "postgres": ">=3", "sql.js": ">=1", "sqlite3": ">=5" }, "optionalPeers": ["@aws-sdk/client-rds-data", "@cloudflare/workers-types", "@electric-sql/pglite", "@libsql/client", "@libsql/client-wasm", "@neondatabase/serverless", "@op-engineering/op-sqlite", "@opentelemetry/api", "@planetscale/database", "@prisma/client", "@tidbcloud/serverless", "@types/better-sqlite3", "@types/pg", "@types/sql.js", "@upstash/redis", "@vercel/postgres", "@xata.io/client", "better-sqlite3", "bun-types", "expo-sqlite", "gel", "knex", "kysely", "mysql2", "pg", "postgres", "sql.js", "sqlite3"] }, "sha512-quIpnYznjU9lHshEOAYLoZ9s3jweleHlZIAWR/jX9gAWNg/JhQ1wj0KGRf7/Zm+obRrYd9GjPVJg790QY9N5AQ=="],
"@packages/db_helper_postgres/typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"@react-native/community-cli-plugin/debug": ["debug@2.6.9", "", { "dependencies": { "ms": "2.0.0" } }, "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="], "@react-native/community-cli-plugin/debug": ["debug@2.6.9", "", { "dependencies": { "ms": "2.0.0" } }, "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA=="],
"@react-native/community-cli-plugin/semver": ["semver@7.7.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="], "@react-native/community-cli-plugin/semver": ["semver@7.7.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],

View file

@ -0,0 +1,42 @@
ENV_MODE=PROD
DATABASE_URL=postgresql://postgres:meatfarmer_master_password@57.128.212.174:7447/meatfarmer #technocracy
# DATABASE_URL=postgres://postgres:meatfarmer_master_password@5.223.55.14:7447/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
ASSETS_DOMAIN=https://assets.freshyo.in/
API_CACHE_KEY=api-cache-dev
# CLOUDFLARE_API_TOKEN=I8Vp4E9TX58E8qEDeH0nTFDS2d2zXNYiXvbs4Ckj
CLOUDFLARE_API_TOKEN=N7jAg5X-RUj_fVfMW6zbfJ8qIYc81TSIKKlbZ6oh
CLOUDFLARE_ZONE_ID=edefbf750bfc3ff26ccd11e8e28dc8d7
# REDIS_URL=redis://default:redis_shafi_password@5.223.55.14:6379
REDIS_URL=redis://default:redis_shafi_password@57.128.212.174: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
# Telegram Configuration
TELEGRAM_BOT_TOKEN=8410461852:AAGXQCwRPFbndqwTgLJh8kYxST4Z0vgh72U
TELEGRAM_CHAT_IDS=5147760058
# TELEGRAM_BOT_TOKEN=8410461852:AAGXQCwRPFbndqwTgLJh8kYxST4Z0vgh72U
# TELEGRAM_CHAT_IDS=-5075171894

View file

@ -0,0 +1,2 @@
# Copy this to .env and fill in your database URL
DATABASE_URL=postgresql://username:password@localhost:5432/dbname

View file

@ -0,0 +1,38 @@
# Database Helper - PostgreSQL
This package contains all database-related configuration, migrations, and schema definitions for the PostgreSQL database.
## Structure
- `src/db/` - Database source files
- `schema.ts` - Drizzle ORM schema definitions
- `db_index.ts` - Database connection and client setup
- `types.ts` - Database types
- `seed.ts` - Database seeding script
- `porter.ts` - Data migration utilities
- `drizzle/` - Migration files generated by Drizzle Kit
- `drizzle.config.ts` - Drizzle Kit configuration
## Environment Variables
Create a `.env` file with:
```
DATABASE_URL=postgresql://username:password@localhost:5432/dbname
```
## Scripts
- `npm run migrate` - Generate new migration files
- `npm run db:push` - Push schema changes to database
- `npm run db:seed` - Run database seeding
- `npm run db:studio` - Open Drizzle Studio
## Usage
This package can be used by other packages/apps in the monorepo:
```typescript
import { db } from '@packages/db_helper_postgres/src/db/db_index';
import { users } from '@packages/db_helper_postgres/src/db/schema';
```

View file

@ -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!,
},
});

View file

@ -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;

View file

@ -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";

View file

@ -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;

View file

@ -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";

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."order_status" ADD COLUMN "is_cancelled" boolean DEFAULT false NOT NULL;

View file

@ -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");

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_info" ADD COLUMN "is_out_of_stock" boolean DEFAULT false NOT NULL;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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");

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."delivery_slot_info" ADD COLUMN "delivery_sequence" jsonb;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."complaints" ADD COLUMN "response" varchar(1000);

View file

@ -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;

View file

@ -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";

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."user_details" ADD COLUMN "profile_image" varchar(500);

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_info" ADD COLUMN "market_price" numeric(10, 2);

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."orders" ADD COLUMN "is_refund_done" boolean DEFAULT false NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."orders" ADD COLUMN "user_notes" text;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."order_status" ADD COLUMN "is_payment_processed" boolean DEFAULT false NOT NULL;

View file

@ -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";

View file

@ -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";

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."users" ALTER COLUMN "name" DROP NOT NULL;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_info" ALTER COLUMN "store_id" SET NOT NULL;

View file

@ -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";

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."coupons" ADD COLUMN "exclusive_apply" boolean DEFAULT false NOT NULL;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."order_cancellations" RENAME COLUMN "razorpay_refund_id" TO "merchant_refund_id";

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1 @@
DROP TABLE "mf"."order_cancellations" CASCADE;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."complaints" ADD COLUMN "images" jsonb;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."store_info" ADD COLUMN "image_url" varchar(500);

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."orders" ADD COLUMN "delivery_charge" numeric(10, 2) DEFAULT '0' NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_info" ADD COLUMN "increment_step" real DEFAULT 1 NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_info" ALTER COLUMN "store_id" DROP NOT NULL;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."home_banners" ALTER COLUMN "serial_num" DROP NOT NULL;

View file

@ -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";

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."home_banners" DROP COLUMN "product_ids";

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."home_banners" ADD COLUMN "product_ids" integer[];

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."coupons" ADD COLUMN "applicable_users" jsonb;

View file

@ -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";

View file

@ -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);

View file

@ -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";

View file

@ -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;

View file

@ -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';

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."coupons" ALTER COLUMN "created_by" DROP NOT NULL;

View file

@ -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);

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."orders" ADD COLUMN "is_flash_delivery" boolean DEFAULT false NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_info" ADD COLUMN "product_quantity" real DEFAULT 1 NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."order_status" ADD COLUMN "is_cancelled_by_admin" boolean;

View file

@ -0,0 +1,2 @@
ALTER TABLE "mf"."vendor_snippets" ALTER COLUMN "slot_id" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "mf"."vendor_snippets" ADD COLUMN "is_permanent" boolean DEFAULT false NOT NULL;

View file

@ -0,0 +1,2 @@
ALTER TABLE "mf"."addresses" ADD COLUMN "admin_latitude" real;--> statement-breakpoint
ALTER TABLE "mf"."addresses" ADD COLUMN "admin_longitude" real;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."addresses" ADD COLUMN "google_maps_url" varchar(500);

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."delivery_slot_info" ADD COLUMN "group_ids" jsonb;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."product_tag_info" ADD COLUMN "related_stores" jsonb;

View file

@ -0,0 +1,7 @@
CREATE TABLE "mf"."user_notifications" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."user_notifications_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"image_url" varchar(500),
"created_at" timestamp DEFAULT now() NOT NULL,
"body" text NOT NULL,
"applicable_users" jsonb
);

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."user_notifications" ADD COLUMN "title" varchar(255) NOT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE "mf"."delivery_slot_info" ADD COLUMN "is_capacity_full" boolean DEFAULT false NOT NULL;

View file

@ -0,0 +1,7 @@
CREATE TABLE "mf"."unlogged_user_tokens" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."unlogged_user_tokens_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,
"last_verified" timestamp,
CONSTRAINT "unlogged_user_tokens_token_unique" UNIQUE("token")
);

View file

@ -0,0 +1,13 @@
CREATE TABLE "mf"."user_incidents" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "mf"."user_incidents_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"user_id" integer NOT NULL,
"order_id" integer,
"date_added" timestamp DEFAULT now() NOT NULL,
"admin_comment" text,
"added_by" integer,
"negativity_score" integer
);
--> statement-breakpoint
ALTER TABLE "mf"."user_incidents" ADD CONSTRAINT "user_incidents_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"."user_incidents" ADD CONSTRAINT "user_incidents_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"."user_incidents" ADD CONSTRAINT "user_incidents_added_by_staff_users_id_fk" FOREIGN KEY ("added_by") REFERENCES "mf"."staff_users"("id") ON DELETE no action ON UPDATE no action;

View file

@ -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": {}
}
}

View file

@ -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": {}
}
}

Some files were not shown because too many files have changed in this diff Show more