Skip to content

Commit

Permalink
Add jobs and stores entities
Browse files Browse the repository at this point in the history
  • Loading branch information
tazo90 committed Apr 15, 2022
1 parent 20f1f55 commit 8e448dd
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 27 deletions.
113 changes: 96 additions & 17 deletions src/lib/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ model Organization {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
jobs Job[]
stores Store[]
@@map(name: "organization")
}

Expand All @@ -75,8 +78,9 @@ model Country {
organizationId Int
applications Application[]
// application Application? @relation(fields: [applicationId], references: [id])
// applicationId Int?
job Job[]
store Store[]
@@unique([name, code])
@@map(name: "country")
}
Expand All @@ -89,26 +93,13 @@ model Brand {
organizationId Int
applications Application[]
// application Application? @relation(fields: [applicationId], references: [id])
// applicationId Int?
job Job[]
store Store[]
@@unique([name, organizationId])
@@map(name: "brand")
}

// model Country {
// id Int @id @default(autoincrement())
// name String @unique
// code String @unique
// organizations OrganizationCountry[]

// application Application? @relation(fields: [applicationId], references: [id])
// applicationId Int?

// @@unique([name, code])
// @@map(name: "country")
// }

enum MembershipRole {
MEMBER
ADMIN
Expand Down Expand Up @@ -216,3 +207,91 @@ model Component {
@@map(name: "component")
}

model Job {
id Int @id @default(autoincrement())
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
organizationId Int
brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
brandId Int
country Country @relation(fields: [countryId], references: [id], onDelete: Cascade)
countryId Int
profession_name String?
job_category_name String?
title String
banner_url String?
body String?
footer String?
apply_url String?
is_manager Boolean?
language String?
externalId String
@@map(name: "job")
}

enum StoreType {
RESTAURANT
FASTFOOD
}

enum StoreStatus {
CLOSED
OPEN
}

model Store {
id Int @id @default(autoincrement())
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
organizationId Int
brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
brandId Int
country Country @relation(fields: [countryId], references: [id], onDelete: Cascade)
countryId Int
osm_id String?
store_id String?
cost_center String?
type StoreType @default(FASTFOOD)
status StoreStatus @default(OPEN)
lat String
lng String
name String
name_osm String?
address_osm String?
address_google String?
address String?
located_in_name String?
located_in_url String?
phone String?
image_place_url String?
image_street_view_url String?
manu_url String?
map_url String?
order_url String?
street_view_url String?
reviews_url String?
payment_types String[]
photos String[]
orders Json
features String[]
services Json
franchisee_details Json
opening_hours Json
ownership String
@@map(name: "store")
}
16 changes: 6 additions & 10 deletions src/lib/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
PrismaClient,
Prisma,
User,
Organization,
MembershipRole,
UserPlan,
} from "@prisma/client";
import { PrismaClient, Prisma, MembershipRole, UserPlan } from "@prisma/client";

import { hashPassword } from "../auth";
import data from "./fixtures/amrest";
Expand Down Expand Up @@ -134,8 +127,11 @@ async function createApps(organization: any, user: any, apps: any) {
await prisma.application.create({
data: {
...app,
userId: user.id,
organizationId: organization.id,
user: { connect: { id: user.id } },
organization: { connect: { id: organization.id } },
expires: new Date(
"Tue Sep 21 2022 16:16:50 GMT-0400 (Eastern Daylight Time)"
),
},
});
});
Expand Down

0 comments on commit 8e448dd

Please sign in to comment.