@the-inkwell/shared 0.1.164 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -1
- package/dist/src/constants.js +276 -0
- package/dist/src/schema/admin/actions/index.js +32 -0
- package/dist/src/schema/admin/campaigns/index.js +68 -0
- package/dist/src/schema/admin/candidacies/index.js +83 -0
- package/dist/src/schema/admin/clients/index.js +30 -0
- package/dist/src/schema/admin/educations/index.js +23 -0
- package/dist/src/schema/admin/experiences/index.js +37 -0
- package/dist/src/schema/admin/files/index.js +7 -0
- package/dist/src/{types/models → schema}/admin/index.js +18 -1
- package/dist/src/schema/admin/jobFunctions/index.js +32 -0
- package/dist/src/schema/admin/listViews/index.js +22 -0
- package/dist/src/schema/admin/locations/index.js +16 -0
- package/dist/src/schema/admin/messages/index.js +51 -0
- package/dist/src/schema/admin/notes/index.js +27 -0
- package/dist/src/schema/admin/partners/index.js +25 -0
- package/dist/src/schema/admin/persons/index.js +194 -0
- package/dist/src/schema/admin/personsToBestPersons/index.js +18 -0
- package/dist/src/schema/admin/personsToSkills/index.js +18 -0
- package/dist/src/schema/admin/personsToTags/index.js +18 -0
- package/dist/src/schema/admin/positions/index.js +58 -0
- package/dist/src/schema/admin/positionsToSkills/index.js +18 -0
- package/dist/src/schema/admin/positionsToTags/index.js +18 -0
- package/dist/src/schema/admin/referrals/index.js +64 -0
- package/dist/src/schema/admin/referralsToMessages/index.js +55 -0
- package/dist/src/schema/admin/senders/index.js +16 -0
- package/dist/src/schema/admin/sendgrid/index.js +10 -0
- package/dist/src/schema/admin/settings/index.js +21 -0
- package/dist/src/schema/admin/skills/index.js +32 -0
- package/dist/src/schema/admin/tags/index.js +29 -0
- package/dist/src/schema/admin/websiteLandingPages/index.js +16 -0
- package/dist/src/schema/admin/websiteStaticPages/index.js +16 -0
- package/dist/src/schema/auth/index.js +11 -0
- package/dist/src/schema/core.js +1469 -0
- package/dist/src/{types/models → schema}/index.js +1 -1
- package/dist/src/utils.js +16 -0
- package/index.ts +2 -1
- package/package.json +9 -2
- package/src/constants.ts +299 -0
- package/src/schema/admin/actions/index.ts +65 -0
- package/src/schema/admin/campaigns/index.ts +111 -0
- package/src/schema/admin/candidacies/index.ts +138 -0
- package/src/schema/admin/clients/index.ts +65 -0
- package/src/schema/admin/dashboard/index.ts +10 -0
- package/src/schema/admin/educations/index.ts +71 -0
- package/src/schema/admin/experiences/index.ts +87 -0
- package/src/schema/admin/files/index.ts +10 -0
- package/src/schema/admin/index.ts +29 -0
- package/src/schema/admin/jobFunctions/index.ts +79 -0
- package/src/schema/admin/listViews/index.ts +58 -0
- package/src/schema/admin/locations/index.ts +42 -0
- package/src/schema/admin/messages/index.ts +88 -0
- package/src/schema/admin/notes/index.ts +56 -0
- package/src/schema/admin/partners/index.ts +60 -0
- package/src/schema/admin/persons/index.ts +294 -0
- package/src/schema/admin/personsToBestPersons/index.ts +67 -0
- package/src/schema/admin/personsToSkills/index.ts +61 -0
- package/src/schema/admin/personsToTags/index.ts +61 -0
- package/src/schema/admin/positions/index.ts +97 -0
- package/src/schema/admin/positionsToSkills/index.ts +64 -0
- package/src/schema/admin/positionsToTags/index.ts +61 -0
- package/src/schema/admin/referrals/index.ts +100 -0
- package/src/schema/admin/referralsToMessages/index.ts +121 -0
- package/src/schema/admin/senders/index.ts +50 -0
- package/src/schema/admin/sendgrid/index.ts +16 -0
- package/src/schema/admin/settings/index.ts +34 -0
- package/src/schema/admin/skills/index.ts +64 -0
- package/src/schema/admin/tags/index.ts +56 -0
- package/src/schema/admin/websiteLandingPages/index.ts +69 -0
- package/src/schema/admin/websiteStaticPages/index.ts +67 -0
- package/src/schema/auth/index.ts +14 -0
- package/src/schema/core.ts +1906 -0
- package/src/{types/models → schema}/index.ts +1 -1
- package/src/utils.ts +41 -0
- package/README.md +0 -9
- package/dist/src/constants/enums.js +0 -209
- package/dist/src/constants/index.js +0 -17
- package/dist/src/types/_schema/Action.js +0 -4
- package/dist/src/types/_schema/ActionNames.js +0 -4
- package/dist/src/types/_schema/Actions.js +0 -4
- package/dist/src/types/_schema/Admin.js +0 -4
- package/dist/src/types/_schema/Admins.js +0 -4
- package/dist/src/types/_schema/Campaign.js +0 -4
- package/dist/src/types/_schema/CampaignStatuses.js +0 -4
- package/dist/src/types/_schema/CampaignToPosition.js +0 -4
- package/dist/src/types/_schema/Campaigns.js +0 -4
- package/dist/src/types/_schema/CampaignsToPositions.js +0 -4
- package/dist/src/types/_schema/Candidacies.js +0 -4
- package/dist/src/types/_schema/Candidacy.js +0 -4
- package/dist/src/types/_schema/CandidacyFeedback.js +0 -4
- package/dist/src/types/_schema/CandidacyRatingCategories.js +0 -4
- package/dist/src/types/_schema/CandidacyRatingReasons.js +0 -4
- package/dist/src/types/_schema/CandidacyRatingToTag.js +0 -4
- package/dist/src/types/_schema/CandidacyRatings.js +0 -4
- package/dist/src/types/_schema/CandidacyRatingsToTags.js +0 -4
- package/dist/src/types/_schema/CandidacySources.js +0 -4
- package/dist/src/types/_schema/CandidacyStages.js +0 -4
- package/dist/src/types/_schema/CandidacyStatuses.js +0 -4
- package/dist/src/types/_schema/Certifications.js +0 -4
- package/dist/src/types/_schema/Client.js +0 -4
- package/dist/src/types/_schema/ClientStages.js +0 -4
- package/dist/src/types/_schema/ClientStatuses.js +0 -4
- package/dist/src/types/_schema/Clients.js +0 -4
- package/dist/src/types/_schema/Clubs.js +0 -4
- package/dist/src/types/_schema/Contract.js +0 -4
- package/dist/src/types/_schema/Contracts.js +0 -4
- package/dist/src/types/_schema/Conversation.js +0 -4
- package/dist/src/types/_schema/Conversations.js +0 -4
- package/dist/src/types/_schema/EducationDegrees.js +0 -4
- package/dist/src/types/_schema/EducationFields.js +0 -4
- package/dist/src/types/_schema/Educations.js +0 -4
- package/dist/src/types/_schema/EnrichmentSources.js +0 -4
- package/dist/src/types/_schema/Enrichments.js +0 -4
- package/dist/src/types/_schema/Experiences.js +0 -4
- package/dist/src/types/_schema/Genders.js +0 -4
- package/dist/src/types/_schema/Industries.js +0 -4
- package/dist/src/types/_schema/JobFunctions.js +0 -4
- package/dist/src/types/_schema/JobLevels.js +0 -4
- package/dist/src/types/_schema/Jwt.js +0 -4
- package/dist/src/types/_schema/Jwts.js +0 -4
- package/dist/src/types/_schema/ListView.js +0 -4
- package/dist/src/types/_schema/ListViewModels.js +0 -4
- package/dist/src/types/_schema/ListViews.js +0 -4
- package/dist/src/types/_schema/Message.js +0 -4
- package/dist/src/types/_schema/MessageChannels.js +0 -4
- package/dist/src/types/_schema/MessageTemplate.js +0 -4
- package/dist/src/types/_schema/MessageTemplates.js +0 -4
- package/dist/src/types/_schema/Messages.js +0 -4
- package/dist/src/types/_schema/Networks.js +0 -4
- package/dist/src/types/_schema/Note.js +0 -4
- package/dist/src/types/_schema/Notes.js +0 -4
- package/dist/src/types/_schema/Otp.js +0 -4
- package/dist/src/types/_schema/Otps.js +0 -4
- package/dist/src/types/_schema/Partners.js +0 -4
- package/dist/src/types/_schema/Person.js +0 -4
- package/dist/src/types/_schema/PersonCareerLevels.js +0 -4
- package/dist/src/types/_schema/PersonClub.js +0 -4
- package/dist/src/types/_schema/PersonClubs.js +0 -4
- package/dist/src/types/_schema/PersonDegrees.js +0 -4
- package/dist/src/types/_schema/PersonEnrichment.js +0 -4
- package/dist/src/types/_schema/PersonEnrichments.js +0 -4
- package/dist/src/types/_schema/PersonGenders.js +0 -4
- package/dist/src/types/_schema/PersonNetwork.js +0 -4
- package/dist/src/types/_schema/PersonNetworks.js +0 -4
- package/dist/src/types/_schema/PersonSkill.js +0 -4
- package/dist/src/types/_schema/PersonSkills.js +0 -4
- package/dist/src/types/_schema/PersonSources.js +0 -4
- package/dist/src/types/_schema/PersonToBestPerson.js +0 -4
- package/dist/src/types/_schema/PersonToPersonClub.js +0 -4
- package/dist/src/types/_schema/PersonToPersonNetwork.js +0 -4
- package/dist/src/types/_schema/PersonToPersonSkill.js +0 -4
- package/dist/src/types/_schema/PersonToTag.js +0 -4
- package/dist/src/types/_schema/Persons.js +0 -4
- package/dist/src/types/_schema/PersonsToBestPersons.js +0 -4
- package/dist/src/types/_schema/PersonsToCertifications.js +0 -4
- package/dist/src/types/_schema/PersonsToClubs.js +0 -4
- package/dist/src/types/_schema/PersonsToIndustries.js +0 -4
- package/dist/src/types/_schema/PersonsToNetworks.js +0 -4
- package/dist/src/types/_schema/PersonsToPersonClubs.js +0 -4
- package/dist/src/types/_schema/PersonsToPersonNetworks.js +0 -4
- package/dist/src/types/_schema/PersonsToPersonSkills.js +0 -4
- package/dist/src/types/_schema/PersonsToSkills.js +0 -4
- package/dist/src/types/_schema/PersonsToTags.js +0 -4
- package/dist/src/types/_schema/Position.js +0 -4
- package/dist/src/types/_schema/PositionRatingCategories.js +0 -4
- package/dist/src/types/_schema/PositionRatings.js +0 -4
- package/dist/src/types/_schema/PositionStages.js +0 -4
- package/dist/src/types/_schema/PositionStatuses.js +0 -4
- package/dist/src/types/_schema/Positions.js +0 -4
- package/dist/src/types/_schema/PositionsToIndustries.js +0 -4
- package/dist/src/types/_schema/PositionsToPersonSkills.js +0 -4
- package/dist/src/types/_schema/PositionsToSkills.js +0 -4
- package/dist/src/types/_schema/PositionsToTags.js +0 -4
- package/dist/src/types/_schema/PublicSchema.js +0 -4
- package/dist/src/types/_schema/Referral.js +0 -4
- package/dist/src/types/_schema/ReferralPayout.js +0 -4
- package/dist/src/types/_schema/ReferralPayouts.js +0 -4
- package/dist/src/types/_schema/ReferralSources.js +0 -4
- package/dist/src/types/_schema/ReferralToIntroMessage.js +0 -4
- package/dist/src/types/_schema/Referrals.js +0 -4
- package/dist/src/types/_schema/ReferralsToIntroMessages.js +0 -4
- package/dist/src/types/_schema/ReferralsToMessages.js +0 -4
- package/dist/src/types/_schema/Sender.js +0 -4
- package/dist/src/types/_schema/Senders.js +0 -4
- package/dist/src/types/_schema/Skills.js +0 -4
- package/dist/src/types/_schema/Tag.js +0 -4
- package/dist/src/types/_schema/Tags.js +0 -4
- package/dist/src/types/_schema/WebsiteBlock.js +0 -4
- package/dist/src/types/_schema/WebsiteBlocks.js +0 -4
- package/dist/src/types/_schema/WebsiteLandingPage.js +0 -4
- package/dist/src/types/_schema/WebsiteLandingPages.js +0 -4
- package/dist/src/types/_schema/WebsiteStaticPage.js +0 -4
- package/dist/src/types/_schema/WebsiteStaticPages.js +0 -4
- package/dist/src/types/admin/index.js +0 -19
- package/dist/src/types/admin/persons/index.js +0 -2
- package/dist/src/types/admin/website/index.js +0 -2
- package/dist/src/types/auth/index.js +0 -2
- package/dist/src/types/db.js +0 -6
- package/dist/src/types/http/admin/candidacies/index.js +0 -2
- package/dist/src/types/http/admin/index.js +0 -19
- package/dist/src/types/http/admin/persons/index.js +0 -2
- package/dist/src/types/http/admin/website/index.js +0 -2
- package/dist/src/types/http/auth/index.js +0 -2
- package/dist/src/types/http/index.js +0 -19
- package/dist/src/types/http/utils/index.js +0 -2
- package/dist/src/types/index.js +0 -18
- package/dist/src/types/models/admin/campaigns/index.js +0 -2
- package/dist/src/types/models/admin/candidacies/index.js +0 -2
- package/dist/src/types/models/admin/clients/index.js +0 -2
- package/dist/src/types/models/admin/conversations/index.js +0 -2
- package/dist/src/types/models/admin/listViews/index.js +0 -2
- package/dist/src/types/models/admin/locations/index.js +0 -2
- package/dist/src/types/models/admin/messages/index.js +0 -2
- package/dist/src/types/models/admin/partners/index.js +0 -2
- package/dist/src/types/models/admin/persons/index.js +0 -2
- package/dist/src/types/models/admin/positions/index.js +0 -23
- package/dist/src/types/models/admin/referrals/index.js +0 -2
- package/dist/src/types/models/admin/settings/index.js +0 -2
- package/dist/src/types/models/admin/website/_shared.js +0 -2
- package/dist/src/types/models/admin/website/home.js +0 -2
- package/dist/src/types/models/admin/website/index.js +0 -18
- package/dist/src/types/models/admin/website/shared.js +0 -2
- package/dist/src/types/models/auth/index.js +0 -2
- package/dist/src/types/schemas/Database.js +0 -4
- package/dist/src/types/schemas/index.js +0 -23
- package/dist/src/types/schemas/public/Action.js +0 -4
- package/dist/src/types/schemas/public/ActionNames.js +0 -4
- package/dist/src/types/schemas/public/Admin.js +0 -4
- package/dist/src/types/schemas/public/Campaign.js +0 -4
- package/dist/src/types/schemas/public/CampaignStatuses.js +0 -4
- package/dist/src/types/schemas/public/CampaignToPosition.js +0 -4
- package/dist/src/types/schemas/public/Candidacy.js +0 -4
- package/dist/src/types/schemas/public/CandidacyFeedback.js +0 -4
- package/dist/src/types/schemas/public/CandidacyRatingToTag.js +0 -4
- package/dist/src/types/schemas/public/CandidacySources.js +0 -4
- package/dist/src/types/schemas/public/CandidacyStatuses.js +0 -4
- package/dist/src/types/schemas/public/Client.js +0 -4
- package/dist/src/types/schemas/public/ClientStatuses.js +0 -4
- package/dist/src/types/schemas/public/Contract.js +0 -4
- package/dist/src/types/schemas/public/Conversation.js +0 -4
- package/dist/src/types/schemas/public/EnrichmentSources.js +0 -4
- package/dist/src/types/schemas/public/Jwt.js +0 -4
- package/dist/src/types/schemas/public/ListView.js +0 -4
- package/dist/src/types/schemas/public/ListViewModels.js +0 -4
- package/dist/src/types/schemas/public/Message.js +0 -4
- package/dist/src/types/schemas/public/MessageChannels.js +0 -4
- package/dist/src/types/schemas/public/MessageSender.js +0 -4
- package/dist/src/types/schemas/public/MessageTemplate.js +0 -4
- package/dist/src/types/schemas/public/Note.js +0 -4
- package/dist/src/types/schemas/public/Otp.js +0 -4
- package/dist/src/types/schemas/public/Person.js +0 -4
- package/dist/src/types/schemas/public/PersonCareerLevels.js +0 -4
- package/dist/src/types/schemas/public/PersonClub.js +0 -4
- package/dist/src/types/schemas/public/PersonDegrees.js +0 -4
- package/dist/src/types/schemas/public/PersonEnrichment.js +0 -4
- package/dist/src/types/schemas/public/PersonGenders.js +0 -4
- package/dist/src/types/schemas/public/PersonNetwork.js +0 -4
- package/dist/src/types/schemas/public/PersonSkill.js +0 -4
- package/dist/src/types/schemas/public/PersonSources.js +0 -4
- package/dist/src/types/schemas/public/PersonToBestPerson.js +0 -4
- package/dist/src/types/schemas/public/PersonToPersonClub.js +0 -4
- package/dist/src/types/schemas/public/PersonToPersonNetwork.js +0 -4
- package/dist/src/types/schemas/public/PersonToPersonSkill.js +0 -4
- package/dist/src/types/schemas/public/PersonToTag.js +0 -4
- package/dist/src/types/schemas/public/Position.js +0 -4
- package/dist/src/types/schemas/public/PositionStatuses.js +0 -4
- package/dist/src/types/schemas/public/PrismaMigrations.js +0 -4
- package/dist/src/types/schemas/public/PublicSchema.js +0 -4
- package/dist/src/types/schemas/public/Referral.js +0 -4
- package/dist/src/types/schemas/public/ReferralPayout.js +0 -4
- package/dist/src/types/schemas/public/ReferralSources.js +0 -4
- package/dist/src/types/schemas/public/ReferralToIntroMessage.js +0 -4
- package/dist/src/types/schemas/public/Sender.js +0 -4
- package/dist/src/types/schemas/public/Tag.js +0 -4
- package/dist/src/types/schemas/public/WebsiteBlock.js +0 -4
- package/dist/src/types/schemas/public/WebsiteLandingPage.js +0 -4
- package/dist/src/types/schemas/public/WebsiteStaticPage.js +0 -4
- package/dist/src/types/shared/index.js +0 -2
- package/dist/src/types/utils/index.js +0 -2
- package/dist/types/admin/index.js +0 -17
- package/dist/types/admin/website/index.js +0 -2
- package/dist/types/index.js +0 -17
- package/src/constants/enums.ts +0 -251
- package/src/constants/index.ts +0 -1
- package/src/types/_schema/ActionNames.ts +0 -11
- package/src/types/_schema/Actions.ts +0 -104
- package/src/types/_schema/Admins.ts +0 -49
- package/src/types/_schema/CampaignStatuses.ts +0 -10
- package/src/types/_schema/Campaigns.ts +0 -76
- package/src/types/_schema/CampaignsToPositions.ts +0 -33
- package/src/types/_schema/Candidacies.ts +0 -77
- package/src/types/_schema/CandidacyFeedback.ts +0 -55
- package/src/types/_schema/CandidacyRatingCategories.ts +0 -12
- package/src/types/_schema/CandidacyRatings.ts +0 -42
- package/src/types/_schema/CandidacySources.ts +0 -11
- package/src/types/_schema/CandidacyStages.ts +0 -14
- package/src/types/_schema/CandidacyStatuses.ts +0 -9
- package/src/types/_schema/Certifications.ts +0 -59
- package/src/types/_schema/ClientStages.ts +0 -12
- package/src/types/_schema/ClientStatuses.ts +0 -9
- package/src/types/_schema/Clients.ts +0 -69
- package/src/types/_schema/Contracts.ts +0 -68
- package/src/types/_schema/EducationDegrees.ts +0 -12
- package/src/types/_schema/EducationFields.ts +0 -18
- package/src/types/_schema/Educations.ts +0 -55
- package/src/types/_schema/EnrichmentSources.ts +0 -8
- package/src/types/_schema/Enrichments.ts +0 -68
- package/src/types/_schema/Experiences.ts +0 -87
- package/src/types/_schema/Genders.ts +0 -11
- package/src/types/_schema/Industries.ts +0 -53
- package/src/types/_schema/JobFunctions.ts +0 -53
- package/src/types/_schema/JobLevels.ts +0 -13
- package/src/types/_schema/Jwts.ts +0 -61
- package/src/types/_schema/ListViewModels.ts +0 -11
- package/src/types/_schema/ListViews.ts +0 -74
- package/src/types/_schema/MessageChannels.ts +0 -9
- package/src/types/_schema/MessageTemplates.ts +0 -53
- package/src/types/_schema/Messages.ts +0 -109
- package/src/types/_schema/Networks.ts +0 -59
- package/src/types/_schema/Notes.ts +0 -76
- package/src/types/_schema/Otps.ts +0 -67
- package/src/types/_schema/Partners.ts +0 -65
- package/src/types/_schema/PersonSources.ts +0 -11
- package/src/types/_schema/Persons.ts +0 -237
- package/src/types/_schema/PersonsToBestPersons.ts +0 -32
- package/src/types/_schema/PersonsToCertifications.ts +0 -26
- package/src/types/_schema/PersonsToNetworks.ts +0 -33
- package/src/types/_schema/PersonsToSkills.ts +0 -33
- package/src/types/_schema/PersonsToTags.ts +0 -33
- package/src/types/_schema/PositionRatingCategories.ts +0 -9
- package/src/types/_schema/PositionRatings.ts +0 -42
- package/src/types/_schema/PositionStages.ts +0 -12
- package/src/types/_schema/PositionStatuses.ts +0 -9
- package/src/types/_schema/Positions.ts +0 -119
- package/src/types/_schema/PositionsToIndustries.ts +0 -33
- package/src/types/_schema/PositionsToSkills.ts +0 -33
- package/src/types/_schema/PositionsToTags.ts +0 -33
- package/src/types/_schema/ReferralPayouts.ts +0 -29
- package/src/types/_schema/ReferralSources.ts +0 -11
- package/src/types/_schema/Referrals.ts +0 -83
- package/src/types/_schema/ReferralsToMessages.ts +0 -40
- package/src/types/_schema/Senders.ts +0 -65
- package/src/types/_schema/Skills.ts +0 -53
- package/src/types/_schema/Tags.ts +0 -53
- package/src/types/_schema/WebsiteBlocks.ts +0 -45
- package/src/types/_schema/WebsiteLandingPages.ts +0 -47
- package/src/types/_schema/WebsiteStaticPages.ts +0 -53
- package/src/types/index.ts +0 -2
- package/src/types/models/admin/campaigns/index.ts +0 -28
- package/src/types/models/admin/candidacies/index.ts +0 -69
- package/src/types/models/admin/clients/index.ts +0 -49
- package/src/types/models/admin/index.ts +0 -12
- package/src/types/models/admin/listViews/index.ts +0 -48
- package/src/types/models/admin/locations/index.ts +0 -28
- package/src/types/models/admin/messages/index.ts +0 -14
- package/src/types/models/admin/partners/index.ts +0 -36
- package/src/types/models/admin/persons/index.ts +0 -90
- package/src/types/models/admin/positions/index.ts +0 -72
- package/src/types/models/admin/referrals/index.ts +0 -67
- package/src/types/models/admin/settings/index.ts +0 -24
- package/src/types/models/admin/website/home.ts +0 -42
- package/src/types/models/admin/website/index.ts +0 -2
- package/src/types/models/admin/website/shared.ts +0 -40
- package/src/types/models/auth/index.ts +0 -6
- package/src/types/utils/index.ts +0 -15
- /package/dist/src/{types/admin/candidacies → schema/admin/dashboard}/index.js +0 -0
|
@@ -0,0 +1,1906 @@
|
|
|
1
|
+
import {
|
|
2
|
+
pgTable,
|
|
3
|
+
timestamp,
|
|
4
|
+
text,
|
|
5
|
+
integer,
|
|
6
|
+
foreignKey,
|
|
7
|
+
uuid,
|
|
8
|
+
jsonb,
|
|
9
|
+
uniqueIndex,
|
|
10
|
+
serial,
|
|
11
|
+
boolean,
|
|
12
|
+
doublePrecision,
|
|
13
|
+
primaryKey,
|
|
14
|
+
pgEnum
|
|
15
|
+
} from 'drizzle-orm/pg-core'
|
|
16
|
+
import { relations, sql, SQL } from 'drizzle-orm'
|
|
17
|
+
import { makeEnumFromObj } from '../utils'
|
|
18
|
+
import {
|
|
19
|
+
ACTIONS,
|
|
20
|
+
CANDIDACY_ASSESSMENT_CATEGORIES,
|
|
21
|
+
CANDIDACY_REJECTORS,
|
|
22
|
+
CANDIDACY_SOURCES,
|
|
23
|
+
CANDIDACY_STAGES,
|
|
24
|
+
CLIENT_STATUSES,
|
|
25
|
+
COUNTRIES,
|
|
26
|
+
EDUCATION_DEGREES,
|
|
27
|
+
EDUCATION_FIELDS,
|
|
28
|
+
EMPLOYMENT_LOCATION_TYPES,
|
|
29
|
+
EMPLOYMENT_TYPES,
|
|
30
|
+
ENRICHMENT_SOURCES,
|
|
31
|
+
GENDERS,
|
|
32
|
+
JOB_LEVELS,
|
|
33
|
+
LIST_VIEW_MODELS,
|
|
34
|
+
MESSAGE_CHANNELS,
|
|
35
|
+
MESSAGE_STATUSES,
|
|
36
|
+
PERSON_SOURCES,
|
|
37
|
+
POSITION_CLOSED_REASONS,
|
|
38
|
+
REFERRAL_SOURCES,
|
|
39
|
+
STATES
|
|
40
|
+
} from '../constants'
|
|
41
|
+
|
|
42
|
+
// enums
|
|
43
|
+
|
|
44
|
+
export const Actions = pgEnum('action', makeEnumFromObj(ACTIONS))
|
|
45
|
+
|
|
46
|
+
export const CandidacyAssessmentCategories = pgEnum(
|
|
47
|
+
'candidacy_assessment_category',
|
|
48
|
+
makeEnumFromObj(CANDIDACY_ASSESSMENT_CATEGORIES)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
export const CandidacyRejectors = pgEnum(
|
|
52
|
+
'candidacy_rejector',
|
|
53
|
+
makeEnumFromObj(CANDIDACY_REJECTORS)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
export const CandidacySources = pgEnum(
|
|
57
|
+
'candidacy_source',
|
|
58
|
+
makeEnumFromObj(CANDIDACY_SOURCES)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
export const CandidacyStages = pgEnum(
|
|
62
|
+
'candidacy_stage',
|
|
63
|
+
makeEnumFromObj(CANDIDACY_STAGES)
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
export const ClientStatuses = pgEnum(
|
|
67
|
+
'client_status',
|
|
68
|
+
makeEnumFromObj(CLIENT_STATUSES)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
export const Countries = pgEnum('country', makeEnumFromObj(COUNTRIES))
|
|
72
|
+
|
|
73
|
+
export const EducationDegrees = pgEnum(
|
|
74
|
+
'education_degree',
|
|
75
|
+
makeEnumFromObj(EDUCATION_DEGREES)
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
export const EducationFields = pgEnum(
|
|
79
|
+
'education_field',
|
|
80
|
+
makeEnumFromObj(EDUCATION_FIELDS)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
export const EmploymentTypes = pgEnum(
|
|
84
|
+
'employment_type',
|
|
85
|
+
makeEnumFromObj(EMPLOYMENT_TYPES)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
export const EmploymentLocationTypes = pgEnum(
|
|
89
|
+
'employment_location_type',
|
|
90
|
+
makeEnumFromObj(EMPLOYMENT_LOCATION_TYPES)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
export const EnrichmentSources = pgEnum(
|
|
94
|
+
'enrichment_source',
|
|
95
|
+
makeEnumFromObj(ENRICHMENT_SOURCES)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
export const Genders = pgEnum('gender', makeEnumFromObj(GENDERS))
|
|
99
|
+
|
|
100
|
+
export const JobLevels = pgEnum('job_level', makeEnumFromObj(JOB_LEVELS))
|
|
101
|
+
|
|
102
|
+
export const ListViewModels = pgEnum(
|
|
103
|
+
'list_view_model',
|
|
104
|
+
makeEnumFromObj(LIST_VIEW_MODELS)
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
export const MessageChannels = pgEnum(
|
|
108
|
+
'message_channel',
|
|
109
|
+
makeEnumFromObj(MESSAGE_CHANNELS)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
export const MessageStatuses = pgEnum(
|
|
113
|
+
'message_status',
|
|
114
|
+
makeEnumFromObj(MESSAGE_STATUSES)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
export const PersonSources = pgEnum(
|
|
118
|
+
'person_source',
|
|
119
|
+
makeEnumFromObj(PERSON_SOURCES)
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
export const PositionClosedReasons = pgEnum(
|
|
123
|
+
'position_closed_reason',
|
|
124
|
+
makeEnumFromObj(POSITION_CLOSED_REASONS)
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
export const ReferralSources = pgEnum(
|
|
128
|
+
'referral_source',
|
|
129
|
+
makeEnumFromObj(REFERRAL_SOURCES)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
export const States = pgEnum('state', makeEnumFromObj(STATES))
|
|
133
|
+
|
|
134
|
+
// tables
|
|
135
|
+
|
|
136
|
+
export const action = pgTable(
|
|
137
|
+
'actions',
|
|
138
|
+
{
|
|
139
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
140
|
+
candidacyId: uuid(),
|
|
141
|
+
clientId: uuid(),
|
|
142
|
+
messageId: uuid(),
|
|
143
|
+
campaignId: uuid(),
|
|
144
|
+
noteId: uuid(),
|
|
145
|
+
personId: uuid(),
|
|
146
|
+
positionId: uuid(),
|
|
147
|
+
referralId: uuid(),
|
|
148
|
+
data: jsonb().$type<any>().notNull(),
|
|
149
|
+
name: Actions().notNull(),
|
|
150
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
151
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
152
|
+
.defaultNow()
|
|
153
|
+
.notNull(),
|
|
154
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
155
|
+
.defaultNow()
|
|
156
|
+
.notNull()
|
|
157
|
+
},
|
|
158
|
+
(table) => [
|
|
159
|
+
foreignKey({
|
|
160
|
+
columns: [table.candidacyId],
|
|
161
|
+
foreignColumns: [candidacy.id],
|
|
162
|
+
name: 'Action_candidacyId_fkey'
|
|
163
|
+
})
|
|
164
|
+
.onUpdate('cascade')
|
|
165
|
+
.onDelete('set null'),
|
|
166
|
+
foreignKey({
|
|
167
|
+
columns: [table.clientId],
|
|
168
|
+
foreignColumns: [client.id],
|
|
169
|
+
name: 'Action_clientId_fkey'
|
|
170
|
+
})
|
|
171
|
+
.onUpdate('cascade')
|
|
172
|
+
.onDelete('set null'),
|
|
173
|
+
foreignKey({
|
|
174
|
+
columns: [table.messageId],
|
|
175
|
+
foreignColumns: [message.id],
|
|
176
|
+
name: 'Action_messageId_fkey'
|
|
177
|
+
})
|
|
178
|
+
.onUpdate('cascade')
|
|
179
|
+
.onDelete('set null'),
|
|
180
|
+
foreignKey({
|
|
181
|
+
columns: [table.noteId],
|
|
182
|
+
foreignColumns: [note.id],
|
|
183
|
+
name: 'Action_noteId_fkey'
|
|
184
|
+
})
|
|
185
|
+
.onUpdate('cascade')
|
|
186
|
+
.onDelete('set null'),
|
|
187
|
+
foreignKey({
|
|
188
|
+
columns: [table.positionId],
|
|
189
|
+
foreignColumns: [position.id],
|
|
190
|
+
name: 'Action_positionId_fkey'
|
|
191
|
+
})
|
|
192
|
+
.onUpdate('cascade')
|
|
193
|
+
.onDelete('set null'),
|
|
194
|
+
foreignKey({
|
|
195
|
+
columns: [table.referralId],
|
|
196
|
+
foreignColumns: [referral.id],
|
|
197
|
+
name: 'Action_referralId_fkey'
|
|
198
|
+
})
|
|
199
|
+
.onUpdate('cascade')
|
|
200
|
+
.onDelete('set null'),
|
|
201
|
+
foreignKey({
|
|
202
|
+
columns: [table.personId],
|
|
203
|
+
foreignColumns: [person.id],
|
|
204
|
+
name: 'Action_personId_fkey'
|
|
205
|
+
})
|
|
206
|
+
.onUpdate('cascade')
|
|
207
|
+
.onDelete('set null'),
|
|
208
|
+
foreignKey({
|
|
209
|
+
columns: [table.campaignId],
|
|
210
|
+
foreignColumns: [campaign.id],
|
|
211
|
+
name: 'Action_campaignId_fkey'
|
|
212
|
+
})
|
|
213
|
+
.onUpdate('cascade')
|
|
214
|
+
.onDelete('set null')
|
|
215
|
+
]
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
export const admin = pgTable(
|
|
219
|
+
'admins',
|
|
220
|
+
{
|
|
221
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
222
|
+
personId: uuid().notNull(),
|
|
223
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
224
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
225
|
+
.defaultNow()
|
|
226
|
+
.notNull(),
|
|
227
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
228
|
+
.defaultNow()
|
|
229
|
+
.notNull()
|
|
230
|
+
},
|
|
231
|
+
(table) => [
|
|
232
|
+
uniqueIndex('Admin_personId_key').using(
|
|
233
|
+
'btree',
|
|
234
|
+
table.personId.asc().nullsLast().op('uuid_ops')
|
|
235
|
+
),
|
|
236
|
+
foreignKey({
|
|
237
|
+
columns: [table.personId],
|
|
238
|
+
foreignColumns: [person.id],
|
|
239
|
+
name: 'Admin_personId_fkey'
|
|
240
|
+
})
|
|
241
|
+
.onUpdate('cascade')
|
|
242
|
+
.onDelete('restrict')
|
|
243
|
+
]
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
export const certification = pgTable(
|
|
247
|
+
'certifications',
|
|
248
|
+
{
|
|
249
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
250
|
+
slug: text().notNull(),
|
|
251
|
+
name: text().notNull(),
|
|
252
|
+
description: text(),
|
|
253
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
254
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
255
|
+
.defaultNow()
|
|
256
|
+
.notNull(),
|
|
257
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
258
|
+
.defaultNow()
|
|
259
|
+
.notNull()
|
|
260
|
+
},
|
|
261
|
+
(table) => [
|
|
262
|
+
uniqueIndex('Certification_slug_key').using(
|
|
263
|
+
'btree',
|
|
264
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
265
|
+
)
|
|
266
|
+
]
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
export const client = pgTable('clients', {
|
|
270
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
271
|
+
name: text().notNull(),
|
|
272
|
+
description: text(),
|
|
273
|
+
isLead: boolean().default(false).notNull(),
|
|
274
|
+
status: ClientStatuses().default('ACTIVE'),
|
|
275
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
276
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
277
|
+
.defaultNow()
|
|
278
|
+
.notNull(),
|
|
279
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
280
|
+
.defaultNow()
|
|
281
|
+
.notNull()
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
export const campaign = pgTable(
|
|
285
|
+
'campaigns',
|
|
286
|
+
{
|
|
287
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
288
|
+
name: text().notNull(),
|
|
289
|
+
senderId: uuid(),
|
|
290
|
+
messageChannel: MessageChannels().notNull(),
|
|
291
|
+
content: jsonb().$type<any>(),
|
|
292
|
+
listViewId: uuid(),
|
|
293
|
+
externalId: text(),
|
|
294
|
+
sentAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
295
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
296
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
297
|
+
.defaultNow()
|
|
298
|
+
.notNull(),
|
|
299
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
300
|
+
.defaultNow()
|
|
301
|
+
.notNull()
|
|
302
|
+
},
|
|
303
|
+
(table) => [
|
|
304
|
+
foreignKey({
|
|
305
|
+
columns: [table.senderId],
|
|
306
|
+
foreignColumns: [sender.id],
|
|
307
|
+
name: 'Campaign_senderId_fkey'
|
|
308
|
+
})
|
|
309
|
+
.onUpdate('cascade')
|
|
310
|
+
.onDelete('set null'),
|
|
311
|
+
foreignKey({
|
|
312
|
+
columns: [table.listViewId],
|
|
313
|
+
foreignColumns: [listView.id],
|
|
314
|
+
name: 'Campaign_listViewId_fkey'
|
|
315
|
+
})
|
|
316
|
+
.onUpdate('cascade')
|
|
317
|
+
.onDelete('set null')
|
|
318
|
+
]
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
export const campaignToPosition = pgTable(
|
|
322
|
+
'campaigns_to_positions',
|
|
323
|
+
{
|
|
324
|
+
campaignId: uuid().notNull(),
|
|
325
|
+
positionId: uuid().notNull(),
|
|
326
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
327
|
+
.defaultNow()
|
|
328
|
+
.notNull()
|
|
329
|
+
},
|
|
330
|
+
(table) => [
|
|
331
|
+
foreignKey({
|
|
332
|
+
columns: [table.campaignId],
|
|
333
|
+
foreignColumns: [campaign.id],
|
|
334
|
+
name: 'CampaignToPosition_campaignId_fkey'
|
|
335
|
+
})
|
|
336
|
+
.onUpdate('cascade')
|
|
337
|
+
.onDelete('restrict'),
|
|
338
|
+
foreignKey({
|
|
339
|
+
columns: [table.positionId],
|
|
340
|
+
foreignColumns: [position.id],
|
|
341
|
+
name: 'CampaignToPosition_positionId_fkey'
|
|
342
|
+
})
|
|
343
|
+
.onUpdate('cascade')
|
|
344
|
+
.onDelete('restrict'),
|
|
345
|
+
primaryKey({
|
|
346
|
+
columns: [table.campaignId, table.positionId],
|
|
347
|
+
name: 'CampaignToPosition_pkey'
|
|
348
|
+
})
|
|
349
|
+
]
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
export const candidacy = pgTable(
|
|
353
|
+
'candidacies',
|
|
354
|
+
{
|
|
355
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
356
|
+
stage: CandidacyStages().default('SUBMITTED'),
|
|
357
|
+
networkId: uuid(),
|
|
358
|
+
source: CandidacySources(),
|
|
359
|
+
personId: uuid().notNull(),
|
|
360
|
+
positionId: uuid().notNull(),
|
|
361
|
+
openedAt: timestamp({
|
|
362
|
+
precision: 3,
|
|
363
|
+
mode: 'date',
|
|
364
|
+
withTimezone: true
|
|
365
|
+
}).defaultNow(),
|
|
366
|
+
ratings: jsonb().$type<{
|
|
367
|
+
EXPERIENCE: number | null
|
|
368
|
+
INDUSTRY: number | null
|
|
369
|
+
SKILL: number | null
|
|
370
|
+
CULTURE: number | null
|
|
371
|
+
COMPENSATION: number | null
|
|
372
|
+
LOCATION: number | null
|
|
373
|
+
MOTIVATION: number | null
|
|
374
|
+
}>(),
|
|
375
|
+
rejector: CandidacyRejectors(),
|
|
376
|
+
rejectionReasons: CandidacyAssessmentCategories().array(),
|
|
377
|
+
closedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
378
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
379
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
380
|
+
.defaultNow()
|
|
381
|
+
.notNull(),
|
|
382
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
383
|
+
.defaultNow()
|
|
384
|
+
.notNull()
|
|
385
|
+
},
|
|
386
|
+
(table) => [
|
|
387
|
+
uniqueIndex('Candidacy_personId_positionId_key').using(
|
|
388
|
+
'btree',
|
|
389
|
+
table.personId.asc().nullsLast().op('uuid_ops'),
|
|
390
|
+
table.positionId.asc().nullsLast().op('uuid_ops')
|
|
391
|
+
),
|
|
392
|
+
foreignKey({
|
|
393
|
+
columns: [table.positionId],
|
|
394
|
+
foreignColumns: [position.id],
|
|
395
|
+
name: 'Candidacy_positionId_fkey'
|
|
396
|
+
})
|
|
397
|
+
.onUpdate('cascade')
|
|
398
|
+
.onDelete('restrict'),
|
|
399
|
+
foreignKey({
|
|
400
|
+
columns: [table.personId],
|
|
401
|
+
foreignColumns: [person.id],
|
|
402
|
+
name: 'Candidacy_personId_fkey'
|
|
403
|
+
})
|
|
404
|
+
.onUpdate('cascade')
|
|
405
|
+
.onDelete('restrict')
|
|
406
|
+
]
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
export const candidacyFeedback = pgTable(
|
|
410
|
+
'candidacy_feedback',
|
|
411
|
+
{
|
|
412
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
413
|
+
candidacyId: uuid().notNull(),
|
|
414
|
+
content: text().notNull(),
|
|
415
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
416
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
417
|
+
.defaultNow()
|
|
418
|
+
.notNull(),
|
|
419
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
420
|
+
.defaultNow()
|
|
421
|
+
.notNull()
|
|
422
|
+
},
|
|
423
|
+
(table) => [
|
|
424
|
+
foreignKey({
|
|
425
|
+
columns: [table.candidacyId],
|
|
426
|
+
foreignColumns: [candidacy.id],
|
|
427
|
+
name: 'CandidacyFeedback_candidacyId_fkey'
|
|
428
|
+
})
|
|
429
|
+
.onUpdate('cascade')
|
|
430
|
+
.onDelete('restrict')
|
|
431
|
+
]
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
export const contract = pgTable(
|
|
435
|
+
'contracts',
|
|
436
|
+
{
|
|
437
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
438
|
+
data: jsonb().$type<any>().notNull(),
|
|
439
|
+
documentUri: text().notNull(),
|
|
440
|
+
positionId: uuid(),
|
|
441
|
+
clientId: uuid().notNull(),
|
|
442
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
443
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
444
|
+
.defaultNow()
|
|
445
|
+
.notNull(),
|
|
446
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
447
|
+
.defaultNow()
|
|
448
|
+
.notNull()
|
|
449
|
+
},
|
|
450
|
+
(table) => [
|
|
451
|
+
foreignKey({
|
|
452
|
+
columns: [table.positionId],
|
|
453
|
+
foreignColumns: [position.id],
|
|
454
|
+
name: 'Contract_positionId_fkey'
|
|
455
|
+
})
|
|
456
|
+
.onUpdate('cascade')
|
|
457
|
+
.onDelete('set null'),
|
|
458
|
+
foreignKey({
|
|
459
|
+
columns: [table.clientId],
|
|
460
|
+
foreignColumns: [client.id],
|
|
461
|
+
name: 'Contract_clientId_fkey'
|
|
462
|
+
})
|
|
463
|
+
.onUpdate('cascade')
|
|
464
|
+
.onDelete('restrict')
|
|
465
|
+
]
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
export const education = pgTable(
|
|
469
|
+
'educations',
|
|
470
|
+
{
|
|
471
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
472
|
+
personId: uuid().notNull(),
|
|
473
|
+
degree: EducationDegrees(),
|
|
474
|
+
field: EducationFields(),
|
|
475
|
+
school: text(),
|
|
476
|
+
graduatedAt: timestamp({
|
|
477
|
+
precision: 3,
|
|
478
|
+
mode: 'date',
|
|
479
|
+
withTimezone: true
|
|
480
|
+
})
|
|
481
|
+
},
|
|
482
|
+
(table) => [
|
|
483
|
+
foreignKey({
|
|
484
|
+
columns: [table.personId],
|
|
485
|
+
foreignColumns: [person.id],
|
|
486
|
+
name: 'Education_personId_fkey'
|
|
487
|
+
})
|
|
488
|
+
.onUpdate('cascade')
|
|
489
|
+
.onDelete('restrict')
|
|
490
|
+
]
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
export const enrichment = pgTable(
|
|
494
|
+
'enrichments',
|
|
495
|
+
{
|
|
496
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
497
|
+
data: jsonb().$type<any>(),
|
|
498
|
+
likelihood: doublePrecision(),
|
|
499
|
+
source: EnrichmentSources().notNull(),
|
|
500
|
+
personId: uuid().notNull(),
|
|
501
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
502
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
503
|
+
.defaultNow()
|
|
504
|
+
.notNull(),
|
|
505
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
506
|
+
.defaultNow()
|
|
507
|
+
.notNull()
|
|
508
|
+
},
|
|
509
|
+
(table) => [
|
|
510
|
+
uniqueIndex('Enrichment_personId_key').using(
|
|
511
|
+
'btree',
|
|
512
|
+
table.personId.asc().nullsLast().op('uuid_ops')
|
|
513
|
+
),
|
|
514
|
+
foreignKey({
|
|
515
|
+
columns: [table.personId],
|
|
516
|
+
foreignColumns: [person.id],
|
|
517
|
+
name: 'Enrichment_personId_fkey'
|
|
518
|
+
})
|
|
519
|
+
.onUpdate('cascade')
|
|
520
|
+
.onDelete('restrict')
|
|
521
|
+
]
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
export const experience = pgTable(
|
|
525
|
+
'experiences',
|
|
526
|
+
{
|
|
527
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
528
|
+
personId: uuid().notNull(),
|
|
529
|
+
jobFunctionId: uuid(),
|
|
530
|
+
industryId: uuid(),
|
|
531
|
+
company: text(),
|
|
532
|
+
level: JobLevels(),
|
|
533
|
+
title: text(),
|
|
534
|
+
salary: integer(),
|
|
535
|
+
isCurrent: boolean().default(false).notNull(),
|
|
536
|
+
startDate: timestamp({
|
|
537
|
+
precision: 3,
|
|
538
|
+
mode: 'date',
|
|
539
|
+
withTimezone: true
|
|
540
|
+
}),
|
|
541
|
+
endDate: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
542
|
+
},
|
|
543
|
+
(table) => [
|
|
544
|
+
foreignKey({
|
|
545
|
+
columns: [table.personId],
|
|
546
|
+
foreignColumns: [person.id],
|
|
547
|
+
name: 'Experience_personId_fkey'
|
|
548
|
+
})
|
|
549
|
+
.onUpdate('cascade')
|
|
550
|
+
.onDelete('restrict'),
|
|
551
|
+
foreignKey({
|
|
552
|
+
columns: [table.jobFunctionId],
|
|
553
|
+
foreignColumns: [jobFunction.id],
|
|
554
|
+
name: 'Experience_jobFunctionId_fkey'
|
|
555
|
+
})
|
|
556
|
+
.onUpdate('cascade')
|
|
557
|
+
.onDelete('set null'),
|
|
558
|
+
foreignKey({
|
|
559
|
+
columns: [table.industryId],
|
|
560
|
+
foreignColumns: [industry.id],
|
|
561
|
+
name: 'Experience_industryId_fkey'
|
|
562
|
+
})
|
|
563
|
+
.onUpdate('cascade')
|
|
564
|
+
.onDelete('set null')
|
|
565
|
+
]
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
export const industry = pgTable(
|
|
569
|
+
'industries',
|
|
570
|
+
{
|
|
571
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
572
|
+
slug: text().notNull(),
|
|
573
|
+
name: text().notNull(),
|
|
574
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
575
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
576
|
+
.defaultNow()
|
|
577
|
+
.notNull(),
|
|
578
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
579
|
+
.defaultNow()
|
|
580
|
+
.notNull()
|
|
581
|
+
},
|
|
582
|
+
(table) => [
|
|
583
|
+
uniqueIndex('Industry_slug_key').using(
|
|
584
|
+
'btree',
|
|
585
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
586
|
+
)
|
|
587
|
+
]
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
export const jobFunction = pgTable(
|
|
591
|
+
'job_functions',
|
|
592
|
+
{
|
|
593
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
594
|
+
slug: text().notNull(),
|
|
595
|
+
name: text().notNull(),
|
|
596
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
597
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
598
|
+
.defaultNow()
|
|
599
|
+
.notNull(),
|
|
600
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
601
|
+
.defaultNow()
|
|
602
|
+
.notNull()
|
|
603
|
+
},
|
|
604
|
+
(table) => [
|
|
605
|
+
uniqueIndex('JobFunction_slug_key').using(
|
|
606
|
+
'btree',
|
|
607
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
608
|
+
)
|
|
609
|
+
]
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
export const jwt = pgTable(
|
|
613
|
+
'jwts',
|
|
614
|
+
{
|
|
615
|
+
id: serial().primaryKey().notNull(),
|
|
616
|
+
jti: text().notNull(),
|
|
617
|
+
personId: uuid().notNull(),
|
|
618
|
+
revokedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
619
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
620
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
621
|
+
.defaultNow()
|
|
622
|
+
.notNull(),
|
|
623
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
624
|
+
.defaultNow()
|
|
625
|
+
.notNull()
|
|
626
|
+
},
|
|
627
|
+
(table) => [
|
|
628
|
+
uniqueIndex('Jwt_jti_key').using(
|
|
629
|
+
'btree',
|
|
630
|
+
table.jti.asc().nullsLast().op('text_ops')
|
|
631
|
+
),
|
|
632
|
+
foreignKey({
|
|
633
|
+
columns: [table.personId],
|
|
634
|
+
foreignColumns: [person.id],
|
|
635
|
+
name: 'Jwt_personId_fkey'
|
|
636
|
+
})
|
|
637
|
+
.onUpdate('cascade')
|
|
638
|
+
.onDelete('restrict')
|
|
639
|
+
]
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
export const listView = pgTable('list_views', {
|
|
643
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
644
|
+
model: ListViewModels().notNull(),
|
|
645
|
+
name: text(),
|
|
646
|
+
form: jsonb().$type<Record<any, any>>().notNull(),
|
|
647
|
+
query: jsonb().$type<Record<any, any>>().notNull(),
|
|
648
|
+
isGeneric: boolean().default(false),
|
|
649
|
+
archivedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
650
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
651
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
652
|
+
.defaultNow()
|
|
653
|
+
.notNull(),
|
|
654
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
655
|
+
.defaultNow()
|
|
656
|
+
.notNull()
|
|
657
|
+
})
|
|
658
|
+
|
|
659
|
+
export const message = pgTable(
|
|
660
|
+
'messages',
|
|
661
|
+
{
|
|
662
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
663
|
+
channel: MessageChannels().notNull(),
|
|
664
|
+
from: text().notNull(),
|
|
665
|
+
to: text().notNull(),
|
|
666
|
+
data: jsonb()
|
|
667
|
+
.$type<{
|
|
668
|
+
subject?: string
|
|
669
|
+
content?: string
|
|
670
|
+
}>()
|
|
671
|
+
.notNull(),
|
|
672
|
+
isReviewed: boolean().default(true).notNull(),
|
|
673
|
+
isOpened: boolean().default(false).notNull(),
|
|
674
|
+
isLinkClicked: boolean().default(false).notNull(),
|
|
675
|
+
outboundSenderId: uuid(),
|
|
676
|
+
personId: uuid().notNull(),
|
|
677
|
+
campaignId: uuid(),
|
|
678
|
+
attachments: jsonb().$type<
|
|
679
|
+
{
|
|
680
|
+
filename: string
|
|
681
|
+
contentType: string
|
|
682
|
+
uri: string | undefined
|
|
683
|
+
}[]
|
|
684
|
+
>(),
|
|
685
|
+
externalId: text(),
|
|
686
|
+
status: MessageStatuses().default('PENDING'),
|
|
687
|
+
statusReason: jsonb().$type<{
|
|
688
|
+
reason: string | undefined
|
|
689
|
+
response: string | undefined
|
|
690
|
+
}>(),
|
|
691
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
692
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
693
|
+
.defaultNow()
|
|
694
|
+
.notNull(),
|
|
695
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
696
|
+
.defaultNow()
|
|
697
|
+
.notNull()
|
|
698
|
+
},
|
|
699
|
+
(table) => [
|
|
700
|
+
foreignKey({
|
|
701
|
+
columns: [table.outboundSenderId],
|
|
702
|
+
foreignColumns: [sender.id],
|
|
703
|
+
name: 'Message_senderId_fkey'
|
|
704
|
+
})
|
|
705
|
+
.onUpdate('cascade')
|
|
706
|
+
.onDelete('set null'),
|
|
707
|
+
foreignKey({
|
|
708
|
+
columns: [table.campaignId],
|
|
709
|
+
foreignColumns: [campaign.id],
|
|
710
|
+
name: 'Message_campaignId_fkey'
|
|
711
|
+
})
|
|
712
|
+
.onUpdate('cascade')
|
|
713
|
+
.onDelete('set null'),
|
|
714
|
+
foreignKey({
|
|
715
|
+
columns: [table.personId],
|
|
716
|
+
foreignColumns: [person.id],
|
|
717
|
+
name: 'Message_personId_fkey'
|
|
718
|
+
})
|
|
719
|
+
.onUpdate('cascade')
|
|
720
|
+
.onDelete('restrict')
|
|
721
|
+
]
|
|
722
|
+
)
|
|
723
|
+
|
|
724
|
+
export const network = pgTable(
|
|
725
|
+
'networks',
|
|
726
|
+
{
|
|
727
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
728
|
+
partnerId: uuid(),
|
|
729
|
+
slug: text().notNull(),
|
|
730
|
+
name: text().notNull(),
|
|
731
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
732
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
733
|
+
.defaultNow()
|
|
734
|
+
.notNull(),
|
|
735
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
736
|
+
.defaultNow()
|
|
737
|
+
.notNull()
|
|
738
|
+
},
|
|
739
|
+
(table) => [
|
|
740
|
+
uniqueIndex('Networks_slug_key').using(
|
|
741
|
+
'btree',
|
|
742
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
743
|
+
)
|
|
744
|
+
]
|
|
745
|
+
)
|
|
746
|
+
|
|
747
|
+
export const note = pgTable(
|
|
748
|
+
'notes',
|
|
749
|
+
{
|
|
750
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
751
|
+
content: text().notNull(),
|
|
752
|
+
adminId: uuid(),
|
|
753
|
+
candidacyId: uuid(),
|
|
754
|
+
personId: uuid(),
|
|
755
|
+
clientId: uuid(),
|
|
756
|
+
positionId: uuid(),
|
|
757
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
758
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
759
|
+
.defaultNow()
|
|
760
|
+
.notNull(),
|
|
761
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
762
|
+
.defaultNow()
|
|
763
|
+
.notNull()
|
|
764
|
+
},
|
|
765
|
+
(table) => [
|
|
766
|
+
foreignKey({
|
|
767
|
+
columns: [table.adminId],
|
|
768
|
+
foreignColumns: [admin.id],
|
|
769
|
+
name: 'Note_adminId_fkey'
|
|
770
|
+
})
|
|
771
|
+
.onUpdate('cascade')
|
|
772
|
+
.onDelete('set null'),
|
|
773
|
+
foreignKey({
|
|
774
|
+
columns: [table.candidacyId],
|
|
775
|
+
foreignColumns: [candidacy.id],
|
|
776
|
+
name: 'Note_candidacyId_fkey'
|
|
777
|
+
})
|
|
778
|
+
.onUpdate('cascade')
|
|
779
|
+
.onDelete('set null'),
|
|
780
|
+
foreignKey({
|
|
781
|
+
columns: [table.clientId],
|
|
782
|
+
foreignColumns: [client.id],
|
|
783
|
+
name: 'Note_clientId_fkey'
|
|
784
|
+
})
|
|
785
|
+
.onUpdate('cascade')
|
|
786
|
+
.onDelete('set null'),
|
|
787
|
+
foreignKey({
|
|
788
|
+
columns: [table.positionId],
|
|
789
|
+
foreignColumns: [position.id],
|
|
790
|
+
name: 'Note_positionId_fkey'
|
|
791
|
+
})
|
|
792
|
+
.onUpdate('cascade')
|
|
793
|
+
.onDelete('set null'),
|
|
794
|
+
foreignKey({
|
|
795
|
+
columns: [table.personId],
|
|
796
|
+
foreignColumns: [person.id],
|
|
797
|
+
name: 'Note_personId_fkey'
|
|
798
|
+
})
|
|
799
|
+
.onUpdate('cascade')
|
|
800
|
+
.onDelete('set null')
|
|
801
|
+
]
|
|
802
|
+
)
|
|
803
|
+
|
|
804
|
+
export const otp = pgTable(
|
|
805
|
+
'otps',
|
|
806
|
+
{
|
|
807
|
+
id: serial().primaryKey().notNull(),
|
|
808
|
+
code: text().notNull(),
|
|
809
|
+
usedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
810
|
+
personId: uuid().notNull(),
|
|
811
|
+
expiresAt: timestamp({
|
|
812
|
+
precision: 3,
|
|
813
|
+
mode: 'date',
|
|
814
|
+
withTimezone: true
|
|
815
|
+
}).notNull(),
|
|
816
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
817
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
818
|
+
.defaultNow()
|
|
819
|
+
.notNull(),
|
|
820
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
821
|
+
.defaultNow()
|
|
822
|
+
.notNull()
|
|
823
|
+
},
|
|
824
|
+
(table) => [
|
|
825
|
+
uniqueIndex('Otp_code_key').using(
|
|
826
|
+
'btree',
|
|
827
|
+
table.code.asc().nullsLast().op('text_ops')
|
|
828
|
+
),
|
|
829
|
+
foreignKey({
|
|
830
|
+
columns: [table.personId],
|
|
831
|
+
foreignColumns: [person.id],
|
|
832
|
+
name: 'Otp_personId_fkey'
|
|
833
|
+
})
|
|
834
|
+
.onUpdate('cascade')
|
|
835
|
+
.onDelete('restrict')
|
|
836
|
+
]
|
|
837
|
+
)
|
|
838
|
+
|
|
839
|
+
export const partner = pgTable('partners', {
|
|
840
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
841
|
+
name: text().notNull(),
|
|
842
|
+
websiteUrl: text(),
|
|
843
|
+
logoUri: text(),
|
|
844
|
+
description: text(),
|
|
845
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
846
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
847
|
+
.defaultNow()
|
|
848
|
+
.notNull(),
|
|
849
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
850
|
+
.defaultNow()
|
|
851
|
+
.notNull()
|
|
852
|
+
})
|
|
853
|
+
|
|
854
|
+
export const person = pgTable(
|
|
855
|
+
'persons',
|
|
856
|
+
{
|
|
857
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
858
|
+
email: text().notNull(),
|
|
859
|
+
emailIsVerified: boolean().default(false).notNull(),
|
|
860
|
+
firstName: text(),
|
|
861
|
+
lastName: text(),
|
|
862
|
+
fullName: text().generatedAlwaysAs(
|
|
863
|
+
(): SQL =>
|
|
864
|
+
sql`NULLIF(TRIM(COALESCE(${person.firstName}, '') || ' ' || COALESCE(${person.lastName}, '')), '')`
|
|
865
|
+
),
|
|
866
|
+
linkedInUrl: text(),
|
|
867
|
+
phone: text(),
|
|
868
|
+
phoneIsVerified: boolean().default(false).notNull(),
|
|
869
|
+
emailIsOptedOut: boolean().default(false).notNull(),
|
|
870
|
+
smsIsOptedOut: boolean().default(false).notNull(),
|
|
871
|
+
resumeUri: text(),
|
|
872
|
+
resumeText: text(),
|
|
873
|
+
resumeData: jsonb().$type<any>(),
|
|
874
|
+
photoUri: text(),
|
|
875
|
+
isMember: boolean(),
|
|
876
|
+
lat: doublePrecision(),
|
|
877
|
+
lon: doublePrecision(),
|
|
878
|
+
city: text(),
|
|
879
|
+
state: States(),
|
|
880
|
+
postalCode: text(),
|
|
881
|
+
country: Countries(),
|
|
882
|
+
additionalEmails: text().array(),
|
|
883
|
+
additionalPhones: text().array(),
|
|
884
|
+
source: PersonSources().default('SOURCED'),
|
|
885
|
+
sourcePersonId: uuid(),
|
|
886
|
+
websiteUrl: text(),
|
|
887
|
+
expectedSalary: integer(),
|
|
888
|
+
preferredEmploymentType: EmploymentTypes(),
|
|
889
|
+
preferredEmploymentLocationType: EmploymentLocationTypes(),
|
|
890
|
+
preferredMessageChannel: MessageChannels(),
|
|
891
|
+
isOpenToRelocate: boolean(),
|
|
892
|
+
gender: Genders(),
|
|
893
|
+
discoveredThrough: text(),
|
|
894
|
+
deactivatedAt: timestamp({
|
|
895
|
+
precision: 3,
|
|
896
|
+
mode: 'date',
|
|
897
|
+
withTimezone: true
|
|
898
|
+
}),
|
|
899
|
+
lastSignedInAt: timestamp({
|
|
900
|
+
precision: 3,
|
|
901
|
+
mode: 'date',
|
|
902
|
+
withTimezone: true
|
|
903
|
+
}),
|
|
904
|
+
signInCount: integer().default(0).notNull(),
|
|
905
|
+
clientId: uuid(),
|
|
906
|
+
addedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
907
|
+
.defaultNow()
|
|
908
|
+
.notNull(),
|
|
909
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
910
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
911
|
+
.defaultNow()
|
|
912
|
+
.notNull(),
|
|
913
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
914
|
+
.defaultNow()
|
|
915
|
+
.notNull()
|
|
916
|
+
},
|
|
917
|
+
(table) => [
|
|
918
|
+
uniqueIndex('Person_email_key').using(
|
|
919
|
+
'btree',
|
|
920
|
+
table.email.asc().nullsLast().op('text_ops')
|
|
921
|
+
),
|
|
922
|
+
uniqueIndex('Person_phone_key').using(
|
|
923
|
+
'btree',
|
|
924
|
+
table.phone.asc().nullsLast().op('text_ops')
|
|
925
|
+
),
|
|
926
|
+
foreignKey({
|
|
927
|
+
columns: [table.sourcePersonId],
|
|
928
|
+
foreignColumns: [table.id],
|
|
929
|
+
name: 'Person_sourcePersonId_fkey'
|
|
930
|
+
})
|
|
931
|
+
.onUpdate('cascade')
|
|
932
|
+
.onDelete('set null'),
|
|
933
|
+
foreignKey({
|
|
934
|
+
columns: [table.clientId],
|
|
935
|
+
foreignColumns: [client.id],
|
|
936
|
+
name: 'Person_clientId_fkey'
|
|
937
|
+
})
|
|
938
|
+
.onUpdate('cascade')
|
|
939
|
+
.onDelete('set null')
|
|
940
|
+
]
|
|
941
|
+
)
|
|
942
|
+
|
|
943
|
+
export const personToBestPerson = pgTable(
|
|
944
|
+
'persons_to_best_persons',
|
|
945
|
+
{
|
|
946
|
+
bestiedByPersonId: uuid().notNull(),
|
|
947
|
+
bestPersonId: uuid().notNull(),
|
|
948
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
949
|
+
.defaultNow()
|
|
950
|
+
.notNull()
|
|
951
|
+
},
|
|
952
|
+
(table) => [
|
|
953
|
+
foreignKey({
|
|
954
|
+
columns: [table.bestiedByPersonId],
|
|
955
|
+
foreignColumns: [person.id],
|
|
956
|
+
name: 'PersonToBestPerson_bestiedByPersonId_fkey'
|
|
957
|
+
})
|
|
958
|
+
.onUpdate('cascade')
|
|
959
|
+
.onDelete('restrict'),
|
|
960
|
+
foreignKey({
|
|
961
|
+
columns: [table.bestPersonId],
|
|
962
|
+
foreignColumns: [person.id],
|
|
963
|
+
name: 'PersonToBestPerson_bestPersonId_fkey'
|
|
964
|
+
})
|
|
965
|
+
.onUpdate('cascade')
|
|
966
|
+
.onDelete('restrict'),
|
|
967
|
+
primaryKey({
|
|
968
|
+
columns: [table.bestiedByPersonId, table.bestPersonId],
|
|
969
|
+
name: 'PersonToBestPerson_pkey'
|
|
970
|
+
})
|
|
971
|
+
]
|
|
972
|
+
)
|
|
973
|
+
|
|
974
|
+
export const personToCertification = pgTable(
|
|
975
|
+
'persons_to_certifications',
|
|
976
|
+
{
|
|
977
|
+
personId: uuid().notNull(),
|
|
978
|
+
certificationId: uuid().notNull()
|
|
979
|
+
},
|
|
980
|
+
(table) => [
|
|
981
|
+
foreignKey({
|
|
982
|
+
columns: [table.personId],
|
|
983
|
+
foreignColumns: [person.id],
|
|
984
|
+
name: 'PersonToCertification_personId_fkey'
|
|
985
|
+
})
|
|
986
|
+
.onUpdate('cascade')
|
|
987
|
+
.onDelete('restrict'),
|
|
988
|
+
foreignKey({
|
|
989
|
+
columns: [table.certificationId],
|
|
990
|
+
foreignColumns: [certification.id],
|
|
991
|
+
name: 'PersonToCertification_certificationId_fkey'
|
|
992
|
+
})
|
|
993
|
+
.onUpdate('cascade')
|
|
994
|
+
.onDelete('restrict'),
|
|
995
|
+
primaryKey({
|
|
996
|
+
columns: [table.personId, table.certificationId],
|
|
997
|
+
name: 'PersonToCertification_pkey'
|
|
998
|
+
})
|
|
999
|
+
]
|
|
1000
|
+
)
|
|
1001
|
+
|
|
1002
|
+
export const personToNetwork = pgTable(
|
|
1003
|
+
'persons_to_networks',
|
|
1004
|
+
{
|
|
1005
|
+
personId: uuid().notNull(),
|
|
1006
|
+
networkId: uuid().notNull(),
|
|
1007
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1008
|
+
.defaultNow()
|
|
1009
|
+
.notNull()
|
|
1010
|
+
},
|
|
1011
|
+
(table) => [
|
|
1012
|
+
foreignKey({
|
|
1013
|
+
columns: [table.networkId],
|
|
1014
|
+
foreignColumns: [network.id],
|
|
1015
|
+
name: 'PersonToNetwork_networkId_fkey'
|
|
1016
|
+
})
|
|
1017
|
+
.onUpdate('cascade')
|
|
1018
|
+
.onDelete('restrict'),
|
|
1019
|
+
foreignKey({
|
|
1020
|
+
columns: [table.personId],
|
|
1021
|
+
foreignColumns: [person.id],
|
|
1022
|
+
name: 'PersonToNetwork_personId_fkey'
|
|
1023
|
+
})
|
|
1024
|
+
.onUpdate('cascade')
|
|
1025
|
+
.onDelete('restrict'),
|
|
1026
|
+
primaryKey({
|
|
1027
|
+
columns: [table.personId, table.networkId],
|
|
1028
|
+
name: 'PersonToNetwork_pkey'
|
|
1029
|
+
})
|
|
1030
|
+
]
|
|
1031
|
+
)
|
|
1032
|
+
|
|
1033
|
+
export const personToSkill = pgTable(
|
|
1034
|
+
'persons_to_skills',
|
|
1035
|
+
{
|
|
1036
|
+
personId: uuid().notNull(),
|
|
1037
|
+
skillId: uuid().notNull(),
|
|
1038
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1039
|
+
.defaultNow()
|
|
1040
|
+
.notNull()
|
|
1041
|
+
},
|
|
1042
|
+
(table) => [
|
|
1043
|
+
foreignKey({
|
|
1044
|
+
columns: [table.skillId],
|
|
1045
|
+
foreignColumns: [skill.id],
|
|
1046
|
+
name: 'PersonToSkill_skillId_fkey'
|
|
1047
|
+
})
|
|
1048
|
+
.onUpdate('cascade')
|
|
1049
|
+
.onDelete('restrict'),
|
|
1050
|
+
foreignKey({
|
|
1051
|
+
columns: [table.personId],
|
|
1052
|
+
foreignColumns: [person.id],
|
|
1053
|
+
name: 'PersonToSkill_personId_fkey'
|
|
1054
|
+
})
|
|
1055
|
+
.onUpdate('cascade')
|
|
1056
|
+
.onDelete('restrict'),
|
|
1057
|
+
primaryKey({
|
|
1058
|
+
columns: [table.personId, table.skillId],
|
|
1059
|
+
name: 'PersonToSkill_pkey'
|
|
1060
|
+
})
|
|
1061
|
+
]
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
export const personToTag = pgTable(
|
|
1065
|
+
'persons_to_tags',
|
|
1066
|
+
{
|
|
1067
|
+
personId: uuid().notNull(),
|
|
1068
|
+
tagId: uuid().notNull(),
|
|
1069
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1070
|
+
.defaultNow()
|
|
1071
|
+
.notNull()
|
|
1072
|
+
},
|
|
1073
|
+
(table) => [
|
|
1074
|
+
foreignKey({
|
|
1075
|
+
columns: [table.tagId],
|
|
1076
|
+
foreignColumns: [tag.id],
|
|
1077
|
+
name: 'PersonToTag_tagId_fkey'
|
|
1078
|
+
})
|
|
1079
|
+
.onUpdate('cascade')
|
|
1080
|
+
.onDelete('restrict'),
|
|
1081
|
+
foreignKey({
|
|
1082
|
+
columns: [table.personId],
|
|
1083
|
+
foreignColumns: [person.id],
|
|
1084
|
+
name: 'PersonToTag_personId_fkey'
|
|
1085
|
+
})
|
|
1086
|
+
.onUpdate('cascade')
|
|
1087
|
+
.onDelete('restrict'),
|
|
1088
|
+
primaryKey({
|
|
1089
|
+
columns: [table.personId, table.tagId],
|
|
1090
|
+
name: 'PersonToTag_pkey'
|
|
1091
|
+
})
|
|
1092
|
+
]
|
|
1093
|
+
)
|
|
1094
|
+
|
|
1095
|
+
export const position = pgTable(
|
|
1096
|
+
'positions',
|
|
1097
|
+
{
|
|
1098
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1099
|
+
slug: text().notNull(),
|
|
1100
|
+
name: text().notNull(),
|
|
1101
|
+
jobFunctionId: uuid(),
|
|
1102
|
+
industryId: uuid(),
|
|
1103
|
+
jobDescription: jsonb().$type<{
|
|
1104
|
+
intro?: string
|
|
1105
|
+
role?: string
|
|
1106
|
+
roleResponsibilities?: string[]
|
|
1107
|
+
candidate?: string
|
|
1108
|
+
candidateQualifications?: string[]
|
|
1109
|
+
}>(),
|
|
1110
|
+
teaser: text(),
|
|
1111
|
+
city: text(),
|
|
1112
|
+
state: States(),
|
|
1113
|
+
postalCode: text(),
|
|
1114
|
+
country: Countries(),
|
|
1115
|
+
employmentType: EmploymentTypes(),
|
|
1116
|
+
employmentLocationType: EmploymentLocationTypes(),
|
|
1117
|
+
// TODO - deprecate once we move away from using referrer location search
|
|
1118
|
+
location: text().generatedAlwaysAs((): SQL => sql`${position.city}`),
|
|
1119
|
+
lat: doublePrecision(),
|
|
1120
|
+
lon: doublePrecision(),
|
|
1121
|
+
isHidden: boolean().default(false).notNull(),
|
|
1122
|
+
isHiddenClient: boolean().default(false).notNull(),
|
|
1123
|
+
salaryMin: integer(),
|
|
1124
|
+
salaryMax: integer(),
|
|
1125
|
+
ratings: jsonb().$type<{
|
|
1126
|
+
COMPENSATION: number | null
|
|
1127
|
+
INTEREST: number | null
|
|
1128
|
+
}>(),
|
|
1129
|
+
referralPlacementReward: integer().default(5000).notNull(),
|
|
1130
|
+
referralInterviewReward: integer().default(100),
|
|
1131
|
+
additionalBenefits: text(),
|
|
1132
|
+
clientId: uuid().notNull(),
|
|
1133
|
+
closedReason: PositionClosedReasons(),
|
|
1134
|
+
openedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1135
|
+
closedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1136
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1137
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1138
|
+
.defaultNow()
|
|
1139
|
+
.notNull(),
|
|
1140
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1141
|
+
.defaultNow()
|
|
1142
|
+
.notNull()
|
|
1143
|
+
},
|
|
1144
|
+
(table) => [
|
|
1145
|
+
foreignKey({
|
|
1146
|
+
columns: [table.jobFunctionId],
|
|
1147
|
+
foreignColumns: [jobFunction.id],
|
|
1148
|
+
name: 'Position_jobFunctionId_fkey'
|
|
1149
|
+
})
|
|
1150
|
+
.onUpdate('cascade')
|
|
1151
|
+
.onDelete('restrict'),
|
|
1152
|
+
foreignKey({
|
|
1153
|
+
columns: [table.industryId],
|
|
1154
|
+
foreignColumns: [industry.id],
|
|
1155
|
+
name: 'Position_industryId_fkey'
|
|
1156
|
+
})
|
|
1157
|
+
.onUpdate('cascade')
|
|
1158
|
+
.onDelete('restrict'),
|
|
1159
|
+
foreignKey({
|
|
1160
|
+
columns: [table.clientId],
|
|
1161
|
+
foreignColumns: [client.id],
|
|
1162
|
+
name: 'Position_clientId_fkey'
|
|
1163
|
+
})
|
|
1164
|
+
.onUpdate('cascade')
|
|
1165
|
+
.onDelete('restrict')
|
|
1166
|
+
]
|
|
1167
|
+
)
|
|
1168
|
+
|
|
1169
|
+
export const positionToIndustry = pgTable(
|
|
1170
|
+
'positions_to_industries',
|
|
1171
|
+
{
|
|
1172
|
+
positionId: uuid().notNull(),
|
|
1173
|
+
industryId: uuid().notNull(),
|
|
1174
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1175
|
+
.defaultNow()
|
|
1176
|
+
.notNull()
|
|
1177
|
+
},
|
|
1178
|
+
(table) => [
|
|
1179
|
+
foreignKey({
|
|
1180
|
+
columns: [table.industryId],
|
|
1181
|
+
foreignColumns: [industry.id],
|
|
1182
|
+
name: 'PositionToIndustry_industryId_fkey'
|
|
1183
|
+
})
|
|
1184
|
+
.onUpdate('cascade')
|
|
1185
|
+
.onDelete('restrict'),
|
|
1186
|
+
foreignKey({
|
|
1187
|
+
columns: [table.positionId],
|
|
1188
|
+
foreignColumns: [position.id],
|
|
1189
|
+
name: 'PositionToIndustry_positionId_fkey'
|
|
1190
|
+
})
|
|
1191
|
+
.onUpdate('cascade')
|
|
1192
|
+
.onDelete('restrict'),
|
|
1193
|
+
primaryKey({
|
|
1194
|
+
columns: [table.positionId, table.industryId],
|
|
1195
|
+
name: 'PositionToIndustry_pkey'
|
|
1196
|
+
})
|
|
1197
|
+
]
|
|
1198
|
+
)
|
|
1199
|
+
|
|
1200
|
+
export const positionToSkill = pgTable(
|
|
1201
|
+
'positions_to_skills',
|
|
1202
|
+
{
|
|
1203
|
+
positionId: uuid().notNull(),
|
|
1204
|
+
skillId: uuid().notNull(),
|
|
1205
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1206
|
+
.defaultNow()
|
|
1207
|
+
.notNull()
|
|
1208
|
+
},
|
|
1209
|
+
(table) => [
|
|
1210
|
+
foreignKey({
|
|
1211
|
+
columns: [table.skillId],
|
|
1212
|
+
foreignColumns: [skill.id],
|
|
1213
|
+
name: 'PositionToSkill_skillId_fkey'
|
|
1214
|
+
})
|
|
1215
|
+
.onUpdate('cascade')
|
|
1216
|
+
.onDelete('restrict'),
|
|
1217
|
+
foreignKey({
|
|
1218
|
+
columns: [table.positionId],
|
|
1219
|
+
foreignColumns: [position.id],
|
|
1220
|
+
name: 'PositionToSkill_positionId_fkey'
|
|
1221
|
+
})
|
|
1222
|
+
.onUpdate('cascade')
|
|
1223
|
+
.onDelete('restrict'),
|
|
1224
|
+
primaryKey({
|
|
1225
|
+
columns: [table.positionId, table.skillId],
|
|
1226
|
+
name: 'PositionToSkill_pkey'
|
|
1227
|
+
})
|
|
1228
|
+
]
|
|
1229
|
+
)
|
|
1230
|
+
|
|
1231
|
+
export const positionToTag = pgTable(
|
|
1232
|
+
'positions_to_tags',
|
|
1233
|
+
{
|
|
1234
|
+
positionId: uuid().notNull(),
|
|
1235
|
+
tagId: uuid().notNull(),
|
|
1236
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1237
|
+
.defaultNow()
|
|
1238
|
+
.notNull()
|
|
1239
|
+
},
|
|
1240
|
+
(table) => [
|
|
1241
|
+
foreignKey({
|
|
1242
|
+
columns: [table.tagId],
|
|
1243
|
+
foreignColumns: [tag.id],
|
|
1244
|
+
name: 'PositionToTag_tagId_fkey'
|
|
1245
|
+
})
|
|
1246
|
+
.onUpdate('cascade')
|
|
1247
|
+
.onDelete('restrict'),
|
|
1248
|
+
foreignKey({
|
|
1249
|
+
columns: [table.positionId],
|
|
1250
|
+
foreignColumns: [position.id],
|
|
1251
|
+
name: 'PositionToTag_personId_fkey'
|
|
1252
|
+
})
|
|
1253
|
+
.onUpdate('cascade')
|
|
1254
|
+
.onDelete('restrict'),
|
|
1255
|
+
primaryKey({
|
|
1256
|
+
columns: [table.positionId, table.tagId],
|
|
1257
|
+
name: 'PositionToTag_pkey'
|
|
1258
|
+
})
|
|
1259
|
+
]
|
|
1260
|
+
)
|
|
1261
|
+
|
|
1262
|
+
export const referral = pgTable(
|
|
1263
|
+
'referrals',
|
|
1264
|
+
{
|
|
1265
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1266
|
+
source: ReferralSources().notNull(),
|
|
1267
|
+
networkId: uuid(),
|
|
1268
|
+
referrerId: uuid().notNull(),
|
|
1269
|
+
candidacyId: uuid().notNull(),
|
|
1270
|
+
campaignId: uuid(),
|
|
1271
|
+
positionId: uuid().notNull(),
|
|
1272
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1273
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1274
|
+
.defaultNow()
|
|
1275
|
+
.notNull(),
|
|
1276
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1277
|
+
.defaultNow()
|
|
1278
|
+
.notNull()
|
|
1279
|
+
},
|
|
1280
|
+
(table) => [
|
|
1281
|
+
uniqueIndex('Referral_candidacyId_key').using(
|
|
1282
|
+
'btree',
|
|
1283
|
+
table.candidacyId.asc().nullsLast().op('uuid_ops')
|
|
1284
|
+
),
|
|
1285
|
+
uniqueIndex('Referral_referrerId_candidacyId_key').using(
|
|
1286
|
+
'btree',
|
|
1287
|
+
table.referrerId.asc().nullsLast().op('uuid_ops'),
|
|
1288
|
+
table.candidacyId.asc().nullsLast().op('uuid_ops')
|
|
1289
|
+
),
|
|
1290
|
+
foreignKey({
|
|
1291
|
+
columns: [table.candidacyId],
|
|
1292
|
+
foreignColumns: [candidacy.id],
|
|
1293
|
+
name: 'Referral_candidacyId_fkey'
|
|
1294
|
+
})
|
|
1295
|
+
.onUpdate('cascade')
|
|
1296
|
+
.onDelete('restrict'),
|
|
1297
|
+
foreignKey({
|
|
1298
|
+
columns: [table.campaignId],
|
|
1299
|
+
foreignColumns: [campaign.id],
|
|
1300
|
+
name: 'Referral_campaignId_fkey'
|
|
1301
|
+
})
|
|
1302
|
+
.onUpdate('cascade')
|
|
1303
|
+
.onDelete('set null'),
|
|
1304
|
+
foreignKey({
|
|
1305
|
+
columns: [table.positionId],
|
|
1306
|
+
foreignColumns: [position.id],
|
|
1307
|
+
name: 'Referral_positionId_fkey'
|
|
1308
|
+
})
|
|
1309
|
+
.onUpdate('cascade')
|
|
1310
|
+
.onDelete('restrict'),
|
|
1311
|
+
foreignKey({
|
|
1312
|
+
columns: [table.referrerId],
|
|
1313
|
+
foreignColumns: [person.id],
|
|
1314
|
+
name: 'Referral_referrerId_fkey'
|
|
1315
|
+
})
|
|
1316
|
+
.onUpdate('cascade')
|
|
1317
|
+
.onDelete('restrict')
|
|
1318
|
+
]
|
|
1319
|
+
)
|
|
1320
|
+
|
|
1321
|
+
export const referralToMessage = pgTable(
|
|
1322
|
+
'referrals_to_messages',
|
|
1323
|
+
{
|
|
1324
|
+
messageId: uuid().notNull(),
|
|
1325
|
+
isIntro: boolean().default(false).notNull(),
|
|
1326
|
+
referralId: uuid().notNull(),
|
|
1327
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1328
|
+
.defaultNow()
|
|
1329
|
+
.notNull()
|
|
1330
|
+
},
|
|
1331
|
+
(table) => [
|
|
1332
|
+
foreignKey({
|
|
1333
|
+
columns: [table.messageId],
|
|
1334
|
+
foreignColumns: [message.id],
|
|
1335
|
+
name: 'ReferralToMessage_messageId_fkey'
|
|
1336
|
+
})
|
|
1337
|
+
.onUpdate('cascade')
|
|
1338
|
+
.onDelete('restrict'),
|
|
1339
|
+
foreignKey({
|
|
1340
|
+
columns: [table.referralId],
|
|
1341
|
+
foreignColumns: [referral.id],
|
|
1342
|
+
name: 'ReferralToMessage_referralId_fkey'
|
|
1343
|
+
})
|
|
1344
|
+
.onUpdate('cascade')
|
|
1345
|
+
.onDelete('restrict'),
|
|
1346
|
+
primaryKey({
|
|
1347
|
+
columns: [table.messageId, table.referralId],
|
|
1348
|
+
name: 'ReferralToMessage_pkey'
|
|
1349
|
+
})
|
|
1350
|
+
]
|
|
1351
|
+
)
|
|
1352
|
+
|
|
1353
|
+
export const referralPayout = pgTable(
|
|
1354
|
+
'referral_payouts',
|
|
1355
|
+
{
|
|
1356
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1357
|
+
referralId: uuid()
|
|
1358
|
+
},
|
|
1359
|
+
(table) => [
|
|
1360
|
+
foreignKey({
|
|
1361
|
+
columns: [table.referralId],
|
|
1362
|
+
foreignColumns: [referral.id],
|
|
1363
|
+
name: 'ReferralPayout_referralId_fkey'
|
|
1364
|
+
})
|
|
1365
|
+
.onUpdate('cascade')
|
|
1366
|
+
.onDelete('set null')
|
|
1367
|
+
]
|
|
1368
|
+
)
|
|
1369
|
+
|
|
1370
|
+
export const sender = pgTable('senders', {
|
|
1371
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1372
|
+
name: text().notNull(),
|
|
1373
|
+
email: text().notNull(),
|
|
1374
|
+
replyToEmail: text(),
|
|
1375
|
+
smsNumber: text().notNull(),
|
|
1376
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1377
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1378
|
+
.defaultNow()
|
|
1379
|
+
.notNull(),
|
|
1380
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1381
|
+
.defaultNow()
|
|
1382
|
+
.notNull()
|
|
1383
|
+
})
|
|
1384
|
+
|
|
1385
|
+
export const skill = pgTable(
|
|
1386
|
+
'skills',
|
|
1387
|
+
{
|
|
1388
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1389
|
+
slug: text().notNull(),
|
|
1390
|
+
name: text().notNull(),
|
|
1391
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1392
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1393
|
+
.defaultNow()
|
|
1394
|
+
.notNull(),
|
|
1395
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1396
|
+
.defaultNow()
|
|
1397
|
+
.notNull()
|
|
1398
|
+
},
|
|
1399
|
+
(table) => [
|
|
1400
|
+
uniqueIndex('Skill_slug_key').using(
|
|
1401
|
+
'btree',
|
|
1402
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
1403
|
+
)
|
|
1404
|
+
]
|
|
1405
|
+
)
|
|
1406
|
+
|
|
1407
|
+
export const tag = pgTable(
|
|
1408
|
+
'tags',
|
|
1409
|
+
{
|
|
1410
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1411
|
+
slug: text().notNull(),
|
|
1412
|
+
name: text().notNull(),
|
|
1413
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1414
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1415
|
+
.defaultNow()
|
|
1416
|
+
.notNull(),
|
|
1417
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1418
|
+
.defaultNow()
|
|
1419
|
+
.notNull()
|
|
1420
|
+
},
|
|
1421
|
+
(table) => [
|
|
1422
|
+
uniqueIndex('Tag_slug_key').using(
|
|
1423
|
+
'btree',
|
|
1424
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
1425
|
+
)
|
|
1426
|
+
]
|
|
1427
|
+
)
|
|
1428
|
+
|
|
1429
|
+
export const websiteBlock = pgTable(
|
|
1430
|
+
'website_blocks',
|
|
1431
|
+
{
|
|
1432
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1433
|
+
slug: text().notNull(),
|
|
1434
|
+
name: text().notNull(),
|
|
1435
|
+
content: text().notNull(),
|
|
1436
|
+
contentType: text().notNull()
|
|
1437
|
+
},
|
|
1438
|
+
(table) => [
|
|
1439
|
+
uniqueIndex('WebsiteBlock_slug_key').using(
|
|
1440
|
+
'btree',
|
|
1441
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
1442
|
+
)
|
|
1443
|
+
]
|
|
1444
|
+
)
|
|
1445
|
+
|
|
1446
|
+
export const websiteLandingPage = pgTable(
|
|
1447
|
+
'website_landing_pages',
|
|
1448
|
+
{
|
|
1449
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1450
|
+
tinyUri: text(),
|
|
1451
|
+
slug: text().notNull(),
|
|
1452
|
+
name: text().notNull(),
|
|
1453
|
+
content: jsonb()
|
|
1454
|
+
.$type<{
|
|
1455
|
+
title?: string
|
|
1456
|
+
body?: string
|
|
1457
|
+
positionIds?: Record<string, boolean>
|
|
1458
|
+
}>()
|
|
1459
|
+
.default({})
|
|
1460
|
+
.notNull(),
|
|
1461
|
+
meta: jsonb()
|
|
1462
|
+
.$type<{
|
|
1463
|
+
title?: string
|
|
1464
|
+
description?: string
|
|
1465
|
+
keywords?: string
|
|
1466
|
+
}>()
|
|
1467
|
+
.default({})
|
|
1468
|
+
.notNull(),
|
|
1469
|
+
deletedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true }),
|
|
1470
|
+
createdAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1471
|
+
.defaultNow()
|
|
1472
|
+
.notNull(),
|
|
1473
|
+
updatedAt: timestamp({ precision: 3, mode: 'date', withTimezone: true })
|
|
1474
|
+
.defaultNow()
|
|
1475
|
+
.notNull()
|
|
1476
|
+
},
|
|
1477
|
+
(table) => [
|
|
1478
|
+
uniqueIndex('WebsiteLandingPage_tinyUri_key').using(
|
|
1479
|
+
'btree',
|
|
1480
|
+
table.tinyUri.asc().nullsLast().op('text_ops')
|
|
1481
|
+
)
|
|
1482
|
+
]
|
|
1483
|
+
)
|
|
1484
|
+
|
|
1485
|
+
export const websiteStaticPage = pgTable(
|
|
1486
|
+
'website_static_pages',
|
|
1487
|
+
{
|
|
1488
|
+
id: uuid().defaultRandom().primaryKey().notNull(),
|
|
1489
|
+
slug: text().notNull(),
|
|
1490
|
+
name: text().notNull(),
|
|
1491
|
+
path: text().notNull(),
|
|
1492
|
+
content: jsonb().$type<Record<any, any>>().default({}).notNull(),
|
|
1493
|
+
meta: jsonb()
|
|
1494
|
+
.$type<{
|
|
1495
|
+
title?: string
|
|
1496
|
+
description?: string
|
|
1497
|
+
keywords?: string
|
|
1498
|
+
}>()
|
|
1499
|
+
.default({})
|
|
1500
|
+
.notNull()
|
|
1501
|
+
},
|
|
1502
|
+
(table) => [
|
|
1503
|
+
uniqueIndex('WebsiteStaticPage_slug_key').using(
|
|
1504
|
+
'btree',
|
|
1505
|
+
table.slug.asc().nullsLast().op('text_ops')
|
|
1506
|
+
)
|
|
1507
|
+
]
|
|
1508
|
+
)
|
|
1509
|
+
|
|
1510
|
+
// relations
|
|
1511
|
+
|
|
1512
|
+
export const actionRelations = relations(action, ({ one }) => ({
|
|
1513
|
+
candidacy: one(candidacy, {
|
|
1514
|
+
fields: [action.candidacyId],
|
|
1515
|
+
references: [candidacy.id]
|
|
1516
|
+
}),
|
|
1517
|
+
client: one(client, {
|
|
1518
|
+
fields: [action.clientId],
|
|
1519
|
+
references: [client.id]
|
|
1520
|
+
}),
|
|
1521
|
+
message: one(message, {
|
|
1522
|
+
fields: [action.messageId],
|
|
1523
|
+
references: [message.id]
|
|
1524
|
+
}),
|
|
1525
|
+
note: one(note, {
|
|
1526
|
+
fields: [action.noteId],
|
|
1527
|
+
references: [note.id]
|
|
1528
|
+
}),
|
|
1529
|
+
position: one(position, {
|
|
1530
|
+
fields: [action.positionId],
|
|
1531
|
+
references: [position.id]
|
|
1532
|
+
}),
|
|
1533
|
+
referral: one(referral, {
|
|
1534
|
+
fields: [action.referralId],
|
|
1535
|
+
references: [referral.id]
|
|
1536
|
+
}),
|
|
1537
|
+
person: one(person, {
|
|
1538
|
+
fields: [action.personId],
|
|
1539
|
+
references: [person.id]
|
|
1540
|
+
})
|
|
1541
|
+
}))
|
|
1542
|
+
|
|
1543
|
+
export const adminRelations = relations(admin, ({ one, many }) => ({
|
|
1544
|
+
notes: many(note),
|
|
1545
|
+
person: one(person, {
|
|
1546
|
+
fields: [admin.personId],
|
|
1547
|
+
references: [person.id]
|
|
1548
|
+
})
|
|
1549
|
+
}))
|
|
1550
|
+
|
|
1551
|
+
export const campaignRelations = relations(campaign, ({ one, many }) => ({
|
|
1552
|
+
referrals: many(referral),
|
|
1553
|
+
messages: many(message),
|
|
1554
|
+
positions: many(campaignToPosition),
|
|
1555
|
+
listView: one(listView, {
|
|
1556
|
+
fields: [campaign.listViewId],
|
|
1557
|
+
references: [listView.id]
|
|
1558
|
+
})
|
|
1559
|
+
}))
|
|
1560
|
+
|
|
1561
|
+
export const campaignToPositionRelations = relations(
|
|
1562
|
+
campaignToPosition,
|
|
1563
|
+
({ one }) => ({
|
|
1564
|
+
campaign: one(campaign, {
|
|
1565
|
+
fields: [campaignToPosition.campaignId],
|
|
1566
|
+
references: [campaign.id]
|
|
1567
|
+
}),
|
|
1568
|
+
position: one(position, {
|
|
1569
|
+
fields: [campaignToPosition.positionId],
|
|
1570
|
+
references: [position.id]
|
|
1571
|
+
})
|
|
1572
|
+
})
|
|
1573
|
+
)
|
|
1574
|
+
|
|
1575
|
+
export const candidacyFeedbackRelations = relations(
|
|
1576
|
+
candidacyFeedback,
|
|
1577
|
+
({ one }) => ({
|
|
1578
|
+
candidacy: one(candidacy, {
|
|
1579
|
+
fields: [candidacyFeedback.candidacyId],
|
|
1580
|
+
references: [candidacy.id]
|
|
1581
|
+
})
|
|
1582
|
+
})
|
|
1583
|
+
)
|
|
1584
|
+
|
|
1585
|
+
export const candidacyRelations = relations(candidacy, ({ one, many }) => ({
|
|
1586
|
+
actions: many(action),
|
|
1587
|
+
position: one(position, {
|
|
1588
|
+
fields: [candidacy.positionId],
|
|
1589
|
+
references: [position.id]
|
|
1590
|
+
}),
|
|
1591
|
+
person: one(person, {
|
|
1592
|
+
fields: [candidacy.personId],
|
|
1593
|
+
references: [person.id]
|
|
1594
|
+
}),
|
|
1595
|
+
notes: many(note),
|
|
1596
|
+
referral: one(referral),
|
|
1597
|
+
feedbacks: many(candidacyFeedback),
|
|
1598
|
+
network: one(network, {
|
|
1599
|
+
fields: [candidacy.networkId],
|
|
1600
|
+
references: [network.id]
|
|
1601
|
+
})
|
|
1602
|
+
}))
|
|
1603
|
+
|
|
1604
|
+
export const certificationRelations = relations(certification, ({ many }) => ({
|
|
1605
|
+
persons: many(person)
|
|
1606
|
+
}))
|
|
1607
|
+
|
|
1608
|
+
export const clientRelations = relations(client, ({ many }) => ({
|
|
1609
|
+
actions: many(action),
|
|
1610
|
+
positions: many(position),
|
|
1611
|
+
notes: many(note),
|
|
1612
|
+
contracts: many(contract),
|
|
1613
|
+
persons: many(person)
|
|
1614
|
+
}))
|
|
1615
|
+
|
|
1616
|
+
export const contractRelations = relations(contract, ({ one }) => ({
|
|
1617
|
+
position: one(position, {
|
|
1618
|
+
fields: [contract.positionId],
|
|
1619
|
+
references: [position.id]
|
|
1620
|
+
}),
|
|
1621
|
+
client: one(client, {
|
|
1622
|
+
fields: [contract.clientId],
|
|
1623
|
+
references: [client.id]
|
|
1624
|
+
})
|
|
1625
|
+
}))
|
|
1626
|
+
|
|
1627
|
+
export const educationRelations = relations(education, ({ one }) => ({
|
|
1628
|
+
person: one(person, {
|
|
1629
|
+
fields: [education.personId],
|
|
1630
|
+
references: [person.id]
|
|
1631
|
+
})
|
|
1632
|
+
}))
|
|
1633
|
+
|
|
1634
|
+
export const enrichmentRelations = relations(enrichment, ({ one }) => ({
|
|
1635
|
+
person: one(person, {
|
|
1636
|
+
fields: [enrichment.personId],
|
|
1637
|
+
references: [person.id]
|
|
1638
|
+
})
|
|
1639
|
+
}))
|
|
1640
|
+
|
|
1641
|
+
export const experienceRelations = relations(experience, ({ one }) => ({
|
|
1642
|
+
person: one(person, {
|
|
1643
|
+
fields: [experience.personId],
|
|
1644
|
+
references: [person.id]
|
|
1645
|
+
}),
|
|
1646
|
+
jobFunction: one(jobFunction, {
|
|
1647
|
+
fields: [experience.jobFunctionId],
|
|
1648
|
+
references: [jobFunction.id]
|
|
1649
|
+
}),
|
|
1650
|
+
industry: one(industry, {
|
|
1651
|
+
fields: [experience.industryId],
|
|
1652
|
+
references: [industry.id]
|
|
1653
|
+
})
|
|
1654
|
+
}))
|
|
1655
|
+
|
|
1656
|
+
export const industryRelations = relations(industry, ({ many }) => ({
|
|
1657
|
+
experiences: many(experience)
|
|
1658
|
+
}))
|
|
1659
|
+
|
|
1660
|
+
export const jobFunctionRelations = relations(jobFunction, ({ many }) => ({
|
|
1661
|
+
experiences: many(experience),
|
|
1662
|
+
positions: many(position)
|
|
1663
|
+
}))
|
|
1664
|
+
|
|
1665
|
+
export const jwtRelations = relations(jwt, ({ one }) => ({
|
|
1666
|
+
person: one(person, {
|
|
1667
|
+
fields: [jwt.personId],
|
|
1668
|
+
references: [person.id]
|
|
1669
|
+
})
|
|
1670
|
+
}))
|
|
1671
|
+
|
|
1672
|
+
export const messageRelations = relations(message, ({ one, many }) => ({
|
|
1673
|
+
actions: many(action),
|
|
1674
|
+
outboundSender: one(sender, {
|
|
1675
|
+
fields: [message.outboundSenderId],
|
|
1676
|
+
references: [sender.id]
|
|
1677
|
+
}),
|
|
1678
|
+
person: one(person, {
|
|
1679
|
+
fields: [message.personId],
|
|
1680
|
+
references: [person.id]
|
|
1681
|
+
}),
|
|
1682
|
+
campaign: one(campaign, {
|
|
1683
|
+
fields: [message.campaignId],
|
|
1684
|
+
references: [campaign.id]
|
|
1685
|
+
}),
|
|
1686
|
+
referrals: many(referralToMessage)
|
|
1687
|
+
}))
|
|
1688
|
+
|
|
1689
|
+
export const networkRelations = relations(network, ({ many, one }) => ({
|
|
1690
|
+
partner: one(partner, {
|
|
1691
|
+
fields: [network.partnerId],
|
|
1692
|
+
references: [partner.id]
|
|
1693
|
+
}),
|
|
1694
|
+
persons: many(personToNetwork),
|
|
1695
|
+
referrals: many(referral),
|
|
1696
|
+
candidacies: many(candidacy)
|
|
1697
|
+
}))
|
|
1698
|
+
|
|
1699
|
+
export const noteRelations = relations(note, ({ one, many }) => ({
|
|
1700
|
+
actions: many(action),
|
|
1701
|
+
admin: one(admin, {
|
|
1702
|
+
fields: [note.adminId],
|
|
1703
|
+
references: [admin.id]
|
|
1704
|
+
}),
|
|
1705
|
+
candidacy: one(candidacy, {
|
|
1706
|
+
fields: [note.candidacyId],
|
|
1707
|
+
references: [candidacy.id]
|
|
1708
|
+
}),
|
|
1709
|
+
client: one(client, {
|
|
1710
|
+
fields: [note.clientId],
|
|
1711
|
+
references: [client.id]
|
|
1712
|
+
}),
|
|
1713
|
+
position: one(position, {
|
|
1714
|
+
fields: [note.positionId],
|
|
1715
|
+
references: [position.id]
|
|
1716
|
+
}),
|
|
1717
|
+
person: one(person, {
|
|
1718
|
+
fields: [note.personId],
|
|
1719
|
+
references: [person.id]
|
|
1720
|
+
})
|
|
1721
|
+
}))
|
|
1722
|
+
|
|
1723
|
+
export const otpRelations = relations(otp, ({ one }) => ({
|
|
1724
|
+
person: one(person, {
|
|
1725
|
+
fields: [otp.personId],
|
|
1726
|
+
references: [person.id]
|
|
1727
|
+
})
|
|
1728
|
+
}))
|
|
1729
|
+
|
|
1730
|
+
export const partnerRelations = relations(partner, ({ many }) => ({
|
|
1731
|
+
networks: many(network)
|
|
1732
|
+
}))
|
|
1733
|
+
|
|
1734
|
+
export const personRelations = relations(person, ({ one, many }) => ({
|
|
1735
|
+
experiences: many(experience),
|
|
1736
|
+
actions: many(action),
|
|
1737
|
+
candidacies: many(candidacy),
|
|
1738
|
+
educations: many(education),
|
|
1739
|
+
certifications: many(personToCertification),
|
|
1740
|
+
messages: many(message),
|
|
1741
|
+
notes: many(note),
|
|
1742
|
+
referrals: many(referral),
|
|
1743
|
+
admins: many(admin),
|
|
1744
|
+
jwts: many(jwt),
|
|
1745
|
+
otps: many(otp),
|
|
1746
|
+
enrichments: many(enrichment),
|
|
1747
|
+
sourcedBy: one(person, {
|
|
1748
|
+
fields: [person.sourcePersonId],
|
|
1749
|
+
references: [person.id],
|
|
1750
|
+
relationName: 'sourcedPerson'
|
|
1751
|
+
}),
|
|
1752
|
+
sourcedPersons: many(person, {
|
|
1753
|
+
relationName: 'sourcedPerson'
|
|
1754
|
+
}),
|
|
1755
|
+
client: one(client, {
|
|
1756
|
+
fields: [person.clientId],
|
|
1757
|
+
references: [client.id]
|
|
1758
|
+
}),
|
|
1759
|
+
tags: many(personToTag),
|
|
1760
|
+
bestiedBy: many(personToBestPerson, {
|
|
1761
|
+
relationName: 'bestiedBy'
|
|
1762
|
+
}),
|
|
1763
|
+
bestPersons: many(personToBestPerson, {
|
|
1764
|
+
relationName: 'bestPersons'
|
|
1765
|
+
}),
|
|
1766
|
+
networks: many(personToNetwork),
|
|
1767
|
+
skills: many(personToSkill)
|
|
1768
|
+
}))
|
|
1769
|
+
|
|
1770
|
+
export const personToBestPersonRelations = relations(
|
|
1771
|
+
personToBestPerson,
|
|
1772
|
+
({ one }) => ({
|
|
1773
|
+
bestiedBy: one(person, {
|
|
1774
|
+
fields: [personToBestPerson.bestiedByPersonId],
|
|
1775
|
+
references: [person.id],
|
|
1776
|
+
relationName: 'bestPersons'
|
|
1777
|
+
}),
|
|
1778
|
+
bestPerson: one(person, {
|
|
1779
|
+
fields: [personToBestPerson.bestPersonId],
|
|
1780
|
+
references: [person.id],
|
|
1781
|
+
relationName: 'bestiedBy'
|
|
1782
|
+
})
|
|
1783
|
+
})
|
|
1784
|
+
)
|
|
1785
|
+
|
|
1786
|
+
export const personToNetworkRelations = relations(
|
|
1787
|
+
personToNetwork,
|
|
1788
|
+
({ one }) => ({
|
|
1789
|
+
network: one(network, {
|
|
1790
|
+
fields: [personToNetwork.networkId],
|
|
1791
|
+
references: [network.id]
|
|
1792
|
+
}),
|
|
1793
|
+
person: one(person, {
|
|
1794
|
+
fields: [personToNetwork.personId],
|
|
1795
|
+
references: [person.id]
|
|
1796
|
+
})
|
|
1797
|
+
})
|
|
1798
|
+
)
|
|
1799
|
+
|
|
1800
|
+
export const personToSkillRelations = relations(personToSkill, ({ one }) => ({
|
|
1801
|
+
skill: one(skill, {
|
|
1802
|
+
fields: [personToSkill.skillId],
|
|
1803
|
+
references: [skill.id]
|
|
1804
|
+
}),
|
|
1805
|
+
person: one(person, {
|
|
1806
|
+
fields: [personToSkill.personId],
|
|
1807
|
+
references: [person.id]
|
|
1808
|
+
})
|
|
1809
|
+
}))
|
|
1810
|
+
|
|
1811
|
+
export const personToTagRelations = relations(personToTag, ({ one }) => ({
|
|
1812
|
+
tag: one(tag, {
|
|
1813
|
+
fields: [personToTag.tagId],
|
|
1814
|
+
references: [tag.id]
|
|
1815
|
+
}),
|
|
1816
|
+
person: one(person, {
|
|
1817
|
+
fields: [personToTag.personId],
|
|
1818
|
+
references: [person.id]
|
|
1819
|
+
})
|
|
1820
|
+
}))
|
|
1821
|
+
|
|
1822
|
+
export const positionRelations = relations(position, ({ one, many }) => ({
|
|
1823
|
+
actions: many(action),
|
|
1824
|
+
client: one(client, {
|
|
1825
|
+
fields: [position.clientId],
|
|
1826
|
+
references: [client.id]
|
|
1827
|
+
}),
|
|
1828
|
+
jobFunction: one(jobFunction, {
|
|
1829
|
+
fields: [position.jobFunctionId],
|
|
1830
|
+
references: [jobFunction.id]
|
|
1831
|
+
}),
|
|
1832
|
+
candidacies: many(candidacy),
|
|
1833
|
+
notes: many(note),
|
|
1834
|
+
referrals: many(referral),
|
|
1835
|
+
contracts: many(contract),
|
|
1836
|
+
campaigns: many(campaignToPosition),
|
|
1837
|
+
tags: many(positionToTag)
|
|
1838
|
+
}))
|
|
1839
|
+
|
|
1840
|
+
export const positionToIndustryRelations = relations(industry, ({ many }) => ({
|
|
1841
|
+
positions: many(positionToIndustry)
|
|
1842
|
+
}))
|
|
1843
|
+
|
|
1844
|
+
export const positionToSkillRelations = relations(skill, ({ many }) => ({
|
|
1845
|
+
positions: many(positionToSkill)
|
|
1846
|
+
}))
|
|
1847
|
+
|
|
1848
|
+
export const referralPayoutRelations = relations(referralPayout, ({ one }) => ({
|
|
1849
|
+
referral: one(referral, {
|
|
1850
|
+
fields: [referralPayout.referralId],
|
|
1851
|
+
references: [referral.id]
|
|
1852
|
+
})
|
|
1853
|
+
}))
|
|
1854
|
+
|
|
1855
|
+
export const referralRelations = relations(referral, ({ one, many }) => ({
|
|
1856
|
+
actions: many(action),
|
|
1857
|
+
candidacy: one(candidacy, {
|
|
1858
|
+
fields: [referral.candidacyId],
|
|
1859
|
+
references: [candidacy.id]
|
|
1860
|
+
}),
|
|
1861
|
+
campaign: one(campaign, {
|
|
1862
|
+
fields: [referral.campaignId],
|
|
1863
|
+
references: [campaign.id]
|
|
1864
|
+
}),
|
|
1865
|
+
position: one(position, {
|
|
1866
|
+
fields: [referral.positionId],
|
|
1867
|
+
references: [position.id]
|
|
1868
|
+
}),
|
|
1869
|
+
referrer: one(person, {
|
|
1870
|
+
fields: [referral.referrerId],
|
|
1871
|
+
references: [person.id]
|
|
1872
|
+
}),
|
|
1873
|
+
payouts: many(referralPayout),
|
|
1874
|
+
messages: many(referralToMessage),
|
|
1875
|
+
network: one(network, {
|
|
1876
|
+
fields: [referral.networkId],
|
|
1877
|
+
references: [network.id]
|
|
1878
|
+
})
|
|
1879
|
+
}))
|
|
1880
|
+
|
|
1881
|
+
export const referralToMessageRelations = relations(
|
|
1882
|
+
referralToMessage,
|
|
1883
|
+
({ one }) => ({
|
|
1884
|
+
message: one(message, {
|
|
1885
|
+
fields: [referralToMessage.messageId],
|
|
1886
|
+
references: [message.id]
|
|
1887
|
+
}),
|
|
1888
|
+
referral: one(referral, {
|
|
1889
|
+
fields: [referralToMessage.referralId],
|
|
1890
|
+
references: [referral.id]
|
|
1891
|
+
})
|
|
1892
|
+
})
|
|
1893
|
+
)
|
|
1894
|
+
|
|
1895
|
+
export const senderRelations = relations(sender, ({ many }) => ({
|
|
1896
|
+
messages: many(message)
|
|
1897
|
+
}))
|
|
1898
|
+
|
|
1899
|
+
export const skillRelations = relations(skill, ({ many }) => ({
|
|
1900
|
+
persons: many(personToSkill)
|
|
1901
|
+
}))
|
|
1902
|
+
|
|
1903
|
+
export const tagRelations = relations(tag, ({ many }) => ({
|
|
1904
|
+
persons: many(personToTag),
|
|
1905
|
+
positions: many(positionToTag)
|
|
1906
|
+
}))
|