diff --git a/package.json b/package.json index 56e7c7a7a6..10200134d0 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,6 @@ "nestjs-console": "^9.0.0", "p-retry": "^5.1.2", "pako": "^2.1.0", - "pg": "^8.11.3", "pkg-up": "^4.0.0", "plur": "^5.1.0", "prismjs-terminal": "^1.2.2", @@ -118,7 +117,6 @@ "@types/luxon": "^3.3.1", "@types/node": "^18.17.7", "@types/pako": "^2.0.0", - "@types/pg": "^8.10.2", "@types/prismjs": "^1.26.0", "@types/react": "^18.2.20", "@types/stack-trace": "^0.0.30", diff --git a/src/common/sensitivity.enum.ts b/src/common/sensitivity.enum.ts index 138152e3a6..b008ba9a71 100644 --- a/src/common/sensitivity.enum.ts +++ b/src/common/sensitivity.enum.ts @@ -1,18 +1,15 @@ import { applyDecorators } from '@nestjs/common'; -import { Field, FieldOptions, registerEnumType } from '@nestjs/graphql'; +import { Field, FieldOptions } from '@nestjs/graphql'; import { Transform } from 'class-transformer'; import { uniq } from 'lodash'; import { rankSens } from '../core/database/query'; import { DbSort } from './db-sort.decorator'; +import { EnumType, makeEnum } from './make-enum'; -export enum Sensitivity { - Low = 'Low', - Medium = 'Medium', - High = 'High', -} - -registerEnumType(Sensitivity, { +export type Sensitivity = EnumType; +export const Sensitivity = makeEnum({ name: 'Sensitivity', + values: ['Low', 'Medium', 'High'], }); export const SensitivityField = (options: FieldOptions = {}) => diff --git a/src/components/admin/admin.service.ts b/src/components/admin/admin.service.ts index dc792241e5..b66e86c3fa 100644 --- a/src/components/admin/admin.service.ts +++ b/src/components/admin/admin.service.ts @@ -1,12 +1,12 @@ import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; import { DateTime } from 'luxon'; -import { ID, ServerException } from '~/common'; +import { ID, Role, ServerException } from '~/common'; import { ConfigService } from '~/core/config/config.service'; import { Transactional } from '~/core/database'; import { ILogger, Logger } from '~/core/logger'; import { AuthenticationService } from '../authentication'; import { CryptoService } from '../authentication/crypto.service'; -import { Powers, Role } from '../authorization/dto'; +import { Power } from '../authorization/dto'; import { AdminRepository } from './admin.repository'; @Injectable() @@ -84,8 +84,7 @@ export class AdminService implements OnApplicationBootstrap { }); // set root user label & give all powers - const powers = Object.keys(Powers); - await this.repo.setUserLabel(powers, id); + await this.repo.setUserLabel([...Power.values], id); } // TODO do this a different way. Using a global like this can cause race conditions. diff --git a/src/components/authentication/login.resolver.ts b/src/components/authentication/login.resolver.ts index aeafb7e227..77a6fbabd8 100644 --- a/src/components/authentication/login.resolver.ts +++ b/src/components/authentication/login.resolver.ts @@ -9,7 +9,7 @@ import { import { stripIndent } from 'common-tags'; import { AnonSession, GqlContextType, Session } from '../../common'; import { Loader, LoaderOf } from '../../core'; -import { Powers as Power, Privileges } from '../authorization'; +import { Power, Privileges } from '../authorization'; import { User, UserLoader } from '../user'; import { AuthenticationService } from './authentication.service'; import { LoginInput, LoginOutput, LogoutOutput } from './dto'; diff --git a/src/components/authentication/register.resolver.ts b/src/components/authentication/register.resolver.ts index 7df897a0e7..aa0cbc1c25 100644 --- a/src/components/authentication/register.resolver.ts +++ b/src/components/authentication/register.resolver.ts @@ -9,7 +9,7 @@ import { import { stripIndent } from 'common-tags'; import { AnonSession, GqlContextType, Session } from '../../common'; import { Loader, LoaderOf } from '../../core'; -import { Powers as Power, Privileges } from '../authorization'; +import { Power, Privileges } from '../authorization'; import { User, UserLoader } from '../user'; import { AuthenticationService } from './authentication.service'; import { RegisterInput, RegisterOutput } from './dto'; diff --git a/src/components/authentication/session.resolver.ts b/src/components/authentication/session.resolver.ts index 1a62ed6978..fb260b5e42 100644 --- a/src/components/authentication/session.resolver.ts +++ b/src/components/authentication/session.resolver.ts @@ -13,7 +13,7 @@ import { UnauthenticatedException, } from '../../common'; import { ConfigService, ILogger, Loader, LoaderOf, Logger } from '../../core'; -import { Powers as Power, Privileges } from '../authorization'; +import { Power, Privileges } from '../authorization'; import { User, UserLoader } from '../user'; import { AuthenticationService } from './authentication.service'; import { SessionOutput } from './dto'; diff --git a/src/components/authorization/authorization.resolver.ts b/src/components/authorization/authorization.resolver.ts index 9f9c0f7c7f..a306b76d95 100644 --- a/src/components/authorization/authorization.resolver.ts +++ b/src/components/authorization/authorization.resolver.ts @@ -1,6 +1,6 @@ import { Query, Resolver } from '@nestjs/graphql'; import { AnonSession, Session } from '~/common'; -import { Powers as Power } from './dto'; +import { Power } from './dto'; import { Privileges } from './policy'; @Resolver() diff --git a/src/components/authorization/dto/index.ts b/src/components/authorization/dto/index.ts index 979bae2ca5..142babb308 100644 --- a/src/components/authorization/dto/index.ts +++ b/src/components/authorization/dto/index.ts @@ -1,2 +1,2 @@ export * from './role.dto'; -export * from './powers'; +export * from './power.enum'; diff --git a/src/components/authorization/dto/power.enum.ts b/src/components/authorization/dto/power.enum.ts new file mode 100644 index 0000000000..5566d51f19 --- /dev/null +++ b/src/components/authorization/dto/power.enum.ts @@ -0,0 +1,111 @@ +import { EnumType, makeEnum } from '~/common'; + +export type Power = EnumType; +export const Power = makeEnum({ + name: 'Power', + values: [ + 'BetaFeatures', + 'CreateEthnoArt', + 'CreateFieldRegion', + 'CreateFieldZone', + 'CreateFilm', + 'CreateFundingAccount', + 'CreateLanguage', + 'CreateLiteracyMaterial', + 'CreateLocation', + 'CreateOrganization', + 'CreatePartner', + 'CreateProject', + 'CreateSong', + 'CreateStory', + 'CreateUser', + { + value: 'CreateBudget', + deprecationReason: 'Use `Project.budget` instead', + }, + { + value: 'CreateBudgetRecord', + deprecationReason: 'Use `Project.budget` instead', + }, + { + value: 'CreateCeremony', + deprecationReason: 'Use `Engagement.ceremony` instead', + }, + { + value: 'CreateChangeRequest', + deprecationReason: 'Use `Project.changeRequests` instead', + }, + { + value: 'CreateDirectory', + deprecationReason: 'Use something else instead', + }, + { + value: 'CreateEducation', + deprecationReason: 'Use `User.education` instead', + }, + { + value: 'CreateEthnologueLanguage', + deprecationReason: + 'Just check `CreateLanguage` instead. This is a sub-object ', + }, + { value: 'CreateFile', deprecationReason: 'Use something else instead' }, + { + value: 'CreateFileVersion', + deprecationReason: 'Use something else instead', + }, + { + value: 'CreateInternshipEngagement', + deprecationReason: 'Use `Project.engagements` instead', + }, + { + value: 'CreateLanguageEngagement', + deprecationReason: 'Use `Project.engagements` instead', + }, + { + value: 'CreatePartnership', + deprecationReason: 'Use `Project.partnerships` instead ', + }, + { value: 'CreatePost', deprecationReason: 'Use `X.posts` instead' }, + { + value: 'CreateProduct', + deprecationReason: 'Use `Engagement.products` instead', + }, + { + value: 'CreateProjectEngagement', + deprecationReason: 'Use `Project.engagements` instead', + }, + { + value: 'CreateProjectMember', + deprecationReason: 'Use `Project.team` instead', + }, + { + value: 'CreateTranslationEngagement', + deprecationReason: 'Use `Project.engagements` instead', + }, + { + value: 'CreateUnavailability', + deprecationReason: 'Use `User.unavailabilities` instead', + }, + { + value: 'GrantInternRole', + deprecationReason: 'Use `AuthorizedRoles.Intern` instead', + }, + { + value: 'GrantLiaisonRole', + deprecationReason: 'Use `AuthorizedRoles.Liaison` instead', + }, + { + value: 'GrantMentorRole', + deprecationReason: 'Use `AuthorizedRoles.Mentor` instead', + }, + { + value: 'GrantRegionalCommunicationsCoordinatorRole', + deprecationReason: + 'Use `AuthorizedRoles.RegionalCommunicationsCoordinator` instead', + }, + { + value: 'GrantTranslatorRole', + deprecationReason: 'Use `AuthorizedRoles.Translator` instead', + }, + ], +}); diff --git a/src/components/authorization/dto/powers.ts b/src/components/authorization/dto/powers.ts deleted file mode 100644 index 829eabf98a..0000000000 --- a/src/components/authorization/dto/powers.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* eslint typescript-sort-keys/string-enum: "warn" */ - -import { registerEnumType } from '@nestjs/graphql'; - -export enum Powers { - BetaFeatures = 'BetaFeatures', - - CreateEthnoArt = 'CreateEthnoArt', - CreateFieldRegion = 'CreateFieldRegion', - CreateFieldZone = 'CreateFieldZone', - CreateFilm = 'CreateFilm', - CreateFundingAccount = 'CreateFundingAccount', - CreateLanguage = 'CreateLanguage', - CreateLiteracyMaterial = 'CreateLiteracyMaterial', - CreateLocation = 'CreateLocation', - CreateOrganization = 'CreateOrganization', - CreatePartner = 'CreatePartner', - CreateProject = 'CreateProject', - CreateSong = 'CreateSong', - CreateStory = 'CreateStory', - CreateUser = 'CreateUser', - - /* eslint-disable typescript-sort-keys/string-enum */ - - /** @deprecated Use `Project.budget` instead */ - CreateBudget = 'CreateBudget', - /** @deprecated Use `Project.budget` instead */ - CreateBudgetRecord = 'CreateBudgetRecord', - /** @deprecated Use `Engagement.ceremony` instead */ - CreateCeremony = 'CreateCeremony', - /** @deprecated Use `Project.changeRequests` instead */ - CreateChangeRequest = 'CreateChangeRequest', - /** @deprecated Use something else instead */ - CreateDirectory = 'CreateDirectory', - /** @deprecated Use `User.education` instead */ - CreateEducation = 'CreateEducation', - /** @deprecated Just check `CreateLanguage` instead. This is a sub-object */ - CreateEthnologueLanguage = 'CreateEthnologueLanguage', - /** @deprecated Use something else instead */ - CreateFile = 'CreateFile', - /** @deprecated Use something else instead */ - CreateFileVersion = 'CreateFileVersion', - /** @deprecated Use `Project.engagements` instead */ - CreateInternshipEngagement = 'CreateInternshipEngagement', - /** @deprecated Use `Project.engagements` instead */ - CreateLanguageEngagement = 'CreateLanguageEngagement', - /** @deprecated Use `Project.partnerships` instead */ - CreatePartnership = 'CreatePartnership', - /** @deprecated Use `X.posts` instead */ - CreatePost = 'CreatePost', - /** @deprecated Use `Engagement.products` instead */ - CreateProduct = 'CreateProduct', - /** @deprecated Use `Project.engagements` instead */ - CreateProjectEngagement = 'CreateProjectEngagement', - /** @deprecated Use `Project.team` instead */ - CreateProjectMember = 'CreateProjectMember', - /** @deprecated Use `Project.engagements` instead */ - CreateTranslationEngagement = 'CreateTranslationEngagement', - /** @deprecated Use `User.unavailabilities` instead */ - CreateUnavailability = 'CreateUnavailability', - - /** @deprecated Use `AuthorizedRoles.Intern` instead */ - GrantInternRole = 'GrantInternRole', - /** @deprecated Use `AuthorizedRoles.Liaison` instead */ - GrantLiaisonRole = 'GrantLiaisonRole', - /** @deprecated Use `AuthorizedRoles.Mentor` instead */ - GrantMentorRole = 'GrantMentorRole', - /** @deprecated Use `AuthorizedRoles.RegionalCommunicationsCoordinator` instead */ - GrantRegionalCommunicationsCoordinatorRole = 'GrantRegionalCommunicationsCoordinatorRole', - /** @deprecated Use `AuthorizedRoles.Translator` instead */ - GrantTranslatorRole = 'GrantTranslatorRole', -} - -registerEnumType(Powers, { name: 'Power' }); diff --git a/src/components/authorization/missing-power.exception.ts b/src/components/authorization/missing-power.exception.ts index b555dfbc85..9936583cc8 100644 --- a/src/components/authorization/missing-power.exception.ts +++ b/src/components/authorization/missing-power.exception.ts @@ -1,9 +1,9 @@ -import { UnauthorizedException } from '../../common/exceptions'; -import { Powers } from './dto/powers'; +import { UnauthorizedException } from '~/common'; +import { Power } from './dto'; export class MissingPowerException extends UnauthorizedException { constructor( - readonly power: Powers, + readonly power: Power, message = `Missing required power: ${power}`, previous?: Error, ) { diff --git a/src/components/authorization/policy/executor/user-privileges.ts b/src/components/authorization/policy/executor/user-privileges.ts index 341ca2c7ba..0274bea019 100644 --- a/src/components/authorization/policy/executor/user-privileges.ts +++ b/src/components/authorization/policy/executor/user-privileges.ts @@ -6,7 +6,7 @@ import { SecuredPropsPlusExtraKey, Session, } from '~/common'; -import { Powers as Power } from '../../dto/powers'; +import { Power } from '../../dto'; import { MissingPowerException } from '../../missing-power.exception'; import { ChildListAction, ChildSingleAction, PropAction } from '../actions'; import { ResourceObjectContext } from '../object.type'; diff --git a/src/components/authorization/policy/policy.factory.ts b/src/components/authorization/policy/policy.factory.ts index b25c790cf0..770ce40299 100644 --- a/src/components/authorization/policy/policy.factory.ts +++ b/src/components/authorization/policy/policy.factory.ts @@ -6,10 +6,9 @@ import { Injectable, OnModuleInit } from '@nestjs/common'; import { pick, startCase } from 'lodash'; import { DeepWritable, Writable } from 'ts-essentials'; import { keys as keysOf } from 'ts-transformer-keys'; -import { EnhancedResource, many, mapFromList } from '~/common'; +import { EnhancedResource, many, mapFromList, Role } from '~/common'; import { ResourcesHost } from '~/core/resources'; -import { Powers as Power } from '../dto/powers'; -import { Role } from '../dto/role.dto'; +import { Power } from '../dto'; import { ChildListAction, ChildSingleAction } from './actions'; import { extract, Permission, Permissions } from './builder/perm-granter'; import { diff --git a/src/components/budget/dto/budget-status.enum.ts b/src/components/budget/dto/budget-status.enum.ts index ab7332a8a3..8a98f839a7 100644 --- a/src/components/budget/dto/budget-status.enum.ts +++ b/src/components/budget/dto/budget-status.enum.ts @@ -1,10 +1,7 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum BudgetStatus { - Pending = 'Pending', - Current = 'Current', - Superceded = 'Superceded', - Rejected = 'Rejected', -} - -registerEnumType(BudgetStatus, { name: 'BudgetStatus' }); +export type BudgetStatus = EnumType; +export const BudgetStatus = makeEnum({ + name: 'BudgetStatus', + values: ['Pending', 'Current', 'Superceded', 'Rejected'], +}); diff --git a/src/components/budget/handlers/update-project-current-budget-status.handler.ts b/src/components/budget/handlers/update-project-current-budget-status.handler.ts index 774187a654..30b883e629 100644 --- a/src/components/budget/handlers/update-project-current-budget-status.handler.ts +++ b/src/components/budget/handlers/update-project-current-budget-status.handler.ts @@ -15,7 +15,7 @@ export class UpdateProjectBudgetStatusHandler if (!updates.step) { return; } - let budgetStatus = BudgetStatus.Current; + let budgetStatus: BudgetStatus = BudgetStatus.Current; if ( stepToStatus(updates.step) !== ProjectStatus.Active || previous.status === ProjectStatus.Active diff --git a/src/components/ceremony/dto/ceremony-type.enum.ts b/src/components/ceremony/dto/ceremony-type.enum.ts new file mode 100644 index 0000000000..abfa59337a --- /dev/null +++ b/src/components/ceremony/dto/ceremony-type.enum.ts @@ -0,0 +1,12 @@ +import { EnumType, makeEnum } from '~/common'; + +export type CeremonyType = EnumType; +export const CeremonyType = makeEnum({ + name: 'CeremonyType', + values: [ + // Language Engagements can have dedications + 'Dedication', + // Internship Engagements can have certifications + 'Certification', + ], +}); diff --git a/src/components/ceremony/dto/ceremony.dto.ts b/src/components/ceremony/dto/ceremony.dto.ts index 5e576c66ac..b278bfe7a6 100644 --- a/src/components/ceremony/dto/ceremony.dto.ts +++ b/src/components/ceremony/dto/ceremony.dto.ts @@ -11,7 +11,7 @@ import { Sensitivity, SensitivityField, } from '../../../common'; -import { CeremonyType } from './type.enum'; +import { CeremonyType } from './ceremony-type.enum'; @RegisterResource() @Calculated() diff --git a/src/components/ceremony/dto/create-ceremony.dto.ts b/src/components/ceremony/dto/create-ceremony.dto.ts index 54156296d1..1ad9315744 100644 --- a/src/components/ceremony/dto/create-ceremony.dto.ts +++ b/src/components/ceremony/dto/create-ceremony.dto.ts @@ -1,6 +1,6 @@ import { Field, InputType } from '@nestjs/graphql'; import { CalendarDate, DateField } from '../../../common'; -import { CeremonyType } from './type.enum'; +import { CeremonyType } from './ceremony-type.enum'; @InputType() export abstract class CreateCeremony { diff --git a/src/components/ceremony/dto/index.ts b/src/components/ceremony/dto/index.ts index 3edc8792e5..b1b4b052cc 100644 --- a/src/components/ceremony/dto/index.ts +++ b/src/components/ceremony/dto/index.ts @@ -1,4 +1,5 @@ export * from './create-ceremony.dto'; export * from './list-ceremony.dto'; export * from './ceremony.dto'; +export * from './ceremony-type.enum'; export * from './update-ceremony.dto'; diff --git a/src/components/ceremony/dto/list-ceremony.dto.ts b/src/components/ceremony/dto/list-ceremony.dto.ts index a1c25cefc0..b57d7562db 100644 --- a/src/components/ceremony/dto/list-ceremony.dto.ts +++ b/src/components/ceremony/dto/list-ceremony.dto.ts @@ -1,7 +1,7 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { FilterField, PaginatedList, SortablePaginationInput } from '~/common'; +import { CeremonyType } from './ceremony-type.enum'; import { Ceremony } from './ceremony.dto'; -import { CeremonyType } from './type.enum'; @InputType() export abstract class CeremonyFilters { diff --git a/src/components/ceremony/dto/type.enum.ts b/src/components/ceremony/dto/type.enum.ts deleted file mode 100644 index 72108e79b9..0000000000 --- a/src/components/ceremony/dto/type.enum.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum CeremonyType { - // Language Engagements can have dedications - Dedication = 'Dedication', - // Internship Engagements can have certifications - Certification = 'Certification', -} - -registerEnumType(CeremonyType, { - name: 'CeremonyType', -}); diff --git a/src/components/ceremony/handlers/create-engagement-default-ceremony.handler.ts b/src/components/ceremony/handlers/create-engagement-default-ceremony.handler.ts index dfe6edf744..64c8cff8a1 100644 --- a/src/components/ceremony/handlers/create-engagement-default-ceremony.handler.ts +++ b/src/components/ceremony/handlers/create-engagement-default-ceremony.handler.ts @@ -3,7 +3,7 @@ import { DateTime } from 'luxon'; import { DatabaseService, EventsHandler, IEventHandler } from '../../../core'; import { EngagementCreatedEvent } from '../../engagement/events'; import { CeremonyService } from '../ceremony.service'; -import { CeremonyType } from '../dto/type.enum'; +import { CeremonyType } from '../dto'; @EventsHandler(EngagementCreatedEvent) export class CreateEngagementDefaultCeremonyHandler diff --git a/src/components/engagement/dto/intern-position.enum.ts b/src/components/engagement/dto/intern-position.enum.ts index fd47843704..2da1918282 100644 --- a/src/components/engagement/dto/intern-position.enum.ts +++ b/src/components/engagement/dto/intern-position.enum.ts @@ -1,124 +1,139 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; +import { ObjectType } from '@nestjs/graphql'; import { stripIndent } from 'common-tags'; -import { SecuredEnum } from '../../../common'; +import { EnumType, makeEnum, SecuredEnum } from '~/common'; -export enum InternshipPosition { - ConsultantInTraining = 'ConsultantInTraining', - MidLevelQualityAssurance = 'MidLevelQualityAssurance', - - LeadershipDevelopment = 'LeadershipDevelopment', - Mobilization = 'Mobilization', - Personnel = 'Personnel', - - Communication = 'Communication', - Administration = 'Administration', - Technology = 'Technology', - Finance = 'Finance', - - LanguageProgramManager = 'LanguageProgramManager', - Literacy = 'Literacy', - OralityFacilitator = 'OralityFacilitator', - ScriptureEngagement = 'ScriptureEngagement', - - // historic - OtherAttached = 'OtherAttached', - OtherTranslationCapacity = 'OtherTranslationCapacity', - OtherPartnershipCapacity = 'OtherPartnershipCapacity', - ExegeticalFacilitator = 'ExegeticalFacilitator', - TranslationFacilitator = 'TranslationFacilitator', -} - -export enum InternshipDomain { - Leadership = 'Leadership', - Operations = 'Operations', - FieldPrograms = 'FieldPrograms', -} - -export enum InternshipProgram { - QualityAssurance = 'QualityAssurance', - CapacityBuilding = 'CapacityBuilding', -} - -const Position = InternshipPosition; -const Domain = InternshipDomain; -const Program = InternshipProgram; - -export const InternshipPositionToDomain: Record< - InternshipPosition, - InternshipDomain | null -> = { - [Position.ConsultantInTraining]: null, - [Position.MidLevelQualityAssurance]: null, - - [Position.LeadershipDevelopment]: Domain.Leadership, - [Position.Mobilization]: Domain.Leadership, - [Position.Personnel]: Domain.Leadership, - - [Position.Communication]: Domain.Operations, - [Position.Administration]: Domain.Operations, - [Position.Technology]: Domain.Operations, - [Position.Finance]: Domain.Operations, - - [Position.LanguageProgramManager]: Domain.FieldPrograms, - [Position.Literacy]: Domain.FieldPrograms, - [Position.OralityFacilitator]: Domain.FieldPrograms, - [Position.ScriptureEngagement]: Domain.FieldPrograms, - - // historic -- best guesses for domains - [Position.OtherAttached]: Domain.FieldPrograms, - [Position.OtherTranslationCapacity]: Domain.FieldPrograms, - [Position.OtherPartnershipCapacity]: Domain.Leadership, - [Position.ExegeticalFacilitator]: null, - [Position.TranslationFacilitator]: Domain.FieldPrograms, -}; - -export const InternshipPositionToProgram: Record< - InternshipPosition, - InternshipProgram -> = { - [Position.ConsultantInTraining]: Program.QualityAssurance, - [Position.MidLevelQualityAssurance]: Program.QualityAssurance, - - [Position.LeadershipDevelopment]: Program.CapacityBuilding, - [Position.Mobilization]: Program.CapacityBuilding, - [Position.Personnel]: Program.CapacityBuilding, +export type InternshipDomain = EnumType; +export const InternshipDomain = makeEnum({ + name: 'InternshipDomain', + values: ['Leadership', 'Operations', 'FieldPrograms'], + description: stripIndent` + An InternshipDomain represents/groups several InternshipPositions. + `, +}); - [Position.Communication]: Program.CapacityBuilding, - [Position.Administration]: Program.CapacityBuilding, - [Position.Technology]: Program.CapacityBuilding, - [Position.Finance]: Program.CapacityBuilding, +export type InternshipProgram = EnumType; +export const InternshipProgram = makeEnum({ + name: 'InternshipProgram', + values: ['QualityAssurance', 'CapacityBuilding'], + description: stripIndent` + An InternshipProgram represents/groups several InternshipPositions. + `, +}); - [Position.LanguageProgramManager]: Program.CapacityBuilding, - [Position.Literacy]: Program.CapacityBuilding, - [Position.OralityFacilitator]: Program.CapacityBuilding, - [Position.ScriptureEngagement]: Program.CapacityBuilding, +export type InternshipPosition = EnumType; +export const InternshipPosition = makeEnum({ + name: 'InternshipPosition', + values: [ + { + value: 'ConsultantInTraining', + domain: null, + program: InternshipProgram.QualityAssurance, + }, + { + value: 'MidLevelQualityAssurance', + domain: null, + program: InternshipProgram.QualityAssurance, + }, - // historic - [Position.OtherAttached]: Program.QualityAssurance, - [Position.OtherTranslationCapacity]: Program.QualityAssurance, - [Position.OtherPartnershipCapacity]: Program.CapacityBuilding, - [Position.ExegeticalFacilitator]: Program.QualityAssurance, - [Position.TranslationFacilitator]: Program.CapacityBuilding, -}; + { + value: 'LeadershipDevelopment', + domain: InternshipDomain.Leadership, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'Mobilization', + domain: InternshipDomain.Leadership, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'Personnel', + domain: InternshipDomain.Leadership, + program: InternshipProgram.CapacityBuilding, + }, -export const historic = [ - Position.OtherAttached, - Position.OtherTranslationCapacity, - Position.OtherPartnershipCapacity, - Position.ExegeticalFacilitator, - Position.TranslationFacilitator, -]; + { + value: 'Communication', + domain: InternshipDomain.Operations, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'Administration', + domain: InternshipDomain.Operations, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'Technology', + domain: InternshipDomain.Operations, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'Finance', + domain: InternshipDomain.Operations, + program: InternshipProgram.CapacityBuilding, + }, -registerEnumType(InternshipPosition, { - name: 'InternshipPosition', - valuesMap: { - ExegeticalFacilitator: { + { + value: 'LanguageProgramManager', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'Literacy', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'OralityFacilitator', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.CapacityBuilding, + }, + { + value: 'ScriptureEngagement', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.CapacityBuilding, + }, + // historic + { + value: 'OtherAttached', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.QualityAssurance, + historic: true, + }, + { + value: 'OtherTranslationCapacity', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.QualityAssurance, + historic: true, + }, + { + value: 'OtherPartnershipCapacity', + domain: InternshipDomain.Leadership, + program: InternshipProgram.CapacityBuilding, + historic: true, + }, + { + value: 'ExegeticalFacilitator', + domain: null, + program: InternshipProgram.QualityAssurance, + historic: true, + }, + { + value: 'TranslationFacilitator', + domain: InternshipDomain.FieldPrograms, + program: InternshipProgram.CapacityBuilding, + historic: true, + }, + { + value: 'ExegeticalFacilitator', deprecationReason: 'Legacy. Only used in historic data.', + historic: true, }, - TranslationFacilitator: { + { + value: 'TranslationFacilitator', deprecationReason: 'Legacy. Only used in historic data.', + historic: true, }, - }, + ], }); @ObjectType({ @@ -127,17 +142,3 @@ registerEnumType(InternshipPosition, { export class SecuredInternPosition extends SecuredEnum(InternshipPosition, { nullable: true, }) {} - -registerEnumType(InternshipProgram, { - name: 'InternshipProgram', - description: stripIndent` - An InternshipProgram represents/groups several InternshipPositions. - `, -}); - -registerEnumType(InternshipDomain, { - name: 'InternshipDomain', - description: stripIndent` - An InternshipDomain represents/groups several InternshipPositions. - `, -}); diff --git a/src/components/engagement/dto/status.enum.ts b/src/components/engagement/dto/status.enum.ts index aa2d0f266f..892a7ce16a 100644 --- a/src/components/engagement/dto/status.enum.ts +++ b/src/components/engagement/dto/status.enum.ts @@ -1,4 +1,4 @@ -import { Field, ObjectType, registerEnumType } from '@nestjs/graphql'; +import { Field, ObjectType } from '@nestjs/graphql'; import { setOf } from '@seedcompany/common'; import { EnumType, makeEnum, SecuredEnum } from '~/common'; @@ -43,13 +43,12 @@ export const EngagementStatus = makeEnum({ }) export class SecuredEngagementStatus extends SecuredEnum(EngagementStatus) {} -export enum EngagementTransitionType { - Neutral = 'Neutral', - Approve = 'Approve', - Reject = 'Reject', -} -registerEnumType(EngagementTransitionType, { +export type EngagementTransitionType = EnumType< + typeof EngagementTransitionType +>; +export const EngagementTransitionType = makeEnum({ name: 'EngagementTransitionType', + values: ['Neutral', 'Approve', 'Reject'], }); @ObjectType() diff --git a/src/components/engagement/engagement.service.ts b/src/components/engagement/engagement.service.ts index 7b8477a839..de0f05804a 100644 --- a/src/components/engagement/engagement.service.ts +++ b/src/components/engagement/engagement.service.ts @@ -31,7 +31,7 @@ import { SecuredProductList, } from '../product'; import { IProject, ProjectStatus } from '../project'; -import { ProjectType } from '../project/dto/type.enum'; +import { ProjectType } from '../project/dto'; import { ProjectService } from '../project/project.service'; import { User } from '../user/dto'; import { diff --git a/src/components/engagement/internship-position.resolver.ts b/src/components/engagement/internship-position.resolver.ts index 70e643fb68..4439325916 100644 --- a/src/components/engagement/internship-position.resolver.ts +++ b/src/components/engagement/internship-position.resolver.ts @@ -5,13 +5,9 @@ import { ResolveField, Resolver, } from '@nestjs/graphql'; -import { difference, values } from 'lodash'; import { - historic, InternshipDomain, InternshipPosition, - InternshipPositionToDomain, - InternshipPositionToProgram, InternshipProgram, SecuredInternPosition, } from './dto'; @@ -37,11 +33,13 @@ export class InternshipPositionResolver { 'The available position options for the internship engagement.', }) options(): InternshipPositionOptions[] { - return difference(values(InternshipPosition), historic).map((position) => ({ - position, - domain: InternshipPositionToDomain[position], - program: InternshipPositionToProgram[position], - })); + return InternshipPosition.entries + .filter((position) => !position.historic) + .map((position) => ({ + position: position.value, + domain: position.domain ?? null, + program: position.program!, + })); } @ResolveField(() => InternshipDomain, { @@ -51,7 +49,10 @@ export class InternshipPositionResolver { domain( @Parent() { value: position }: SecuredInternPosition, ): InternshipDomain | null { - return position ? InternshipPositionToDomain[position] : null; + const domain = InternshipPosition.entries.find( + (entry) => position === entry.value, + )?.domain; + return position && domain ? domain : null; } @ResolveField(() => InternshipProgram, { @@ -62,6 +63,9 @@ export class InternshipPositionResolver { program( @Parent() { value: position }: SecuredInternPosition, ): InternshipProgram | null { - return position ? InternshipPositionToProgram[position] : null; + const program = InternshipPosition.entries.find( + (entry) => position === entry.value, + )?.program; + return position && program ? program : null; } } diff --git a/src/components/file/dto/file-node-type.enum.ts b/src/components/file/dto/file-node-type.enum.ts new file mode 100644 index 0000000000..302fddb506 --- /dev/null +++ b/src/components/file/dto/file-node-type.enum.ts @@ -0,0 +1,9 @@ +import { EnumType, makeEnum } from '~/common'; + +export type FileNodeType = EnumType; +export const FileNodeType = makeEnum({ + name: 'FileNodeType', + description: + 'The type of node in the file tree. A file, directory or file version.', + values: ['Directory', 'File', 'FileVersion'], +}); diff --git a/src/components/file/dto/index.ts b/src/components/file/dto/index.ts index 9d153db835..f2dc1a4311 100644 --- a/src/components/file/dto/index.ts +++ b/src/components/file/dto/index.ts @@ -1,6 +1,6 @@ export * from './upload.dto'; export * from './update.dto'; export * from './delete.dto'; -export * from './type'; +export * from './file-node-type.enum'; export * from './node'; export * from './list'; diff --git a/src/components/file/dto/list.ts b/src/components/file/dto/list.ts index e9cc64aa80..891b17da6e 100644 --- a/src/components/file/dto/list.ts +++ b/src/components/file/dto/list.ts @@ -1,7 +1,7 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { FilterField, PaginatedList, SortablePaginationInput } from '~/common'; +import { FileNodeType } from './file-node-type.enum'; import { Directory, File, FileNode, IFileNode } from './node'; -import { FileNodeType } from './type'; @InputType() export abstract class FileFilters { diff --git a/src/components/file/dto/node.ts b/src/components/file/dto/node.ts index ebd9062e16..07500a9c63 100644 --- a/src/components/file/dto/node.ts +++ b/src/components/file/dto/node.ts @@ -19,7 +19,7 @@ import { ServerException, simpleSwitch, } from '../../../common'; -import { FileNodeType } from './type'; +import { FileNodeType } from './file-node-type.enum'; /** * This should be used for TypeScript types as we'll always be passing around @@ -107,7 +107,7 @@ export class FileVersion extends BaseFile { static readonly Props = keysOf(); static readonly SecuredProps = keysOf>(); - declare readonly type: FileNodeType.FileVersion; + declare readonly type: 'FileVersion'; } @RegisterResource() @@ -118,7 +118,7 @@ export class File extends BaseFile { static readonly Props = keysOf(); static readonly SecuredProps = keysOf>(); - declare readonly type: FileNodeType.File; + declare readonly type: 'File'; readonly latestVersionId: ID; @@ -136,7 +136,7 @@ export class Directory extends FileNode { static readonly Props = keysOf(); static readonly SecuredProps = keysOf>(); - declare readonly type: FileNodeType.Directory; + declare readonly type: 'Directory'; @Field(() => Int, { description: diff --git a/src/components/file/dto/type.ts b/src/components/file/dto/type.ts deleted file mode 100644 index 8a698207b0..0000000000 --- a/src/components/file/dto/type.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum FileNodeType { - Directory = 'Directory', - File = 'File', - FileVersion = 'FileVersion', -} - -registerEnumType(FileNodeType, { - name: 'FileNodeType', - description: - 'The type of node in the file tree. A file, directory or file version.', -}); diff --git a/src/components/language/dto/language.dto.ts b/src/components/language/dto/language.dto.ts index cca0197116..63b13a05f3 100644 --- a/src/components/language/dto/language.dto.ts +++ b/src/components/language/dto/language.dto.ts @@ -157,13 +157,7 @@ export class Language extends Interfaces { @Field() readonly sponsorEstimatedEndDate: SecuredDate; - // Calculated. Not settable. - @SensitivityField({ - description: stripIndent` - The language's sensitivity. - It's based on its most sensitive location. - `, - }) + @SensitivityField() readonly sensitivity: Sensitivity; @Field() diff --git a/src/components/location/dto/location-type.enum.ts b/src/components/location/dto/location-type.enum.ts index 70b417748d..73a4b89ea8 100644 --- a/src/components/location/dto/location-type.enum.ts +++ b/src/components/location/dto/location-type.enum.ts @@ -1,19 +1,14 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum LocationType { - Country = 'Country', - City = 'City', - County = 'County', - Region = 'Region', - State = 'State', - CrossBorderArea = 'CrossBorderArea', -} - -registerEnumType(LocationType, { +export type LocationType = EnumType; +export const LocationType = makeEnum({ name: 'LocationType', - valuesMap: { - CrossBorderArea: { - description: `@label Cross-Border Area`, - }, - }, + values: [ + 'Country', + 'City', + 'County', + 'Region', + 'State', + { value: 'CrossBorderArea', label: 'Cross-Border Area' }, + ], }); diff --git a/src/components/location/dto/location.dto.ts b/src/components/location/dto/location.dto.ts index 9d2ac265ca..9d81346c60 100644 --- a/src/components/location/dto/location.dto.ts +++ b/src/components/location/dto/location.dto.ts @@ -10,6 +10,7 @@ import { Secured, SecuredEnum, SecuredProperty, + SecuredPropertyList, SecuredProps, SecuredString, SecuredStringNullable, @@ -54,6 +55,11 @@ export class Location extends Resource { }) export class SecuredLocation extends SecuredProperty(Location) {} +@ObjectType({ + description: SecuredPropertyList.descriptionFor('a list of locations'), +}) +export class SecuredLocations extends SecuredPropertyList(Location) {} + declare module '~/core/resources/map' { interface ResourceMap { Location: typeof Location; diff --git a/src/components/organization/dto/create-organization.dto.ts b/src/components/organization/dto/create-organization.dto.ts index c092d75a7c..62e5f25da6 100644 --- a/src/components/organization/dto/create-organization.dto.ts +++ b/src/components/organization/dto/create-organization.dto.ts @@ -2,6 +2,8 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; import { ValidateNested } from 'class-validator'; import { NameField } from '../../../common'; +import { OrganizationReach } from './organization-reach.dto'; +import { OrganizationType } from './organization-type.dto'; import { Organization } from './organization.dto'; @InputType() @@ -14,6 +16,12 @@ export abstract class CreateOrganization { @Field({ nullable: true }) readonly address?: string; + + @Field(() => [OrganizationType], { nullable: true }) + readonly types?: readonly OrganizationType[]; + + @Field(() => [OrganizationReach], { nullable: true }) + readonly reach?: readonly OrganizationReach[]; } @InputType() diff --git a/src/components/organization/dto/organization-reach.dto.ts b/src/components/organization/dto/organization-reach.dto.ts new file mode 100644 index 0000000000..a0a347d365 --- /dev/null +++ b/src/components/organization/dto/organization-reach.dto.ts @@ -0,0 +1,19 @@ +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; + +/** + * The reach of the organization. + */ +export type OrganizationReach = EnumType; +export const OrganizationReach = makeEnum({ + name: 'OrganizationReach', + description: 'The reach of the organization', + values: ['Local', 'Regional', 'National', 'Global'], +}); + +@ObjectType({ + description: SecuredEnumList.descriptionFor('organization reach'), +}) +export class SecuredOrganizationReach extends SecuredEnumList( + OrganizationReach, +) {} diff --git a/src/components/organization/dto/organization-type.dto.ts b/src/components/organization/dto/organization-type.dto.ts new file mode 100644 index 0000000000..2dab878768 --- /dev/null +++ b/src/components/organization/dto/organization-type.dto.ts @@ -0,0 +1,25 @@ +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; + +/** + * The type of organization. + */ +export type OrganizationType = EnumType; +export const OrganizationType = makeEnum({ + name: 'OrganizationType', + description: 'The type of organization', + values: [ + 'Church', + 'Parachurch', + 'Mission', + 'TranslationOrganization', + 'Alliance', + ], +}); + +@ObjectType({ + description: SecuredEnumList.descriptionFor('organization types'), +}) +export class SecuredOrganizationTypes extends SecuredEnumList( + OrganizationType, +) {} diff --git a/src/components/organization/dto/organization.dto.ts b/src/components/organization/dto/organization.dto.ts index 6af7f3b884..1b3f96c74d 100644 --- a/src/components/organization/dto/organization.dto.ts +++ b/src/components/organization/dto/organization.dto.ts @@ -14,6 +14,8 @@ import { SensitivityField, } from '../../../common'; import { Location } from '../../location/dto'; +import { SecuredOrganizationReach } from './organization-reach.dto'; +import { SecuredOrganizationTypes } from './organization-type.dto'; @RegisterResource() @ObjectType({ @@ -41,6 +43,12 @@ export class Organization extends Resource { "Based on the projects' lowest sensitivity, and defaults to 'High' if no project is connected", }) readonly sensitivity: Sensitivity; + + @Field() + readonly types: SecuredOrganizationTypes; + + @Field() + readonly reach: SecuredOrganizationReach; } @ObjectType({ diff --git a/src/components/organization/dto/update-organization.dto.ts b/src/components/organization/dto/update-organization.dto.ts index a719267d5b..7931f42ee3 100644 --- a/src/components/organization/dto/update-organization.dto.ts +++ b/src/components/organization/dto/update-organization.dto.ts @@ -2,6 +2,8 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; import { ValidateNested } from 'class-validator'; import { ID, IdField, NameField } from '../../../common'; +import { OrganizationReach } from './organization-reach.dto'; +import { OrganizationType } from './organization-type.dto'; import { Organization } from './organization.dto'; @InputType() @@ -17,6 +19,12 @@ export abstract class UpdateOrganization { @Field({ nullable: true }) readonly address?: string; + + @Field(() => [OrganizationType], { nullable: true }) + readonly types?: readonly OrganizationType[]; + + @Field(() => [OrganizationReach], { nullable: true }) + readonly reach?: readonly OrganizationReach[]; } @InputType() diff --git a/src/components/organization/migrations/add-reach.migration.ts b/src/components/organization/migrations/add-reach.migration.ts new file mode 100644 index 0000000000..5d61d8fa3c --- /dev/null +++ b/src/components/organization/migrations/add-reach.migration.ts @@ -0,0 +1,9 @@ +import { BaseMigration, Migration } from '~/core'; +import { Organization } from '../dto'; + +@Migration('2023-08-04T00:00:00') +export class AddOrganizationReachMigration extends BaseMigration { + async up() { + await this.addProperty(Organization, 'reach', []); + } +} diff --git a/src/components/organization/migrations/add-type.migration.ts b/src/components/organization/migrations/add-type.migration.ts new file mode 100644 index 0000000000..6656e00057 --- /dev/null +++ b/src/components/organization/migrations/add-type.migration.ts @@ -0,0 +1,9 @@ +import { BaseMigration, Migration } from '~/core'; +import { Organization } from '../dto'; + +@Migration('2023-08-04T00:00:00') +export class AddOrganizationTypeMigration extends BaseMigration { + async up() { + await this.addProperty(Organization, 'types', []); + } +} diff --git a/src/components/organization/organization.module.ts b/src/components/organization/organization.module.ts index 29cab46da9..9fc59fc258 100644 --- a/src/components/organization/organization.module.ts +++ b/src/components/organization/organization.module.ts @@ -1,6 +1,8 @@ import { forwardRef, Module } from '@nestjs/common'; import { AuthorizationModule } from '../authorization/authorization.module'; import { LocationModule } from '../location/location.module'; +import { AddOrganizationReachMigration } from './migrations/add-reach.migration'; +import { AddOrganizationTypeMigration } from './migrations/add-type.migration'; import { OrganizationLoader } from './organization.loader'; import { OrganizationRepository } from './organization.repository'; import { OrganizationResolver } from './organization.resolver'; @@ -13,6 +15,8 @@ import { OrganizationService } from './organization.service'; OrganizationService, OrganizationRepository, OrganizationLoader, + AddOrganizationReachMigration, + AddOrganizationTypeMigration, ], exports: [OrganizationService], }) diff --git a/src/components/organization/organization.repository.ts b/src/components/organization/organization.repository.ts index cd2c7a56ae..16327c42ad 100644 --- a/src/components/organization/organization.repository.ts +++ b/src/components/organization/organization.repository.ts @@ -26,8 +26,10 @@ export class OrganizationRepository extends DtoRepository< async create(input: CreateOrganization, session: Session) { const initialProps = { name: input.name, - address: input.address, acronym: input.acronym, + address: input.address, + types: input.types ?? [], + reach: input.reach ?? [], canDelete: true, }; diff --git a/src/components/partner/dto/create-partner.dto.ts b/src/components/partner/dto/create-partner.dto.ts index 4b38b6419c..8fc8836367 100644 --- a/src/components/partner/dto/create-partner.dto.ts +++ b/src/components/partner/dto/create-partner.dto.ts @@ -3,9 +3,10 @@ import { Transform, Type } from 'class-transformer'; import { Matches, ValidateNested } from 'class-validator'; import { uniq } from 'lodash'; import { ID, IdField, IdOf, IsId, NameField } from '../../../common'; +import { Location } from '../../../components/location'; import { FieldRegion } from '../../field-region'; import type { Language } from '../../language'; -import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type'; +import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type.enum'; import { PartnerType } from './partner-type.enum'; import { Partner } from './partner.dto'; @@ -43,6 +44,11 @@ export abstract class CreatePartner { @IdField({ nullable: true }) readonly languageOfWiderCommunicationId?: IdOf | null; + @Field(() => [IDType], { nullable: true }) + @IsId({ each: true }) + @Transform(({ value }) => uniq(value)) + readonly countries?: ReadonlyArray> = []; + @Field(() => [IDType], { nullable: true }) @IsId({ each: true }) @Transform(({ value }) => uniq(value)) diff --git a/src/components/partner/dto/partner-type.enum.ts b/src/components/partner/dto/partner-type.enum.ts index 27a002d10a..ed9bc7f496 100644 --- a/src/components/partner/dto/partner-type.enum.ts +++ b/src/components/partner/dto/partner-type.enum.ts @@ -1,15 +1,11 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnumList } from '../../../common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; -export enum PartnerType { - Managing = 'Managing', - Funding = 'Funding', - Impact = 'Impact', - Technical = 'Technical', - Resource = 'Resource', -} - -registerEnumType(PartnerType, { name: 'PartnerType' }); +export type PartnerType = EnumType; +export const PartnerType = makeEnum({ + name: 'PartnerType', + values: ['Managing', 'Funding', 'Impact', 'Technical', 'Resource'], +}); @ObjectType({ description: SecuredEnumList.descriptionFor('partner types'), diff --git a/src/components/partner/dto/partner.dto.ts b/src/components/partner/dto/partner.dto.ts index 1f49c6ec1b..a3845acb13 100644 --- a/src/components/partner/dto/partner.dto.ts +++ b/src/components/partner/dto/partner.dto.ts @@ -19,10 +19,11 @@ import { Sensitivity, SensitivityField, } from '../../../common'; +import { Location } from '../../../components/location'; import { ScopedRole } from '../../authorization'; import { FieldRegion } from '../../field-region'; import type { Language } from '../../language'; -import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type'; +import { FinancialReportingType } from '../../partnership/dto'; import { Pinnable } from '../../pin/dto'; import { Postable } from '../../post/dto'; import { IProject } from '../../project/dto'; @@ -55,7 +56,7 @@ export class Partner extends Interfaces { readonly organization: Secured; - readonly pointOfContact: Secured; + readonly pointOfContact: Secured; @Field() readonly types: SecuredPartnerTypes; @@ -78,6 +79,7 @@ export class Partner extends Interfaces { readonly languageOfWiderCommunication: Secured | null>; readonly fieldRegions: Required>>>; + readonly countries: Required>>>; @DateTimeField() readonly modifiedAt: DateTime; diff --git a/src/components/partner/dto/update-partner.dto.ts b/src/components/partner/dto/update-partner.dto.ts index 0cf8beefdc..1c6e4a11b2 100644 --- a/src/components/partner/dto/update-partner.dto.ts +++ b/src/components/partner/dto/update-partner.dto.ts @@ -3,9 +3,10 @@ import { Transform, Type } from 'class-transformer'; import { Matches, ValidateNested } from 'class-validator'; import { uniq } from 'lodash'; import { ID, IdField, IdOf, IsId, NameField } from '../../../common'; +import { Location } from '../../../components/location'; import { FieldRegion } from '../../field-region'; import type { Language } from '../../language'; -import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type'; +import { FinancialReportingType } from '../../partnership/dto'; import { PartnerType } from './partner-type.enum'; import { Partner } from './partner.dto'; @@ -15,7 +16,7 @@ export abstract class UpdatePartner { readonly id: ID; @IdField({ nullable: true }) - readonly pointOfContactId?: ID; + readonly pointOfContactId?: ID | null; @Field(() => [PartnerType], { nullable: true }) @Transform(({ value }) => uniq(value)) @@ -43,6 +44,11 @@ export abstract class UpdatePartner { @IdField({ nullable: true }) readonly languageOfWiderCommunicationId?: IdOf | null; + @Field(() => [IDType], { nullable: true }) + @IsId({ each: true }) + @Transform(({ value }) => (value ? uniq(value) : undefined)) + readonly countries?: ReadonlyArray>; + @Field(() => [IDType], { nullable: true }) @IsId({ each: true }) @Transform(({ value }) => (value ? uniq(value) : undefined)) diff --git a/src/components/partner/partner.repository.ts b/src/components/partner/partner.repository.ts index c7995ca241..4052670ea6 100644 --- a/src/components/partner/partner.repository.ts +++ b/src/components/partner/partner.repository.ts @@ -64,6 +64,7 @@ export class PartnerRepository extends DtoRepository< input.languageOfWiderCommunicationId, ], fieldRegions: ['FieldRegion', input.fieldRegions], + countries: ['Location', input.countries], }), ) .return<{ id: ID }>('node.id as id') @@ -114,6 +115,15 @@ export class PartnerRepository extends DtoRepository< ]) .return(collect('fieldRegions.id').as('fieldRegionsIds')), ) + .subQuery('node', (sub) => + sub + .match([ + node('node'), + relation('out', '', 'countries'), + node('countries', 'Location'), + ]) + .return(collect('countries.id').as('countriesIds')), + ) .apply(matchProps()) .optionalMatch([ node('node'), @@ -137,43 +147,13 @@ export class PartnerRepository extends DtoRepository< pointOfContact: 'pointOfContact.id', languageOfWiderCommunication: 'languageOfWiderCommunication.id', fieldRegions: 'fieldRegionsIds', + countries: 'countriesIds', scope: 'scopedRoles', pinned: 'exists((:User { id: $requestingUser })-[:pinned]->(node))', }).as('dto'), ); } - async updatePointOfContact(id: ID, user: ID, session: Session) { - const createdAt = DateTime.local(); - await this.db - .query() - .apply(matchRequestingUser(session)) - .matchNode('partner', 'Partner', { id }) - .matchNode('newPointOfContact', 'User', { - id: user, - }) - .optionalMatch([ - node('org'), - relation('out', 'oldPointOfContactRel', 'pointOfContact', { - active: true, - }), - node('pointOfContact', 'User'), - ]) - .setValues({ - 'oldPointOfContactRel.active': false, - }) - .with('*') - .create([ - node('partner'), - relation('out', '', 'pointOfContact', { - active: true, - createdAt, - }), - node('newPointOfContact'), - ]) - .run(); - } - async list({ filter, ...input }: PartnerListInput, session: Session) { const result = await this.db .query() diff --git a/src/components/partner/partner.resolver.ts b/src/components/partner/partner.resolver.ts index a4080e0744..0632ed75b8 100644 --- a/src/components/partner/partner.resolver.ts +++ b/src/components/partner/partner.resolver.ts @@ -19,6 +19,7 @@ import { import { Loader, LoaderOf } from '../../core'; import { FieldRegionLoader, SecuredFieldRegions } from '../field-region'; import { LanguageLoader, SecuredLanguageNullable } from '../language'; +import { LocationLoader, SecuredLocations } from '../location'; import { OrganizationLoader, SecuredOrganization } from '../organization'; import { PartnerLoader, PartnerService } from '../partner'; import { @@ -103,6 +104,14 @@ export class PartnerResolver { return await loadSecuredIds(loader, partner.fieldRegions); } + @ResolveField(() => SecuredLocations) + async countries( + @Parent() partner: Partner, + @Loader(LocationLoader) loader: LoaderOf, + ): Promise { + return await loadSecuredIds(loader, partner.countries); + } + @ResolveField(() => SecuredProjectList, { description: 'The list of projects the partner has a partnership with.', }) diff --git a/src/components/partner/partner.service.ts b/src/components/partner/partner.service.ts index 381cdb2f51..344b07f537 100644 --- a/src/components/partner/partner.service.ts +++ b/src/components/partner/partner.service.ts @@ -2,7 +2,9 @@ import { forwardRef, Inject, Injectable } from '@nestjs/common'; import { DuplicateException, ID, + IdOf, InputException, + loadManyIgnoreMissingThrowAny, NotFoundException, ObjectView, ServerException, @@ -10,10 +12,11 @@ import { UnauthorizedException, UnsecuredDto, } from '../../common'; -import { HandleIdLookup, ILogger, Logger } from '../../core'; +import { HandleIdLookup, ILogger, Logger, ResourceLoader } from '../../core'; import { mapListResults } from '../../core/database/results'; import { Privileges } from '../authorization'; -import { FinancialReportingType } from '../partnership/dto/financial-reporting-type'; +import { Location, LocationLoader, LocationType } from '../location'; +import { FinancialReportingType } from '../partnership/dto'; import { IProject, ProjectListInput, @@ -38,6 +41,7 @@ export class PartnerService { @Inject(forwardRef(() => ProjectService)) private readonly projectService: ProjectService & {}, private readonly repo: PartnerRepository, + private readonly resourceLoader: ResourceLoader, ) {} async create(input: CreatePartner, session: Session): Promise { @@ -55,6 +59,10 @@ export class PartnerService { ); } + if (input.countries) { + await this.verifyCountries(input.countries); + } + const id = await this.repo.create(input, session); this.logger.debug(`Partner created`, { id }); @@ -125,13 +133,19 @@ export class PartnerService { pointOfContactId, languageOfWiderCommunicationId, fieldRegions, + countries, ...simpleChanges } = changes; await this.repo.updateProperties(partner, simpleChanges); - if (pointOfContactId) { - await this.repo.updatePointOfContact(input.id, pointOfContactId, session); + if (pointOfContactId !== undefined) { + await this.repo.updateRelation( + 'pointOfContact', + 'User', + input.id, + pointOfContactId, + ); } if (languageOfWiderCommunicationId) { @@ -143,6 +157,22 @@ export class PartnerService { ); } + if (countries) { + await this.verifyCountries(countries); + + try { + await this.repo.updateRelationList({ + id: partner.id, + relation: 'countries', + newList: countries, + }); + } catch (e) { + throw e instanceof InputException + ? e.withField('partner.countries') + : e; + } + } + if (fieldRegions) { try { await this.repo.updateRelationList({ @@ -229,4 +259,26 @@ export class PartnerService { ? false : true; } + + private async verifyCountries(ids: ReadonlyArray>) { + const loader = await this.resourceLoader.getLoader(LocationLoader); + const locations = await loadManyIgnoreMissingThrowAny(loader, ids); + const invalidIds = locations.flatMap((location) => + location.type.value !== 'Country' ? location.id : [], + ); + if (invalidIds.length === 0) { + return; + } + const ex = new LocationTypeException([LocationType.Country], invalidIds); + throw ex.withField('partner.countries'); + } +} + +class LocationTypeException extends InputException { + constructor( + readonly allowedTypes: readonly LocationType[], + readonly invalidIds: ID[], + ) { + super('Given locations do not match the expected type'); + } } diff --git a/src/components/partnership/dto/create-partnership.dto.ts b/src/components/partnership/dto/create-partnership.dto.ts index 7addd4d5e6..c732a52340 100644 --- a/src/components/partnership/dto/create-partnership.dto.ts +++ b/src/components/partnership/dto/create-partnership.dto.ts @@ -6,7 +6,7 @@ import { CalendarDate, DateField, ID, IdField } from '../../../common'; import { ChangesetIdField } from '../../changeset'; import { CreateDefinedFileVersionInput } from '../../file/dto'; import { PartnerType } from '../../partner/dto'; -import { FinancialReportingType } from './financial-reporting-type'; +import { FinancialReportingType } from './financial-reporting-type.enum'; import { PartnershipAgreementStatus } from './partnership-agreement-status.enum'; import { Partnership } from './partnership.dto'; diff --git a/src/components/partnership/dto/financial-reporting-type.enum.ts b/src/components/partnership/dto/financial-reporting-type.enum.ts new file mode 100644 index 0000000000..9b02fb0b5b --- /dev/null +++ b/src/components/partnership/dto/financial-reporting-type.enum.ts @@ -0,0 +1,7 @@ +import { EnumType, makeEnum } from '~/common'; + +export type FinancialReportingType = EnumType; +export const FinancialReportingType = makeEnum({ + name: 'FinancialReportingType', + values: ['Funded', 'FieldEngaged', 'Hybrid'], +}); diff --git a/src/components/partnership/dto/financial-reporting-type.ts b/src/components/partnership/dto/financial-reporting-type.ts deleted file mode 100644 index 52c952f65c..0000000000 --- a/src/components/partnership/dto/financial-reporting-type.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum FinancialReportingType { - Funded = 'Funded', - FieldEngaged = 'FieldEngaged', - Hybrid = 'Hybrid', -} - -registerEnumType(FinancialReportingType, { name: 'FinancialReportingType' }); diff --git a/src/components/partnership/dto/index.ts b/src/components/partnership/dto/index.ts index f82c42ec0d..ecab4d7345 100644 --- a/src/components/partnership/dto/index.ts +++ b/src/components/partnership/dto/index.ts @@ -1,5 +1,5 @@ export * from './partnership-agreement-status.enum'; -export * from './financial-reporting-type'; +export * from './financial-reporting-type.enum'; export * from './partnership.dto'; export * from './create-partnership.dto'; export * from './update-partnership.dto'; diff --git a/src/components/partnership/dto/partnership-agreement-status.enum.ts b/src/components/partnership/dto/partnership-agreement-status.enum.ts index 8f95ac4e0f..df2307399a 100644 --- a/src/components/partnership/dto/partnership-agreement-status.enum.ts +++ b/src/components/partnership/dto/partnership-agreement-status.enum.ts @@ -1,11 +1,9 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum PartnershipAgreementStatus { - NotAttached = 'NotAttached', - AwaitingSignature = 'AwaitingSignature', - Signed = 'Signed', -} - -registerEnumType(PartnershipAgreementStatus, { +export type PartnershipAgreementStatus = EnumType< + typeof PartnershipAgreementStatus +>; +export const PartnershipAgreementStatus = makeEnum({ name: 'PartnershipAgreementStatus', + values: ['NotAttached', 'AwaitingSignature', 'Signed'], }); diff --git a/src/components/partnership/dto/partnership.dto.ts b/src/components/partnership/dto/partnership.dto.ts index 69bdbd7f3b..13f9758576 100644 --- a/src/components/partnership/dto/partnership.dto.ts +++ b/src/components/partnership/dto/partnership.dto.ts @@ -20,9 +20,9 @@ import { ScopedRole } from '../../authorization'; import { ChangesetAware } from '../../changeset/dto'; import { DefinedFile } from '../../file/dto'; import { Organization } from '../../organization/dto'; -import { SecuredPartnerTypes } from '../../partner/dto/partner-type.enum'; +import { SecuredPartnerTypes } from '../../partner/dto'; import { IProject } from '../../project/dto'; -import { FinancialReportingType } from './financial-reporting-type'; +import { FinancialReportingType } from './financial-reporting-type.enum'; import { PartnershipAgreementStatus } from './partnership-agreement-status.enum'; @ObjectType({ diff --git a/src/components/partnership/dto/update-partnership.dto.ts b/src/components/partnership/dto/update-partnership.dto.ts index 0d0a0568a6..00039a973c 100644 --- a/src/components/partnership/dto/update-partnership.dto.ts +++ b/src/components/partnership/dto/update-partnership.dto.ts @@ -6,7 +6,7 @@ import { CalendarDate, DateField, ID, IdField } from '../../../common'; import { ChangesetIdField } from '../../changeset'; import { CreateDefinedFileVersionInput } from '../../file/dto'; import { PartnerType } from '../../partner/dto'; -import { FinancialReportingType } from './financial-reporting-type'; +import { FinancialReportingType } from './financial-reporting-type.enum'; import { PartnershipAgreementStatus } from './partnership-agreement-status.enum'; import { Partnership } from './partnership.dto'; diff --git a/src/components/periodic-report/dto/periodic-report.dto.ts b/src/components/periodic-report/dto/periodic-report.dto.ts index 3ce798107d..6942c49228 100644 --- a/src/components/periodic-report/dto/periodic-report.dto.ts +++ b/src/components/periodic-report/dto/periodic-report.dto.ts @@ -71,7 +71,7 @@ export class FinancialReport extends PeriodicReport { static readonly SecuredProps = keysOf>(); static readonly Parent = 'dynamic'; - declare readonly type: ReportType.Financial; + declare readonly type: 'Financial'; } @RegisterResource() @@ -83,7 +83,7 @@ export class NarrativeReport extends PeriodicReport { static readonly SecuredProps = keysOf>(); static readonly Parent = 'dynamic'; - declare readonly type: ReportType.Narrative; + declare readonly type: 'Narrative'; } @ObjectType({ diff --git a/src/components/periodic-report/dto/report-period.enum.ts b/src/components/periodic-report/dto/report-period.enum.ts index 0f82737d8e..50f3f9ad26 100644 --- a/src/components/periodic-report/dto/report-period.enum.ts +++ b/src/components/periodic-report/dto/report-period.enum.ts @@ -1,12 +1,11 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnum, SecuredProperty } from '../../../common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnum, SecuredProperty } from '~/common'; -export enum ReportPeriod { - Monthly = 'Monthly', - Quarterly = 'Quarterly', -} - -registerEnumType(ReportPeriod, { name: 'PeriodType' }); +export type ReportPeriod = EnumType; +export const ReportPeriod = makeEnum({ + name: 'PeriodType', + values: ['Monthly', 'Quarterly'], +}); @ObjectType({ description: SecuredProperty.descriptionFor('report period'), diff --git a/src/components/periodic-report/dto/report-type.enum.ts b/src/components/periodic-report/dto/report-type.enum.ts index bd8ede8bb5..da5a8c9810 100644 --- a/src/components/periodic-report/dto/report-type.enum.ts +++ b/src/components/periodic-report/dto/report-type.enum.ts @@ -1,9 +1,7 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum ReportType { - Financial = 'Financial', - Progress = 'Progress', - Narrative = 'Narrative', -} - -registerEnumType(ReportType, { name: 'ReportType' }); +export type ReportType = EnumType; +export const ReportType = makeEnum({ + name: 'ReportType', + values: ['Financial', 'Progress', 'Narrative'], +}); diff --git a/src/components/post/dto/create-post.dto.ts b/src/components/post/dto/create-post.dto.ts index 4174f471a7..90788574e7 100644 --- a/src/components/post/dto/create-post.dto.ts +++ b/src/components/post/dto/create-post.dto.ts @@ -2,9 +2,9 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; import { IsNotEmpty, ValidateNested } from 'class-validator'; import { ID, IdField } from '../../../common'; +import { PostType } from './post-type.enum'; import { Post } from './post.dto'; import { PostShareability } from './shareability.dto'; -import { PostType } from './type.enum'; @InputType() export class CreatePost { diff --git a/src/components/post/dto/post-type.enum.ts b/src/components/post/dto/post-type.enum.ts new file mode 100644 index 0000000000..4f0fe3ebae --- /dev/null +++ b/src/components/post/dto/post-type.enum.ts @@ -0,0 +1,7 @@ +import { EnumType, makeEnum } from '~/common'; + +export type PostType = EnumType; +export const PostType = makeEnum({ + name: 'PostType', + values: ['Note', 'Story', 'Prayer'], +}); diff --git a/src/components/post/dto/post.dto.ts b/src/components/post/dto/post.dto.ts index 294641a361..490661330c 100644 --- a/src/components/post/dto/post.dto.ts +++ b/src/components/post/dto/post.dto.ts @@ -11,8 +11,8 @@ import { SecuredProps, SecuredString, } from '../../../common'; +import { PostType } from './post-type.enum'; import { PostShareability } from './shareability.dto'; -import { PostType } from './type.enum'; @RegisterResource() @ObjectType({ diff --git a/src/components/post/dto/type.enum.ts b/src/components/post/dto/type.enum.ts deleted file mode 100644 index 86e0b837de..0000000000 --- a/src/components/post/dto/type.enum.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum PostType { - Note = 'Note', - Story = 'Story', - Prayer = 'Prayer', -} - -registerEnumType(PostType, { - name: 'PostType', -}); diff --git a/src/components/post/dto/update-post.dto.ts b/src/components/post/dto/update-post.dto.ts index 9b81685211..2379ebf167 100644 --- a/src/components/post/dto/update-post.dto.ts +++ b/src/components/post/dto/update-post.dto.ts @@ -2,9 +2,9 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; import { IsNotEmpty, ValidateNested } from 'class-validator'; import { ID, IdField } from '../../../common'; +import { PostType } from './post-type.enum'; import { Post } from './post.dto'; import { PostShareability } from './shareability.dto'; -import { PostType } from './type.enum'; @InputType() export abstract class UpdatePost { diff --git a/src/components/product-progress/dto/progress-format.enum.ts b/src/components/product-progress/dto/progress-format.enum.ts index d68208d10b..59d04eaf93 100644 --- a/src/components/product-progress/dto/progress-format.enum.ts +++ b/src/components/product-progress/dto/progress-format.enum.ts @@ -1,46 +1,44 @@ -import { registerEnumType } from '@nestjs/graphql'; import { stripIndent } from 'common-tags'; +import { EnumType, makeEnum } from '~/common'; -export enum ProgressFormat { - Numerator = 'Numerator', - Decimal = 'Decimal', - Percent = 'Percent', - Verses = 'Verses', - VerseEquivalents = 'VerseEquivalents', -} - -registerEnumType(ProgressFormat, { +export type ProgressFormat = EnumType; +export const ProgressFormat = makeEnum({ name: 'ProgressFormat', description: 'A format for a progress number', - valuesMap: { - Numerator: { + values: [ + { + value: 'Numerator', description: stripIndent` The raw value that does not take into account the target value. This will be 0 <= # <= the product's \`progressTarget\` number. For example, # of Y complete `, }, - Decimal: { + { + value: 'Decimal', description: stripIndent` A percent expressed as a decimal (0-1) For example, 0.# * 100 percent complete `, }, - Percent: { + { + value: 'Percent', description: stripIndent` A percent which already has already been multiplied by 100 For example, ##.#% complete `, }, - Verses: { + { + value: 'Verses', description: stripIndent` The number of verses completed `, }, - VerseEquivalents: { + { + value: 'VerseEquivalents', description: stripIndent` The number of verse equivalents completed `, }, - }, + ], }); diff --git a/src/components/product/dto/available-steps.ts b/src/components/product/dto/available-steps.ts index 1fcec770ad..b0bf82a789 100644 --- a/src/components/product/dto/available-steps.ts +++ b/src/components/product/dto/available-steps.ts @@ -1,10 +1,10 @@ import { ArgsType, Field } from '@nestjs/graphql'; import { ProducibleType } from './producible.dto'; -import { ProductApproach as Approach } from './product-approach'; +import { ProductApproach as Approach } from './product-approach.enum'; import { ApproachToMethodologies, ProductMethodology as Methodology, -} from './product-methodology'; +} from './product-methodology.enum'; import { ProductStep as Step } from './product-step.enum'; @ArgsType() diff --git a/src/components/product/dto/completion-description.dto.ts b/src/components/product/dto/completion-description.dto.ts index 7dd9818e3f..7d67025557 100644 --- a/src/components/product/dto/completion-description.dto.ts +++ b/src/components/product/dto/completion-description.dto.ts @@ -1,6 +1,6 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql'; import { PaginatedList, PaginationInput } from '../../../common'; -import { ProductMethodology } from './product-methodology'; +import { ProductMethodology } from './product-methodology.enum'; @InputType() export class ProductCompletionDescriptionSuggestionsInput extends PaginationInput { diff --git a/src/components/product/dto/create-product.dto.ts b/src/components/product/dto/create-product.dto.ts index c6de7a132d..c2af2f8fbc 100644 --- a/src/components/product/dto/create-product.dto.ts +++ b/src/components/product/dto/create-product.dto.ts @@ -10,9 +10,9 @@ import { ScriptureRangeInput, UnspecifiedScripturePortionInput, } from '../../scripture'; -import { ProductMedium } from './product-medium'; -import { ProductMethodology } from './product-methodology'; -import { ProductPurpose } from './product-purpose'; +import { ProductMedium } from './product-medium.enum'; +import { ProductMethodology } from './product-methodology.enum'; +import { ProductPurpose } from './product-purpose.enum'; import { ProductStep as Step } from './product-step.enum'; import { AnyProduct, Product } from './product.dto'; import { ProgressMeasurement } from './progress-measurement.enum'; diff --git a/src/components/product/dto/index.ts b/src/components/product/dto/index.ts index d79efb2d23..2ee619016c 100644 --- a/src/components/product/dto/index.ts +++ b/src/components/product/dto/index.ts @@ -1,7 +1,7 @@ -export * from './product-approach'; -export * from './product-medium'; -export * from './product-methodology'; -export * from './product-purpose'; +export * from './product-approach.enum'; +export * from './product-medium.enum'; +export * from './product-methodology.enum'; +export * from './product-purpose.enum'; export * from './product-step.enum'; export * from './producible.dto'; export * from './create-product.dto'; diff --git a/src/components/product/dto/list-product.dto.ts b/src/components/product/dto/list-product.dto.ts index c860fdd7f2..64694e04d7 100644 --- a/src/components/product/dto/list-product.dto.ts +++ b/src/components/product/dto/list-product.dto.ts @@ -7,8 +7,8 @@ import { SecuredList, SortablePaginationInput, } from '~/common'; -import { ProductApproach } from './product-approach'; -import { ProductMethodology } from './product-methodology'; +import { ProductApproach } from './product-approach.enum'; +import { ProductMethodology } from './product-methodology.enum'; import { AnyProduct, Product } from './product.dto'; @InputType() diff --git a/src/components/product/dto/product-approach.enum.ts b/src/components/product/dto/product-approach.enum.ts new file mode 100644 index 0000000000..c1c6caf8dd --- /dev/null +++ b/src/components/product/dto/product-approach.enum.ts @@ -0,0 +1,11 @@ +import { EnumType, makeEnum } from '~/common'; + +/** + * This is a roll up of methodology, for easier querying + */ +export type ProductApproach = EnumType; +export const ProductApproach = makeEnum({ + name: 'ProductApproach', + description: 'This is a roll up of methodology, for easier querying', + values: ['Written', 'OralTranslation', 'OralStories', 'Visual'], +}); diff --git a/src/components/product/dto/product-approach.ts b/src/components/product/dto/product-approach.ts deleted file mode 100644 index f4ea0b323c..0000000000 --- a/src/components/product/dto/product-approach.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -/** - * This is a roll up of methodology, for easier querying - */ -export enum ProductApproach { - Written = 'Written', - OralTranslation = 'OralTranslation', - OralStories = 'OralStories', - Visual = 'Visual', -} - -registerEnumType(ProductApproach, { - name: 'ProductApproach', - description: 'This is a roll up of methodology, for easier querying', -}); diff --git a/src/components/product/dto/product-medium.enum.ts b/src/components/product/dto/product-medium.enum.ts new file mode 100644 index 0000000000..7d17e7d0ab --- /dev/null +++ b/src/components/product/dto/product-medium.enum.ts @@ -0,0 +1,33 @@ +import { ObjectType } from '@nestjs/graphql'; +import { stripIndent } from 'common-tags'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; + +/** + * How the product is delivered. + * + * This is independent of how the translation is done. + */ +export type ProductMedium = EnumType; +export const ProductMedium = makeEnum({ + name: 'ProductMedium', + description: stripIndent` + How the product is delivered? + + This is independent of how the translation is done. + `, + values: [ + 'Print', + 'Web', + { value: 'EBook', label: 'E-Book' }, + 'App', + 'TrainedStoryTellers', + 'Audio', + 'Video', + 'Other', + ], +}); + +@ObjectType({ + description: SecuredEnumList.descriptionFor('product mediums'), +}) +export class SecuredProductMediums extends SecuredEnumList(ProductMedium) {} diff --git a/src/components/product/dto/product-medium.ts b/src/components/product/dto/product-medium.ts deleted file mode 100644 index 55d1205b0b..0000000000 --- a/src/components/product/dto/product-medium.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnumList } from '../../../common'; - -/** - * How the product is delivered. - * - * This is independent of how the translation is done. - */ -export enum ProductMedium { - Print = 'Print', - Web = 'Web', - EBook = 'EBook', - App = 'App', - TrainedStoryTellers = 'TrainedStoryTellers', - Audio = 'Audio', - Video = 'Video', - Other = 'Other', -} - -registerEnumType(ProductMedium, { - name: 'ProductMedium', - description: 'How the product is delivered', - valuesMap: { - EBook: { - description: `@label E-Book`, - }, - }, -}); - -@ObjectType({ - description: SecuredEnumList.descriptionFor('product mediums'), -}) -export class SecuredProductMediums extends SecuredEnumList(ProductMedium) {} diff --git a/src/components/product/dto/product-methodology.ts b/src/components/product/dto/product-methodology.enum.ts similarity index 66% rename from src/components/product/dto/product-methodology.ts rename to src/components/product/dto/product-methodology.enum.ts index d6e49be58d..df0e566022 100644 --- a/src/components/product/dto/product-methodology.ts +++ b/src/components/product/dto/product-methodology.enum.ts @@ -1,34 +1,46 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; +import { ObjectType } from '@nestjs/graphql'; import { invertBy } from 'lodash'; -import { SecuredEnum, SecuredEnumList } from '../../../common'; -import { ProductApproach as Approach } from './product-approach'; +import { EnumType, makeEnum, SecuredEnum, SecuredEnumList } from '~/common'; +import { ProductApproach as Approach } from './product-approach.enum'; /** * How is this translation being done */ -export enum ProductMethodology { - // Written - Paratext = 'Paratext', - OtherWritten = 'OtherWritten', - - // Oral Translation - Render = 'Render', - Audacity = 'Audacity', - AdobeAudition = 'AdobeAudition', - OtherOralTranslation = 'OtherOralTranslation', +export type ProductMethodology = EnumType; +export const ProductMethodology = makeEnum({ + name: 'ProductMethodology', + description: 'How is this translation being done', + values: [ + // Written + 'Paratext', + 'OtherWritten', + // Oral Translation + 'Render', + 'Audacity', + 'AdobeAudition', + 'OtherOralTranslation', + // Oral Stories + 'StoryTogether', + 'SeedCompanyMethod', + 'OneStory', + 'Craft2Tell', + 'OtherOralStories', + // Visual + 'Film', + 'SignLanguage', + 'OtherVisual', + ], +}); - // Oral Stories - StoryTogether = 'StoryTogether', - SeedCompanyMethod = 'SeedCompanyMethod', - OneStory = 'OneStory', - Craft2Tell = 'Craft2Tell', - OtherOralStories = 'OtherOralStories', +@ObjectType({ + description: SecuredEnum.descriptionFor('a product methodology'), +}) +export class SecuredMethodology extends SecuredEnum(ProductMethodology) {} - // Visual - Film = 'Film', - SignLanguage = 'SignLanguage', - OtherVisual = 'OtherVisual', -} +@ObjectType({ + description: SecuredEnumList.descriptionFor('methodologies'), +}) +export class SecuredMethodologies extends SecuredEnumList(ProductMethodology) {} export const MethodologyToApproach: Record = { // Written @@ -57,18 +69,3 @@ export const MethodologyToApproach: Record = { export const ApproachToMethodologies = invertBy( MethodologyToApproach, ) as Record; - -registerEnumType(ProductMethodology, { - name: 'ProductMethodology', - description: 'How is this translation being done', -}); - -@ObjectType({ - description: SecuredEnum.descriptionFor('a product methodology'), -}) -export class SecuredMethodology extends SecuredEnum(ProductMethodology) {} - -@ObjectType({ - description: SecuredEnumList.descriptionFor('methodologies'), -}) -export class SecuredMethodologies extends SecuredEnumList(ProductMethodology) {} diff --git a/src/components/product/dto/product-purpose.enum.ts b/src/components/product/dto/product-purpose.enum.ts new file mode 100644 index 0000000000..ab2a6b9a8d --- /dev/null +++ b/src/components/product/dto/product-purpose.enum.ts @@ -0,0 +1,23 @@ +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; + +/** + * Why is this translation happening? + */ +export type ProductPurpose = EnumType; +export const ProductPurpose = makeEnum({ + name: 'ProductPurpose', + description: 'Why is this translation happening?', + values: [ + 'EvangelismChurchPlanting', + 'ChurchLife', + 'ChurchMaturity', + 'SocialIssues', + 'Discipleship', + ], +}); + +@ObjectType({ + description: SecuredEnumList.descriptionFor('product purposes'), +}) +export class SecuredProductPurposes extends SecuredEnumList(ProductPurpose) {} diff --git a/src/components/product/dto/product-purpose.ts b/src/components/product/dto/product-purpose.ts deleted file mode 100644 index 744c5046d9..0000000000 --- a/src/components/product/dto/product-purpose.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnumList } from '../../../common'; - -/** - * Why is this translation happening? - */ -export enum ProductPurpose { - EvangelismChurchPlanting = 'EvangelismChurchPlanting', - ChurchLife = 'ChurchLife', - ChurchMaturity = 'ChurchMaturity', - SocialIssues = 'SocialIssues', - Discipleship = 'Discipleship', -} - -registerEnumType(ProductPurpose, { - name: 'ProductPurpose', -}); - -@ObjectType({ - description: SecuredEnumList.descriptionFor('product purposes'), -}) -export class SecuredProductPurposes extends SecuredEnumList(ProductPurpose) {} diff --git a/src/components/product/dto/product-step.enum.ts b/src/components/product/dto/product-step.enum.ts index 8a34adbacb..17cd9392de 100644 --- a/src/components/product/dto/product-step.enum.ts +++ b/src/components/product/dto/product-step.enum.ts @@ -1,27 +1,27 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnumList } from '../../../common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; -export enum ProductStep { - ExegesisAndFirstDraft = 'ExegesisAndFirstDraft', - TeamCheck = 'TeamCheck', - CommunityTesting = 'CommunityTesting', - BackTranslation = 'BackTranslation', - ConsultantCheck = 'ConsultantCheck', - InternalizationAndDrafting = 'InternalizationAndDrafting', - PeerRevision = 'PeerRevision', - ConsistencyCheckAndFinalEdits = 'ConsistencyCheckAndFinalEdits', - Craft = 'Craft', - Test = 'Test', - Check = 'Check', - Record = 'Record', - Develop = 'Develop', - Translate = 'Translate', - Completed = 'Completed', -} - -registerEnumType(ProductStep, { +export type ProductStep = EnumType; +export const ProductStep = makeEnum({ name: 'ProductStep', description: 'A step required to complete a product/"goal".', + values: [ + 'ExegesisAndFirstDraft', + 'TeamCheck', + 'CommunityTesting', + 'BackTranslation', + 'ConsultantCheck', + 'InternalizationAndDrafting', + 'PeerRevision', + 'ConsistencyCheckAndFinalEdits', + 'Craft', + 'Test', + 'Check', + 'Record', + 'Develop', + 'Translate', + 'Completed', + ], }); @ObjectType({ diff --git a/src/components/product/dto/product.dto.ts b/src/components/product/dto/product.dto.ts index f2918fde82..acc22a3081 100644 --- a/src/components/product/dto/product.dto.ts +++ b/src/components/product/dto/product.dto.ts @@ -27,9 +27,9 @@ import { SecuredUnspecifiedScripturePortion, } from '../../scripture'; import { Producible, ProducibleRef, SecuredProducible } from './producible.dto'; -import { SecuredProductMediums } from './product-medium'; -import { SecuredMethodology } from './product-methodology'; -import { SecuredProductPurposes } from './product-purpose'; +import { SecuredProductMediums } from './product-medium.enum'; +import { SecuredMethodology } from './product-methodology.enum'; +import { SecuredProductPurposes } from './product-purpose.enum'; import { SecuredProductSteps } from './product-step.enum'; import { SecuredProgressMeasurement } from './progress-measurement.enum'; diff --git a/src/components/product/dto/progress-measurement.enum.ts b/src/components/product/dto/progress-measurement.enum.ts index c9a709a275..85efaf9ee5 100644 --- a/src/components/product/dto/progress-measurement.enum.ts +++ b/src/components/product/dto/progress-measurement.enum.ts @@ -1,20 +1,11 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnum } from '../../../common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnum } from '~/common'; -export enum ProgressMeasurement { - Percent = 'Percent', - Number = 'Number', - Boolean = 'Boolean', -} - -registerEnumType(ProgressMeasurement, { +export type ProgressMeasurement = EnumType; +export const ProgressMeasurement = makeEnum({ name: 'ProgressMeasurement', description: 'Measurement units for reporting progress', - valuesMap: { - Boolean: { - description: `@label Done / Not Done`, - }, - }, + values: ['Number', 'Percent', { value: 'Boolean', label: 'Done / Not Done' }], }); @ObjectType({ diff --git a/src/components/progress-report/dto/community-stories.dto.ts b/src/components/progress-report/dto/community-stories.dto.ts index 89608c3e20..8abf494842 100644 --- a/src/components/progress-report/dto/community-stories.dto.ts +++ b/src/components/progress-report/dto/community-stories.dto.ts @@ -1,6 +1,6 @@ import { keys as keysOf } from 'ts-transformer-keys'; import { SecuredProps, VariantOf } from '~/common'; -import { RegisterResource } from '~/core'; +import { RegisterResource } from '~/core/resources'; import { PromptVariantResponse } from '../../prompts/dto'; import { ProgressReportHighlight } from './highlights.dto'; diff --git a/src/components/progress-report/dto/progress-report.entity.ts b/src/components/progress-report/dto/progress-report.entity.ts index 7eca922929..17f5ae82b8 100644 --- a/src/components/progress-report/dto/progress-report.entity.ts +++ b/src/components/progress-report/dto/progress-report.entity.ts @@ -12,7 +12,6 @@ import { RegisterResource } from '~/core/resources'; import { LanguageEngagement } from '../../engagement/dto'; import { DefinedFile } from '../../file'; import { IPeriodicReport } from '../../periodic-report/dto/periodic-report.dto'; -import { ReportType } from '../../periodic-report/dto/report-type.enum'; import { ProgressReportCommunityStory } from './community-stories.dto'; import { ProgressReportHighlight } from './highlights.dto'; import { SecuredProgressReportStatus as SecuredStatus } from './progress-report-status.enum'; @@ -34,7 +33,7 @@ export class ProgressReport extends IPeriodicReport { communityStories: [ProgressReportCommunityStory], } satisfies ResourceRelationsShape; - declare readonly type: ReportType.Progress; + declare readonly type: 'Progress'; @Field(() => LanguageEngagement) declare readonly parent: BaseNode; diff --git a/src/components/progress-report/variance-explanation/variance-explanation.resolver.ts b/src/components/progress-report/variance-explanation/variance-explanation.resolver.ts index b9e4a23eb2..fcc641c76e 100644 --- a/src/components/progress-report/variance-explanation/variance-explanation.resolver.ts +++ b/src/components/progress-report/variance-explanation/variance-explanation.resolver.ts @@ -8,10 +8,7 @@ import { import { clamp } from 'lodash'; import { AnonSession, LoggedInSession, Session } from '~/common'; import { Loader, LoaderOf } from '~/core'; -import { - ScheduleStatus, - fromVariance as scheduleStatusFromVariance, -} from '../../progress-summary/dto/schedule-status.enum'; +import { ScheduleStatus } from '../../progress-summary/dto'; import { ProgressSummaryLoader } from '../../progress-summary/progress-summary.loader'; import { ProgressReport } from '../dto'; import { ProgressReportVarianceExplanationReasonOptions as ReasonOptions } from './reason-options'; @@ -87,6 +84,6 @@ export class ProgressReportVarianceExplanationReasonOptionsResolver { const actual = clamp(summary.actual, 0, 1); const planned = clamp(summary.planned, 0, 1); const variance = actual - planned; - return scheduleStatusFromVariance(variance); + return ScheduleStatus.fromVariance(variance); } } diff --git a/src/components/progress-report/workflow/dto/workflow-transition.dto.ts b/src/components/progress-report/workflow/dto/workflow-transition.dto.ts index b0b05c8afc..adeaa153e7 100644 --- a/src/components/progress-report/workflow/dto/workflow-transition.dto.ts +++ b/src/components/progress-report/workflow/dto/workflow-transition.dto.ts @@ -1,6 +1,6 @@ import { Field, ObjectType } from '@nestjs/graphql'; import { ID, IdField } from '~/common'; -import { TransitionType } from '../../../project/dto/step.enum'; +import { TransitionType } from '../../../project/dto'; import { ProgressReportStatus } from '../../dto'; export { TransitionType }; diff --git a/src/components/progress-report/workflow/transitions.ts b/src/components/progress-report/workflow/transitions.ts index afaf3573e8..05dbc5bb2e 100644 --- a/src/components/progress-report/workflow/transitions.ts +++ b/src/components/progress-report/workflow/transitions.ts @@ -1,7 +1,7 @@ import { createHash } from 'crypto'; import { mapValues } from 'lodash'; import { ID, Many, maybeMany, Role } from '~/common'; -import { ProgressReportStatus as Status } from '../dto/progress-report-status.enum'; +import { ProgressReportStatus as Status } from '../dto'; import { ProgressReportWorkflowTransition as PublicTransition, TransitionType as Type, diff --git a/src/components/progress-summary/dto/index.ts b/src/components/progress-summary/dto/index.ts index c1f2eab140..b7a4d3fb9e 100644 --- a/src/components/progress-summary/dto/index.ts +++ b/src/components/progress-summary/dto/index.ts @@ -1 +1,2 @@ export * from './progress-summary.dto'; +export * from './schedule-status.enum'; diff --git a/src/components/progress-summary/dto/schedule-status.enum.ts b/src/components/progress-summary/dto/schedule-status.enum.ts index c5a5d1b682..b87f03ddb1 100644 --- a/src/components/progress-summary/dto/schedule-status.enum.ts +++ b/src/components/progress-summary/dto/schedule-status.enum.ts @@ -1,22 +1,19 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum ScheduleStatus { - Ahead = 'Ahead', - OnTime = 'OnTime', - Behind = 'Behind', -} - -export const fromVariance = (variance: number) => { - if (variance > 1 || variance < -1) { - throw new Error('Variance should be a decimal between [-1, 1]'); - } - return variance > 0.3 - ? ScheduleStatus.Ahead - : variance < -0.1 - ? ScheduleStatus.Behind - : ScheduleStatus.OnTime; -}; - -registerEnumType(ScheduleStatus, { +export type ScheduleStatus = EnumType; +export const ScheduleStatus = makeEnum({ name: 'ScheduleStatus', + values: ['Ahead', 'OnTime', 'Behind'], + extra: (status) => ({ + fromVariance: (variance: number) => { + if (variance > 1 || variance < -1) { + throw new Error('Variance should be a decimal between [-1, 1]'); + } + return variance > 0.3 + ? status.Ahead + : variance < -0.1 + ? status.Behind + : status.OnTime; + }, + }), }); diff --git a/src/components/progress-summary/progress-summary.resolver.ts b/src/components/progress-summary/progress-summary.resolver.ts index 2ad332a540..b780561813 100644 --- a/src/components/progress-summary/progress-summary.resolver.ts +++ b/src/components/progress-summary/progress-summary.resolver.ts @@ -4,11 +4,7 @@ import { stripIndent } from 'common-tags'; import { clamp } from 'lodash'; import { simpleSwitch } from '../../common'; import { ProgressFormat } from '../product-progress/dto'; -import { ProgressSummary } from './dto'; -import { - ScheduleStatus, - fromVariance as scheduleStatusFromVariance, -} from './dto/schedule-status.enum'; +import { ProgressSummary, ScheduleStatus } from './dto'; const formatArg: ArgsOptions = { name: 'format', @@ -67,6 +63,6 @@ export class ProgressSummaryResolver { }) scheduleStatus(@Parent() summary: ProgressSummary): ScheduleStatus { const variance = this.variance(summary, ProgressFormat.Decimal); - return scheduleStatusFromVariance(variance); + return ScheduleStatus.fromVariance(variance); } } diff --git a/src/components/project-change-request/dto/project-change-request-status.enum.ts b/src/components/project-change-request/dto/project-change-request-status.enum.ts index 58d4a80e01..4e3abe8840 100644 --- a/src/components/project-change-request/dto/project-change-request-status.enum.ts +++ b/src/components/project-change-request/dto/project-change-request-status.enum.ts @@ -1,14 +1,12 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnum } from '../../../common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnum } from '~/common'; -export enum ProjectChangeRequestStatus { - Pending = 'Pending', - Approved = 'Approved', - Rejected = 'Rejected', -} - -registerEnumType(ProjectChangeRequestStatus, { +export type ProjectChangeRequestStatus = EnumType< + typeof ProjectChangeRequestStatus +>; +export const ProjectChangeRequestStatus = makeEnum({ name: 'ProjectChangeRequestStatus', + values: ['Pending', 'Approved', 'Rejected'], }); @ObjectType({ diff --git a/src/components/project-change-request/dto/project-change-request-type.enum.ts b/src/components/project-change-request/dto/project-change-request-type.enum.ts index 90049617ae..443fc97ad9 100644 --- a/src/components/project-change-request/dto/project-change-request-type.enum.ts +++ b/src/components/project-change-request/dto/project-change-request-type.enum.ts @@ -1,18 +1,13 @@ -import { ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnumList } from '../../../common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnumList } from '~/common'; -export enum ProjectChangeRequestType { - Time = 'Time', - Budget = 'Budget', - Goal = 'Goal', - Engagement = 'Engagement', - Other = 'Other', -} - -registerEnumType(ProjectChangeRequestType, { +export type ProjectChangeRequestType = EnumType< + typeof ProjectChangeRequestType +>; +export const ProjectChangeRequestType = makeEnum({ name: 'ProjectChangeRequestType', + values: ['Time', 'Budget', 'Goal', 'Engagement', 'Other'], }); - @ObjectType({ description: SecuredEnumList.descriptionFor('project change request types'), }) diff --git a/src/components/project/dto/create-project.dto.ts b/src/components/project/dto/create-project.dto.ts index ff6ce3d6ce..8890880707 100644 --- a/src/components/project/dto/create-project.dto.ts +++ b/src/components/project/dto/create-project.dto.ts @@ -15,9 +15,9 @@ import { SensitivityField, } from '../../../common'; import { ReportPeriod } from '../../periodic-report/dto'; +import { ProjectStep } from './project-step.enum'; +import { ProjectType } from './project-type.enum'; import { IProject, Project } from './project.dto'; -import { ProjectStep } from './step.enum'; -import { ProjectType } from './type.enum'; @InputType() export abstract class CreateProject { diff --git a/src/components/project/dto/index.ts b/src/components/project/dto/index.ts index d9c51aadda..52490dc1f6 100644 --- a/src/components/project/dto/index.ts +++ b/src/components/project/dto/index.ts @@ -1,6 +1,6 @@ -export * from './status.enum'; -export * from './step.enum'; -export * from './type.enum'; +export * from './project-status.enum'; +export * from './project-step.enum'; +export * from './project-type.enum'; export * from './create-project.dto'; export * from './list-projects.dto'; export * from './project.dto'; diff --git a/src/components/project/dto/list-projects.dto.ts b/src/components/project/dto/list-projects.dto.ts index c43e0d2b4e..d20f2f5bd7 100644 --- a/src/components/project/dto/list-projects.dto.ts +++ b/src/components/project/dto/list-projects.dto.ts @@ -11,15 +11,15 @@ import { Sensitivity, SortablePaginationInput, } from '~/common'; +import { ProjectStatus } from './project-status.enum'; +import { ProjectStep } from './project-step.enum'; +import { ProjectType } from './project-type.enum'; import { InternshipProject, IProject, Project, TranslationProject, } from './project.dto'; -import { ProjectStatus } from './status.enum'; -import { ProjectStep } from './step.enum'; -import { ProjectType } from './type.enum'; @InputType() export abstract class ProjectFilters { diff --git a/src/components/project/dto/status.enum.ts b/src/components/project/dto/project-status.enum.ts similarity index 86% rename from src/components/project/dto/status.enum.ts rename to src/components/project/dto/project-status.enum.ts index c4a0ef1105..fa2a390c8f 100644 --- a/src/components/project/dto/status.enum.ts +++ b/src/components/project/dto/project-status.enum.ts @@ -1,17 +1,18 @@ -import { createUnionType, registerEnumType } from '@nestjs/graphql'; -import { ProjectStep } from './step.enum'; +import { createUnionType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; +import { ProjectStep } from './project-step.enum'; -export enum ProjectStatus { - InDevelopment = 'InDevelopment', - Active = 'Active', - Terminated = 'Terminated', - Completed = 'Completed', - DidNotDevelop = 'DidNotDevelop', -} - -registerEnumType(ProjectStatus, { +export type ProjectStatus = EnumType; +export const ProjectStatus = makeEnum({ name: 'ProjectStatus', description: 'A alias for a group of project steps', + values: [ + 'InDevelopment', + 'Active', + 'Terminated', + 'Completed', + 'DidNotDevelop', + ], }); const mapping: Record = { diff --git a/src/components/project/dto/project-step.enum.ts b/src/components/project/dto/project-step.enum.ts new file mode 100644 index 0000000000..cafc75536b --- /dev/null +++ b/src/components/project/dto/project-step.enum.ts @@ -0,0 +1,66 @@ +import { Field, ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnum } from '~/common'; + +export type ProjectStep = EnumType; +export const ProjectStep = makeEnum({ + name: 'ProjectStep', + values: [ + 'EarlyConversations', + 'PendingConceptApproval', + 'PrepForConsultantEndorsement', + 'PendingConsultantEndorsement', + 'PrepForFinancialEndorsement', + 'PendingFinancialEndorsement', + 'FinalizingProposal', + 'PendingRegionalDirectorApproval', + 'PendingZoneDirectorApproval', + 'PendingFinanceConfirmation', + 'OnHoldFinanceConfirmation', + 'DidNotDevelop', + 'Rejected', + 'Active', + 'ActiveChangedPlan', + 'DiscussingChangeToPlan', + 'PendingChangeToPlanApproval', + 'PendingChangeToPlanConfirmation', + 'DiscussingSuspension', + 'PendingSuspensionApproval', + 'Suspended', + 'DiscussingReactivation', + 'PendingReactivationApproval', + 'DiscussingTermination', + 'PendingTerminationApproval', + 'FinalizingCompletion', + 'Terminated', + 'Completed', + ], +}); + +@ObjectType({ + description: SecuredEnum.descriptionFor('a project step'), +}) +export class SecuredProjectStep extends SecuredEnum(ProjectStep) {} + +export type TransitionType = EnumType; +export const TransitionType = makeEnum({ + name: 'TransitionType', + values: ['Neutral', 'Approve', 'Reject'], +}); + +@ObjectType() +export abstract class ProjectStepTransition { + @Field(() => ProjectStep) + to: ProjectStep; + + @Field() + label: string; + + @Field(() => TransitionType) + type: TransitionType; + + @Field(() => Boolean, { defaultValue: false }) + disabled?: boolean; + + @Field(() => String, { nullable: true }) + disabledReason?: string; +} diff --git a/src/components/project/dto/project-type.enum.ts b/src/components/project/dto/project-type.enum.ts new file mode 100644 index 0000000000..7d52502b9e --- /dev/null +++ b/src/components/project/dto/project-type.enum.ts @@ -0,0 +1,7 @@ +import { EnumType, makeEnum } from '~/common'; + +export type ProjectType = EnumType; +export const ProjectType = makeEnum({ + name: 'ProjectType', + values: ['Translation', 'Internship'], +}); diff --git a/src/components/project/dto/project.dto.ts b/src/components/project/dto/project.dto.ts index d79c27c6ce..4efbc2ce1f 100644 --- a/src/components/project/dto/project.dto.ts +++ b/src/components/project/dto/project.dto.ts @@ -42,9 +42,9 @@ import { Pinnable } from '../../pin/dto'; import { Postable } from '../../post/dto'; import { ProjectChangeRequest } from '../../project-change-request/dto'; import { ProjectMember } from '../project-member/dto'; -import { ProjectStatus } from './status.enum'; -import { SecuredProjectStep } from './step.enum'; -import { ProjectType } from './type.enum'; +import { ProjectStatus } from './project-status.enum'; +import { SecuredProjectStep } from './project-step.enum'; +import { ProjectType } from './project-type.enum'; type AnyProject = MergeExclusive; @@ -190,7 +190,7 @@ export class TranslationProject extends Project { static readonly Props = keysOf(); static readonly SecuredProps = keysOf>(); - declare readonly type: ProjectType.Translation; + declare readonly type: 'Translation'; } @RegisterResource() @@ -201,7 +201,7 @@ export class InternshipProject extends Project { static readonly Props = keysOf(); static readonly SecuredProps = keysOf>(); - declare readonly type: ProjectType.Internship; + declare readonly type: 'Internship'; } export const projectRange = (project: UnsecuredDto) => diff --git a/src/components/project/dto/step.enum.ts b/src/components/project/dto/step.enum.ts deleted file mode 100644 index 019d9cc1f1..0000000000 --- a/src/components/project/dto/step.enum.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Field, ObjectType, registerEnumType } from '@nestjs/graphql'; -import { SecuredEnum } from '../../../common'; - -export enum ProjectStep { - EarlyConversations = 'EarlyConversations', - PendingConceptApproval = 'PendingConceptApproval', - PrepForConsultantEndorsement = 'PrepForConsultantEndorsement', - PendingConsultantEndorsement = 'PendingConsultantEndorsement', - PrepForFinancialEndorsement = 'PrepForFinancialEndorsement', - PendingFinancialEndorsement = 'PendingFinancialEndorsement', - FinalizingProposal = 'FinalizingProposal', - PendingRegionalDirectorApproval = 'PendingRegionalDirectorApproval', - PendingZoneDirectorApproval = 'PendingZoneDirectorApproval', - PendingFinanceConfirmation = 'PendingFinanceConfirmation', - OnHoldFinanceConfirmation = 'OnHoldFinanceConfirmation', - - DidNotDevelop = 'DidNotDevelop', - Rejected = 'Rejected', - - Active = 'Active', - ActiveChangedPlan = 'ActiveChangedPlan', - DiscussingChangeToPlan = 'DiscussingChangeToPlan', - PendingChangeToPlanApproval = 'PendingChangeToPlanApproval', - PendingChangeToPlanConfirmation = 'PendingChangeToPlanConfirmation', - DiscussingSuspension = 'DiscussingSuspension', - PendingSuspensionApproval = 'PendingSuspensionApproval', - Suspended = 'Suspended', - DiscussingReactivation = 'DiscussingReactivation', - PendingReactivationApproval = 'PendingReactivationApproval', - DiscussingTermination = 'DiscussingTermination', - PendingTerminationApproval = 'PendingTerminationApproval', - FinalizingCompletion = 'FinalizingCompletion', - - Terminated = 'Terminated', - - Completed = 'Completed', -} - -registerEnumType(ProjectStep, { - name: 'ProjectStep', -}); - -@ObjectType({ - description: SecuredEnum.descriptionFor('a project step'), -}) -export class SecuredProjectStep extends SecuredEnum(ProjectStep) {} - -export enum TransitionType { - Neutral = 'Neutral', - Approve = 'Approve', - Reject = 'Reject', -} -registerEnumType(TransitionType, { name: 'TransitionType' }); - -@ObjectType() -export abstract class ProjectStepTransition { - @Field(() => ProjectStep) - to: ProjectStep; - - @Field() - label: string; - - @Field(() => TransitionType) - type: TransitionType; - - @Field(() => Boolean, { defaultValue: false }) - disabled?: boolean; - - @Field(() => String, { nullable: true }) - disabledReason?: string; -} diff --git a/src/components/project/dto/type.enum.ts b/src/components/project/dto/type.enum.ts deleted file mode 100644 index c44a8e625d..0000000000 --- a/src/components/project/dto/type.enum.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { registerEnumType } from '@nestjs/graphql'; - -export enum ProjectType { - Translation = 'Translation', - Internship = 'Internship', -} - -registerEnumType(ProjectType, { - name: 'ProjectType', -}); diff --git a/src/components/project/dto/update-project.dto.ts b/src/components/project/dto/update-project.dto.ts index 3070376bbc..0f768e2c2d 100644 --- a/src/components/project/dto/update-project.dto.ts +++ b/src/components/project/dto/update-project.dto.ts @@ -15,8 +15,8 @@ import { } from '../../../common'; import { ChangesetIdField } from '../../changeset'; import { ReportPeriod } from '../../periodic-report/dto'; +import { ProjectStep } from './project-step.enum'; import { IProject, Project } from './project.dto'; -import { ProjectStep } from './step.enum'; @InputType() export abstract class UpdateProject { diff --git a/src/components/project/project.rules.ts b/src/components/project/project.rules.ts index d30d689192..79ebd12ca2 100644 --- a/src/components/project/project.rules.ts +++ b/src/components/project/project.rules.ts @@ -487,6 +487,7 @@ export class ProjectRules { return { approvers: [ Role.Administrator, + Role.ProjectManager, Role.RegionalDirector, Role.FieldOperationsDirector, ], diff --git a/src/components/scripture/dto/book-difficulty.enum.ts b/src/components/scripture/dto/book-difficulty.enum.ts index ad0cba38b4..c3348bb1f5 100644 --- a/src/components/scripture/dto/book-difficulty.enum.ts +++ b/src/components/scripture/dto/book-difficulty.enum.ts @@ -1,13 +1,8 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum BookDifficulty { - Easy = 'Easy', - Normal = 'Normal', - Hard = 'Hard', - Hardest = 'Hardest', -} - -registerEnumType(BookDifficulty, { +export type BookDifficulty = EnumType; +export const BookDifficulty = makeEnum({ name: 'BookDifficulty', description: 'How hard is this book to translate?', + values: ['Easy', 'Normal', 'Hard', 'Hardest'], }); diff --git a/src/components/scripture/scripture-reference.repository.ts b/src/components/scripture/scripture-reference.repository.ts index 0f9bc22eca..6e131011e2 100644 --- a/src/components/scripture/scripture-reference.repository.ts +++ b/src/components/scripture/scripture-reference.repository.ts @@ -1,9 +1,9 @@ import { Injectable } from '@nestjs/common'; import { Node, node, Query, relation } from 'cypher-query-builder'; import { DateTime } from 'luxon'; -import { ID, Range } from '../../common'; -import { DatabaseService } from '../../core'; -import { ACTIVE, collect } from '../../core/database/query'; +import { ID, Range } from '~/common'; +import { DatabaseService } from '~/core/database'; +import { ACTIVE, collect } from '~/core/database/query'; import { ScriptureRange, ScriptureRangeInput } from './dto'; export type DbScriptureReferences = ReadonlyArray>>; diff --git a/src/components/search/dto/search-results.dto.ts b/src/components/search/dto/search-results.dto.ts index 89a0037554..9a58891353 100644 --- a/src/components/search/dto/search-results.dto.ts +++ b/src/components/search/dto/search-results.dto.ts @@ -1,6 +1,6 @@ -import { createUnionType, registerEnumType } from '@nestjs/graphql'; -import { mapValues, uniq } from 'lodash'; -import { keys, simpleSwitch } from '~/common'; +import { createUnionType } from '@nestjs/graphql'; +import { uniq } from 'lodash'; +import { EnumType, keys, makeEnum, simpleSwitch } from '~/common'; import { ResourceMap } from '~/core'; import { EthnoArt } from '../../ethno-art/dto'; import { FieldRegion } from '../../field-region/dto'; @@ -107,12 +107,11 @@ export type SearchType = | keyof typeof searchableAbstracts; // Don't use outside of defining GQL schema -export const GqlSearchType = mapValues( - { +export type GqlSearchType = EnumType; +export const GqlSearchType = makeEnum({ + name: 'SearchType', + values: Object.keys({ ...publicSearchable, ...searchableAbstracts, - }, - (v, k) => k, -); - -registerEnumType(GqlSearchType, { name: 'SearchType' }); + }), +}); diff --git a/src/components/user/dto/language-proficiency.enum.ts b/src/components/user/dto/language-proficiency.enum.ts index 620b6d4d50..dc6f69fff1 100644 --- a/src/components/user/dto/language-proficiency.enum.ts +++ b/src/components/user/dto/language-proficiency.enum.ts @@ -1,12 +1,7 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum LanguageProficiency { - Beginner = 'Beginner', - Conversational = 'Conversational', - Skilled = 'Skilled', - Fluent = 'Fluent', -} - -registerEnumType(LanguageProficiency, { +export type LanguageProficiency = EnumType; +export const LanguageProficiency = makeEnum({ name: 'LanguageProficiency', + values: ['Beginner', 'Conversational', 'Skilled', 'Fluent'], }); diff --git a/src/components/user/dto/user-status.enum.ts b/src/components/user/dto/user-status.enum.ts index a2ac14f63d..a49d06892f 100644 --- a/src/components/user/dto/user-status.enum.ts +++ b/src/components/user/dto/user-status.enum.ts @@ -1,10 +1,7 @@ -import { registerEnumType } from '@nestjs/graphql'; +import { EnumType, makeEnum } from '~/common'; -export enum UserStatus { - Active = 'Active', - Disabled = 'Disabled', -} - -registerEnumType(UserStatus, { +export type UserStatus = EnumType; +export const UserStatus = makeEnum({ name: 'UserStatus', + values: ['Active', 'Disabled'], }); diff --git a/src/components/user/education/dto/education.dto.ts b/src/components/user/education/dto/education.dto.ts index 18ce1167e6..a3513a9454 100644 --- a/src/components/user/education/dto/education.dto.ts +++ b/src/components/user/education/dto/education.dto.ts @@ -1,25 +1,29 @@ -import { Field, ObjectType, registerEnumType } from '@nestjs/graphql'; +import { Field, ObjectType } from '@nestjs/graphql'; import { keys as keysOf } from 'ts-transformer-keys'; -import { RegisterResource } from '~/core/resources'; import { + EnumType, + makeEnum, NameField, Resource, SecuredEnum, SecuredProperty, SecuredProps, SecuredString, -} from '../../../../common'; - -export enum Degree { - Primary = 'Primary', - Secondary = 'Secondary', - Associates = 'Associates', - Bachelors = 'Bachelors', - Masters = 'Masters', - Doctorate = 'Doctorate', -} +} from '~/common'; +import { RegisterResource } from '~/core/resources'; -registerEnumType(Degree, { name: 'Degree' }); +export type Degree = EnumType; +export const Degree = makeEnum({ + name: 'Degree', + values: [ + 'Primary', + 'Secondary', + 'Associates', + 'Bachelors', + 'Masters', + 'Doctorate', + ], +}); @ObjectType({ description: SecuredProperty.descriptionFor('a degree'), diff --git a/src/core/config/config.service.ts b/src/core/config/config.service.ts index 870d09b902..0077301213 100644 --- a/src/core/config/config.service.ts +++ b/src/core/config/config.service.ts @@ -9,7 +9,6 @@ import LRUCache from 'lru-cache'; import { Duration, DurationLike } from 'luxon'; import { nanoid } from 'nanoid'; import { Config as Neo4JDriverConfig } from 'neo4j-driver'; -import { PoolConfig } from 'pg'; import { keys as keysOf } from 'ts-transformer-keys'; import { Class, Merge, ReadonlyDeep } from 'type-fest'; import { csv, ID, ServerException } from '../../common'; @@ -177,30 +176,8 @@ export const makeConfig = (env: EnvironmentService) => }; })(); - postgres = (() => { - // Put the PG* env vars in the global env, so the library can use them. - // There's dozens of them, so we'll just pass them through implicitly. - for (const [key, value] of env) { - if (key.startsWith('PG')) { - process.env[key] = value; - } - } - /* eslint-disable @typescript-eslint/naming-convention */ - const config: PoolConfig = { - application_name: env.string('PGAPPNAME').optional('cord_api'), - connectionString: - env.string('PGURI').optional() ?? - env - .string('PGURL') - .optional('postgres://postgres:postgres@localhost/cord'), - }; - /* eslint-enable @typescript-eslint/naming-convention */ - return config; - })(); - - // Control which database is prioritized, while we migrate to postgres - database = env.string('DATABASE').optional('neo4j'); - usePostgres = this.database.toLowerCase() === 'postgres'; + // Control which database is prioritized, while we migrate. + databaseEngine = env.string('DATABASE').optional('neo4j').toLowerCase(); dbIndexesCreate = env.boolean('DB_CREATE_INDEXES').optional(true); dbAutoMigrate = env diff --git a/src/core/core.module.ts b/src/core/core.module.ts index f49bb56407..9634aadac4 100644 --- a/src/core/core.module.ts +++ b/src/core/core.module.ts @@ -14,7 +14,6 @@ import { EventsModule } from './events'; import { ExceptionFilter } from './exception/exception.filter'; import { ExceptionNormalizer } from './exception/exception.normalizer'; import { GraphqlModule } from './graphql'; -import { PostgresModule } from './postgres/postgres.module'; import { ResourceModule } from './resources/resource.module'; import { ScalarProviders } from './scalars.resolver'; import { TimeoutInterceptor } from './timeout.interceptor'; @@ -34,7 +33,6 @@ import { WaitResolver } from './wait.resolver'; GraphqlModule, EventsModule, TracingModule, - PostgresModule, ResourceModule, ], providers: [ @@ -59,7 +57,6 @@ import { WaitResolver } from './wait.resolver'; EventsModule, ResourceModule, TracingModule, - PostgresModule, ], }) export class CoreModule {} diff --git a/src/core/database/index.ts b/src/core/database/index.ts index 705e7c44f1..5be012d5c6 100644 --- a/src/core/database/index.ts +++ b/src/core/database/index.ts @@ -8,3 +8,4 @@ export * from './indexer'; export * from './migration'; export * from './db-type'; export * from './rollback-manager'; +export * from './split-db.provider'; diff --git a/src/core/database/query/match-project-based-props.ts b/src/core/database/query/match-project-based-props.ts index 6a40b0d495..6e36bd0abd 100644 --- a/src/core/database/query/match-project-based-props.ts +++ b/src/core/database/query/match-project-based-props.ts @@ -6,7 +6,7 @@ import { GlobalScopedRole, ScopedRole, } from '../../../components/authorization'; -import { ProjectType } from '../../../components/project/dto/type.enum'; +import { ProjectType } from '../../../components/project/dto/project-type.enum'; import { apoc, coalesce, diff --git a/src/core/database/split-db.provider.ts b/src/core/database/split-db.provider.ts new file mode 100644 index 0000000000..11fc0a0ceb --- /dev/null +++ b/src/core/database/split-db.provider.ts @@ -0,0 +1,17 @@ +import type { Provider, Type } from '@nestjs/common'; +import { ModuleRef } from '@nestjs/core'; +import type { PublicOf } from '~/common'; +import { ConfigService } from '../config/config.service'; + +export const splitDb = ( + neo4jRepository: Type, + edgeDbRepository: Type>, +): Provider => ({ + provide: neo4jRepository, + inject: [ModuleRef, ConfigService], + useFactory: async (moduleRef: ModuleRef, config: ConfigService) => { + const cls = + config.databaseEngine === 'edgedb' ? edgeDbRepository : neo4jRepository; + return await moduleRef.create(cls); + }, +}); diff --git a/src/core/index.ts b/src/core/index.ts index fe51077ec2..0763b72f2b 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -5,7 +5,6 @@ export * from './core.module'; export * from './cache'; export * from './graphql'; export * from './database'; -export * from './postgres'; export * from './events'; export * from './resources'; export * from './data-loader'; diff --git a/src/core/postgres/index.ts b/src/core/postgres/index.ts deleted file mode 100644 index 1929d89d23..0000000000 --- a/src/core/postgres/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './pg.service'; -export * from './split-db.provider'; diff --git a/src/core/postgres/pg.service.ts b/src/core/postgres/pg.service.ts deleted file mode 100644 index a0cd9c7bed..0000000000 --- a/src/core/postgres/pg.service.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { Inject, Injectable } from '@nestjs/common'; -import { AsyncLocalStorage } from 'async_hooks'; -import { dropRightWhile } from 'lodash'; -import pg, { - type ClientBase, - type PoolClient, - type Pool as PoolType, -} from 'pg'; -import { TracingService } from '../tracing'; - -const { Client, DatabaseError, Pool } = pg; - -@Injectable() -export class Pg { - constructor( - @Inject(Pool) private readonly pool: PoolType, - private readonly tracing: TracingService, - ) {} - - /** - * Holds the lazy client for the transaction within this async scope. - */ - private readonly clientStore = new AsyncLocalStorage< - () => Promise - >(); - - async query( - queryText: string, - values?: unknown[], - ): Promise { - // Grab transaction client creator & initialize it if needed. - const txClient = await this.clientStore.getStore()?.(); - // Otherwise, just use implicit client from pool - const client = txClient ?? this.pool; - - try { - // Hack to get the callee name, to identify the tracing segment. - const stack = new Error('').stack!.split('\n').slice(2); - const frame = stack[0] - ? /at (?:async )?(.+) \(/.exec(stack[0]) - : undefined; - const calleeName = - frame?.[1].replace(/^Pg/, '').replace(/Repository\./, '.') ?? 'Query'; - - return await this.tracing.capture(calleeName, async (sub) => { - // Show this segment separately in service map - sub.namespace = 'remote'; - // Help ID the segment as being for a database - sub.sql = {}; - - const result = await client.query(queryText, values); - return result.rows; - }); - } catch (e) { - if (e instanceof DatabaseError) { - // Stacktrace will always be relating to received remote data, - // completely unrelated to the callee of this method. - // Replace it with callee of this method, so it's actually tied - // to the code defining the query being executed. - e.stack = [ - ...dropRightWhile(e.stack!.split('\n'), (line) => - line.startsWith(' at'), - ), - ...new Error('').stack!.split('\n').slice(2), - ].join('\n'); - } - throw e; - } - } - - /** - * Prefer {@link PgTransaction @PgTransaction()} decorator to this explicit method. - * - * Run given function inside a transaction. - * - * If called inside another transaction, this will re-use that transaction, - * NOT make another one. - * - * Client is lazily acquired and tracked for you, - * all you have to do is call {@link query}. - * - * BEGIN/COMMIT commands are sent automatically before and after given function. - * ABORT is sent automatically when an exception is thrown, so be sure to - * not swallow errors inside this function call. - */ - async inTx(run: () => Promise): Promise { - if (this.clientStore.getStore()) { - // Already have a bound client, this is noop. - return await run(); - } - - // Create function to lazily acquire client once. - let client: PoolClient | null = null; - const getClient = async () => { - if (!client) { - client = await this.pool.connect(); - await client.query('BEGIN'); - } - return client; - }; - // TS has a false positive here, re-enforce it's possible to not be null. - client = client as PoolClient | null; - - try { - // Run given function bound to this lazy client - const result = await this.clientStore.run(getClient, run); - await client?.query('COMMIT'); - return result; - } catch (e) { - await client?.query('ROLLBACK'); - throw e; - } finally { - client?.release(); - } - } - - escapeIdentifier(str: string): string { - return Client.prototype.escapeIdentifier(str); - } - escapeLiteral(str: string): string { - return Client.prototype.escapeLiteral(str); - } -} diff --git a/src/core/postgres/postgres.module.ts b/src/core/postgres/postgres.module.ts deleted file mode 100644 index 89f38a34ca..0000000000 --- a/src/core/postgres/postgres.module.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { Inject, Module, OnModuleDestroy, OnModuleInit } from '@nestjs/common'; -import { DateTime, Duration } from 'luxon'; -import pg, { PoolConfig, type Pool as PoolType } from 'pg'; -import { builtins as TypeId } from 'pg-types'; -import { CalendarDate } from '../../common'; -import { ConfigService } from '../config/config.service'; -import { ILogger, LoggerToken } from '../logger'; -import { Pg } from './pg.service'; - -const { Pool, types } = pg; - -@Module({ - exports: [Pg], - providers: [ - { - provide: Pool, - useFactory(config: ConfigService, logger: ILogger) { - const pool = new Pool({ - ...(config.postgres as PoolConfig), // typecast to undo deep readonly - log: (message, err) => { - if (err instanceof Error) { - logger.error(message, { exception: err }); - } else { - logger.debug(message); - } - }, - }); - - pool.on('connect', (client) => { - void client - .query('SET DATESTYLE = iso; SET intervalstyle = iso_8601') - .then(() => logger.debug('set temporal styles')); - }); - - return pool; - }, - inject: [ConfigService, LoggerToken('postgres:driver')], - }, - Pg, - ], -}) -export class PostgresModule implements OnModuleInit, OnModuleDestroy { - constructor( - @Inject(Pool) private readonly pool: PoolType, - private readonly pg: Pg, - ) {} - - async onModuleInit() { - const dateParser = (inner: (d: string) => any) => (val: any) => { - if (val == null) { - return null; - } - if (val === 'infinity') { - return Infinity; - } - if (val === '-infinity') { - return -Infinity; - } - return inner(val); - }; - types.setTypeParser(TypeId.DATE, dateParser(CalendarDate.fromSQL)); - types.setTypeParser(TypeId.TIMESTAMP, dateParser(DateTime.fromSQL)); - types.setTypeParser(TypeId.TIMESTAMPTZ, dateParser(DateTime.fromSQL)); - types.setTypeParser(TypeId.TIMETZ, dateParser(DateTime.fromSQL)); - - types.setTypeParser(TypeId.INTERVAL, (val) => - val == null ? val : Duration.fromISO(val), - ); - } - - async onModuleDestroy() { - await this.pool.end(); - // @ts-expect-error I don't want this in the public API. - // This is easier than DI or private/public implementation/interface split. - this.pg.clientStore.disable(); - } -} diff --git a/src/core/postgres/split-db.provider.ts b/src/core/postgres/split-db.provider.ts deleted file mode 100644 index 53a3b4ec7e..0000000000 --- a/src/core/postgres/split-db.provider.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Provider, Type } from '@nestjs/common'; -import { ModuleRef } from '@nestjs/core'; -import type { PublicOf } from '../../common'; -import { ConfigService } from '../config/config.service'; - -export const splitDb = (neo: Type, pg: Type>): Provider => ({ - provide: neo, - useFactory: (config: ConfigService, moduleRef: ModuleRef) => - moduleRef.create(config.usePostgres ? pg : neo), - inject: [ConfigService, ModuleRef], -}); diff --git a/src/core/postgres/sql/change-scripts/admin.v1.sql b/src/core/postgres/sql/change-scripts/admin.v1.sql deleted file mode 100644 index e2ef919bfa..0000000000 --- a/src/core/postgres/sql/change-scripts/admin.v1.sql +++ /dev/null @@ -1,461 +0,0 @@ -create schema if not exists admin; -create schema if not exists common; - -set schema 'common'; - -CREATE EXTENSION if not exists hstore; -create extension if not exists postgis; - -CREATE EXTENSION IF NOT EXISTS pgcrypto; - -CREATE OR REPLACE FUNCTION nanoid(size int DEFAULT 11) -RETURNS text AS $$ -DECLARE - id text := ''; - i int := 0; - urlAlphabet char(64) := 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'; - bytes bytea := common.gen_random_bytes(size); - byte int; - pos int; -BEGIN - WHILE i < size LOOP - byte := get_byte(bytes, i); - pos := (byte & 63) + 1; -- + 1 because substr starts at 1 for some reason - id := id || substr(urlAlphabet, pos, 1); - i = i + 1; - END LOOP; - RETURN id; -END -$$ LANGUAGE PLPGSQL STABLE; - -create type admin.history_event_type as enum ( - 'INSERT', - 'UPDATE', - 'DELETE' -); - -create type common.sensitivity as enum ( - 'Low', - 'Medium', - 'High' -); - -create type admin.access_level as enum ( - 'Read', - 'Write' -); - -create table common_sensitivity_enum ( - value varchar(32) primary key -); - -insert into common_sensitivity_enum(value) values('Low'), ('Medium'), ('High'); - -create table admin_access_level_enum( - value varchar(32) primary key -); - -insert into admin_access_level_enum(value) values('Read'), ('Write'); - -create table admin_table_name_enum ( - value varchar(64) primary key -); - -create type admin.table_name as enum ( - 'admin.database_version_control', - 'admin.email_tokens', - 'admin.group_memberships', - 'admin.group_row_access', - 'admin.groups', - 'admin.peers', - 'admin.people', - 'admin.role_column_grants', - 'admin.role_memberships', - 'admin.role_table_permissions', - 'admin.roles', - 'admin.tokens', - 'admin.users', - - 'common.blogs', - 'common.blog_posts', - 'common.cell_channels', - 'common.coalition_memberships', - 'common.coalitions', - 'common.directories', - 'common.discussion_channels', - 'common.education_by_person', - 'common.education_entries', - 'common.file_versions', - 'common.files', - 'common.languages', - 'common.locations', - 'common.notes', - 'common.organizations', - 'common.org_chart_positions', - 'common.org_chart_position_graph', - 'common.people_graph', - 'common.people_to_org_relationships', - 'common.posts', - 'up.prayer_requests', - 'up.prayer_notifications', - 'common.scripture_references', - 'common.site_text_strings', - 'common.site_text_translations', - 'common.stage_graph', - 'common.stage_notifications', - 'common.stage_role_column_grants', - 'common.stages', - 'common.threads', - 'common.ticket_assignments', - 'common.ticket_feedback', - 'common.ticket_graph', - 'common.tickets', - 'common.work_estimates', - 'common.work_records', - 'common.workflows', - - 'sil.country_codes', - 'sil.language_codes', - 'sil.language_index', - 'sil.iso_639_3', - 'sil.iso_639_3_names', - 'sil.iso_639_3_macrolanguages', - 'sil.iso_639_3_retirements', - 'sil.table_of_countries', - 'sil.table_of_languages', - 'sil.table_of_languages_in_country', - - 'sc.budget_records', - 'sc.budget_records_partnerships', - 'sc.budgets', - 'sc.ceremonies', - 'sc.change_to_plans', - 'sc.ethno_arts', - 'sc.ethnologue', - 'sc.field_regions', - 'sc.field_zones', - 'sc.file_versions', - 'sc.films', - 'sc.funding_accounts', - 'sc.global_partner_assessments', - 'sc.global_partner_engagements', - 'sc.global_partner_engagement_people', - 'sc.global_partner_performance', - 'sc.global_partner_transitions', - 'sc.internship_engagements', - 'sc.known_languages_by_person', - 'sc.language_engagements', - 'sc.language_goal_definitions', -- not finished - 'sc.language_goals', -- not finished - 'sc.language_locations', -- not finished - 'sc.languages', - 'sc.locations', - 'sc.organization_locations', - 'sc.organizations', - 'sc.partners', - 'sc.partnerships', - 'sc.people', - 'sc.periodic_reports', - 'sc.periodic_reports_directory', - 'sc.person_unavailabilities', - 'sc.pinned_projects', - 'sc.posts', - 'sc.posts_directory', - 'sc.product_scripture_references', - 'sc.products', - 'sc.project_locations', - 'sc.project_members', - 'sc.projects', - 'sc.stories' - -); - --- VERSION CONTROL --------------------------------------------------- - -create type admin.db_vc_status as enum ( - 'In Progress', - 'Completed', - 'Abandoned' -); - -create table admin.database_version_control ( - id varchar(32) primary key default common.nanoid(), - version int not null, - status admin.db_vc_status default 'In Progress', - started timestamp not null default CURRENT_TIMESTAMP, - completed timestamp -); - --- PEOPLE ------------------------------------------------------------ - -create table admin.people ( - id varchar(32) primary key default common.nanoid(), - - about text, - picture_common_files_id varchar(32), -- references common.files(id) add an alter statement after common schema loads - private_first_name varchar(32), - private_last_name varchar(32), - public_first_name varchar(32), - public_last_name varchar(32), - primary_location_common_locations_id varchar(32), -- references common.locations(id), add an alter statement after common schema loads - sensitivity_clearance common.sensitivity default 'Low', - timezone varchar(64), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32), -- not null doesn't work here, on startup - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32), -- not null doesn't work here, on startup - owning_person_admin_people_id varchar(32), -- not null doesn't work here, on startup - owning_group_admin_groups_id varchar(32) -- not null doesn't work here, on startup -); - -alter table admin.people add constraint admin_people_created_by_people_id_fk foreign key (created_by_admin_people_id) references admin.people(id); -alter table admin.people add constraint admin_people_modified_by_people_id_fk foreign key (modified_by_admin_people_id) references admin.people(id); -alter table admin.people add constraint admin_people_owning_person_people_id_fk foreign key (owning_person_admin_people_id) references admin.people(id); - --- GROUPS -------------------------------------------------------------------- - -create table admin.groups( - id varchar(32) primary key default common.nanoid(), - - name varchar(64) not null, - parent_group_row_access_admin_groups_id varchar(32) references admin.groups(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) references admin.groups(id), -- not null doesn't work here, on startup - - unique (name, owning_group_admin_groups_id) -); - -alter table admin.people add constraint admin_people_owning_group_groups_id_fk foreign key (owning_group_admin_groups_id) references admin.groups(id); - -create table admin.group_row_access( - id varchar(32) primary key default common.nanoid(), - - admin_groups_id varchar(32) not null references admin.groups(id), - admin_table_name_enum_value varchar(64) not null references admin_table_name_enum(value), - row_id varchar(32) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_groups_id, admin_table_name_enum_value, row_id) -); - -create table admin.group_memberships( - id varchar(32) primary key default common.nanoid(), - - admin_groups_id varchar(32) not null references admin.groups(id), - admin_people_id varchar(32) not null references admin.people(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_groups_id, admin_people_id) -); - -create table admin.organization_administrators( - id varchar(32) primary key default nanoid(), - - admin_groups_id varchar(32) not null references admin.groups(id), - admin_people_id varchar(32) not null references admin.people(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_groups_id, admin_people_id) -); - --- ROLES -------------------------------------------------------------------- - -create table admin.roles ( - id varchar(32) primary key default common.nanoid(), - - name varchar(255) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (name, owning_group_admin_groups_id) -); - -create table admin.role_column_grants( - id varchar(32) primary key default common.nanoid(), - - admin_role_id varchar(32) not null references admin.roles(id), - admin_table_name_enum_value varchar(64) not null references admin_table_name_enum(value), - column_name varchar(64) not null, - access_level admin.access_level not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_role_id, admin_table_name_enum_value, column_name) -); - -create type admin.table_permission_grant_type as enum ( - 'Create', - 'Delete' -); - -create table admin.role_table_permissions( - id varchar(32) primary key default common.nanoid(), - - admin_role_id varchar(32) not null references admin.roles(id), - admin_table_name_enum_value varchar(64) not null references admin_table_name_enum(value), - table_permission admin.table_permission_grant_type not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_role_id, admin_table_name_enum_value, table_permission) -); - -create table admin.role_memberships ( - id varchar(32) primary key default common.nanoid(), - - admin_role_id varchar(32) not null references admin.roles(id), - admin_people_id varchar(32) unique not null references admin.people(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique(admin_role_id, admin_people_id) -); - -create table admin.role_all_data_column_grants( - id varchar(32) primary key default nanoid(), - - admin_roles_id varchar(32) not null references admin.roles(id), - admin_table_name_enum_value varchar(64) not null references admin_table_name_enum(value), - column_name varchar(64) not null, - access_level admin.access_level not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_roles_id, admin_table_name_enum_value, column_name) -); - --- USERS --------------------------------------------------------------------- - -create table admin.user_email_accounts( - id varchar(32) primary key references admin.people(id), -- not null added in v2 - - email varchar(255), -- unique not null - password varchar(255), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table admin.user_phone_accounts( - id varchar(32) primary key references admin.people(id), -- not null added in v2 - - phone varchar(64) unique, - password varchar(255), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- AUTHENTICATION ------------------------------------------------------------ - -create table if not exists admin.tokens ( - id varchar(32) primary key default common.nanoid(), - token varchar(512) unique not null, - admin_people_id varchar(32) references admin.people(id), - created_at timestamp not null default CURRENT_TIMESTAMP -); - --- email tokens - -create table admin.email_tokens ( - id varchar(32) primary key default common.nanoid(), - token varchar(512) unique not null, - admin_user_id varchar(32) not null references admin.user_email_accounts(id), - created_at timestamp not null default CURRENT_TIMESTAMP -); - --- PEER to PEER ------------------------------------------------------------- - --- not used right now -create table admin.peers ( - id varchar(32) primary key default common.nanoid(), - - admin_people_id varchar(32) unique unique not null references admin.people(id), - url varchar(128) unique not null, - peer_approved bool not null default false, - url_confirmed bool not null default false, - source_token varchar(64) unique, - target_token varchar(64) unique, - session_token varchar(64) unique, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -insert into admin_table_name_enum(value) values - ('admin_database_version_control'), - ('admin_email_tokens'), - ('admin_group_memberships'), - ('admin_group_row_access'), - ('admin_groups'), - ('admin_organization_administrators'), - ('admin_peers'), - ('admin_people'), - ('admin_role_all_data_column_grants'), - ('admin_role_column_grants'), - ('admin_role_memberships'), - ('admin_role_table_permissions'), - ('admin_roles'), - ('admin_tokens'), - ('admin_users'); diff --git a/src/core/postgres/sql/change-scripts/admin.v2.sql b/src/core/postgres/sql/change-scripts/admin.v2.sql deleted file mode 100644 index 8a92168564..0000000000 --- a/src/core/postgres/sql/change-scripts/admin.v2.sql +++ /dev/null @@ -1 +0,0 @@ -alter table admin.users alter column email set not null; diff --git a/src/core/postgres/sql/change-scripts/bootstrap.data.sql b/src/core/postgres/sql/change-scripts/bootstrap.data.sql deleted file mode 100755 index 46db9800e2..0000000000 --- a/src/core/postgres/sql/change-scripts/bootstrap.data.sql +++ /dev/null @@ -1,100 +0,0 @@ -CREATE OR REPLACE PROCEDURE bootstrap( - IN p_email VARCHAR(255), - IN p_password VARCHAR(50), - inout error_type varchar(32) -) -LANGUAGE PLPGSQL -AS $$ -DECLARE - vPeopleCount int; -- if this is a fresh db or not - vPersonId varchar(32); - vOrgId varchar(32); - vAdminRoleId varchar(32); - vAdminGroupId varchar(32); - vNonAdminPersonId varchar(32); - vPublicPersonId varchar(32); - vPublicGroupId varchar(32); - vPublicRoleId varchar(32); - vTableOfLanguagesId varchar(32); - vCommonLanguagesId varchar(32); - vCommonSiteTextStringsId varchar(32); -BEGIN - select count(id) - from admin.people - into vPeopleCount; - - if vPeopleCount = 0 then - -- people -------------------------------------------------------------------------------- - - -- Root user - insert into admin.people(sensitivity_clearance) - values ('High') - returning id - into vPersonId; - - -- public user - insert into admin.people(sensitivity_clearance) - values ('Low') - returning id - into vPublicPersonId; - - -- create token for the public 'person' - insert into admin.tokens(token, admin_people_id) values ('public', vPublicPersonId); - - -- groups ------------------------------------------------------------------------------------- - - -- Administrators Group - insert into admin.groups(name, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id) - values ('Administrators', vPersonId, vPersonId, vPersonId) - returning id - into vAdminGroupId; - - -- Public Group - insert into admin.groups(name, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id) - values ('Public', vPersonId, vPersonId, vPersonId) - returning id - into vPublicGroupId; - - -- organization ------------------------------------------------------------------------------------------ - - -- Seed Company - insert into common.organizations(name, sensitivity, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id, owning_group_admin_groups_id) - values ('Seed Company', 'Low', vPersonId, vPersonId, vPersonId, vAdminGroupId) - returning id - into vOrgId; - - -- users ---------------------------------------------------------------------------------------------------- - - -- Root user - insert into admin.user_email_accounts(id, email, password, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id, owning_group_admin_groups_id) - values (vPersonId, p_email, p_password, vPersonId, vPersonId, vPersonId, vAdminGroupId); - - -- global roles ---------------------------------------------------------------------------------------------------- - - -- Administrator role - insert into admin.roles(name, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id, owning_group_admin_groups_id) - values ('Administrator', vPersonId, vPersonId, vPersonId, vAdminGroupId) - returning id - into vAdminRoleId; - - -- Public role - insert into admin.roles(name, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id, owning_group_admin_groups_id) - values ('Public', vPersonId, vPersonId, vPersonId, vAdminGroupId) - returning id - into vPublicRoleId; - - -- global role memberships ------------------------------------------------------------------------------------------ - - -- Give Root user the Administrator role - insert into admin.role_memberships(admin_role_id, admin_people_id, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id, owning_group_admin_groups_id) values - (vAdminRoleId, vPersonId, vPersonId, vPersonId, vPersonId, vAdminGroupId); - - -- role table grants ------------------------------------------------------------------------------------------ - - -- group memberships ---------------------------------------------------------------------------------------------------- - insert into admin.group_memberships(admin_groups_id, admin_people_id, created_by_admin_people_id, modified_by_admin_people_id, owning_person_admin_people_id, owning_group_admin_groups_id) - values (vAdminGroupId, vPersonId, vPersonId, vPersonId, vPersonId, vAdminGroupId); - - end if; - -END; $$; diff --git a/src/core/postgres/sql/change-scripts/common.v1.sql b/src/core/postgres/sql/change-scripts/common.v1.sql deleted file mode 100644 index c6a0142e70..0000000000 --- a/src/core/postgres/sql/change-scripts/common.v1.sql +++ /dev/null @@ -1,964 +0,0 @@ --- common schema. common_organizations_id specific schema should go in an common_organizations_id-specific file. - --- ENUMS ---- - -create type common.mime_type as enum ( - 'application/msword', - 'application/pdf', - 'application/postscript', - 'application/rtf', - 'application/vnd.ms-excel', - 'application/vnd.ms-excel.sheet.macroenabled.12', - 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - 'application/vnd.ms-outlook', - 'application/octet-stream', - 'application/vnd.ms-powerpoint', - 'application/vnd.ms-project', - 'application/vnd.oasis.opendocument.chart', - 'application/vnd.oasis.opendocument.chart-template', - 'application/vnd.oasis.opendocument.database', - 'application/vnd.oasis.opendocument.graphics', - 'application/vnd.oasis.opendocument.graphics-template', - 'application/vnd.oasis.opendocument.image', - 'application/vnd.oasis.opendocument.image-template', - 'application/vnd.oasis.opendocument.presentation', - 'application/vnd.oasis.opendocument.presentation-template', - 'application/vnd.oasis.opendocument.spreadsheet', - 'application/vnd.oasis.opendocument.spreadsheet-template', - 'application/vnd.oasis.opendocument.text', - 'application/vnd.oasis.opendocument.text-master', - 'application/vnd.oasis.opendocument.text-template', - 'application/vnd.oasis.opendocument.text-web', - --- This is a temporal fix for application/vnd.openxmlformats-officedocument mime types --- Since Postgres only accepts up to 63 byte chars for labels --- 'app/vnd.openxmlformats-officedocument.presentationml.presentation', - 'app/vnd.openxmlformats-officedocument.presentationml.slide', - 'app/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'app/vnd.openxmlformats-officedocument.presentationml.template', - 'app/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'app/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'app/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'app/vnd.openxmlformats-officedocument.wordprocessingml.template', - - - 'application/vnd.visio', - 'application/vnd.wordperfect', - 'application/x-font-ghostscript', - 'application/x-font-linux-psf', - 'application/x-font-pcf', - 'application/x-font-snf', - 'application/x-font-type1', - 'application/x-gtar', - 'application/x-iso9660-image', - 'application/x-ms-wmd', - 'application/x-msaccess', - 'application/x-mspublisher', - 'application/x-mswrite', - 'application/x-tar', - 'application/x-tex', - 'application/x-tex-tfm', - 'application/x-texinfo', - 'application/x-zip-compressed', - 'application/zip', - 'audio/adpcm', - 'audio/basic', - 'audio/midi', - 'audio/mp4', - 'audio/mpeg', - 'audio/ogg', - 'audio/s3m', - 'audio/silk', - 'audio/vnd.rip', - 'audio/webm', - 'audio/x-aac', - 'audio/x-aiff', - 'audio/x-caf', - 'audio/x-flac', - 'audio/x-matroska', - 'audio/x-mpegurl', - 'audio/x-ms-wax', - 'audio/x-ms-wma', - 'audio/xpn-realaudio', - 'audio/x-wav', - 'audio/xm', - 'font/otf', - 'font/ttf', - 'font/woff', - 'font/woff2', - 'image/bmp', - 'image/cgm', - 'image/g3fax', - 'image/gif', - 'image/ief', - 'image/jpeg', - 'image/ktx', - 'image/png', - 'image/sgi', - 'image/svg+xml', - 'image/tiff', - 'image/vnd.adobe.photoshop', - 'image/vnd.dwg', - 'image/vnd.dxf', - 'image/x-3ds', - 'image/x-cmu-raster', - 'image/x-cmx', - 'image/x-freehand', - 'image/x-icon', - 'image/x-mrsid-image', - 'image/x-pcx', - 'image/x-pict', - 'image/x-portable-anymap', - 'image/x-portable-bitmap', - 'image/x-portable-graymap', - 'image/x-portable-pixmap', - 'image/x-rgb', - 'image/x-tga', - 'image/x-xbitmap', - 'image/x-xpixmap', - 'image/xwindowdump', - 'message/rfc822', - 'text/calendar', - 'text/css', - 'text/csv', - 'text/html', - 'text/plain', - 'text/richtext', - 'text/rtf', - 'text/sgml', - 'text/tab-separated-values', - 'video/3gpp', - 'video/3gp2', - 'video/h261', - 'video/h263', - 'video/h264', - 'video/jpeg', - 'video/jpm', - 'video/mj2', - 'video/mp4', - 'video/mpeg', - 'video/ogg', - 'video/quicktime', - 'video/vnd.mpegurl', - 'video/vnd.vivo', - 'video/webm', - 'video/x-f4v', - 'video/x-fli', - 'video/x-flv', - 'video/x-m4v', - 'video/x-matroska', - 'video/x-mng', - 'video/x-ms-asf', - 'video/x-ms-vob', - 'video/x-ms-wm', - 'video/x-ms-wmv', - 'video/x-ms-wmx', - 'video/x-ms-wvx', - 'video/x-msvideo', - 'video/x-sgi-movie', - 'video/x-smv' -); - --- FILES & DIRECTORIES ---------------------------------------------------------- - --- todo research cascading deletes -create table common.directories ( - id varchar(32) primary key default common.nanoid(), - - parent_common_directories_id varchar(32) references common.directories(id), - name varchar(255), -- not null - - -- todo add triggers for derived data - -- size - -- total files (not directories or versions) - -- id of first file created - -- modified at/by of most recent file version added in any dir/sub - -- add derived data from sub-directories/files - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.files ( - id varchar(32) primary key default common.nanoid(), - - parent_common_directories_id varchar(32) references common.directories(id), --not null - name varchar(255), -- not null - - -- todo, derived data - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.file_versions ( - id varchar(32) primary key default common.nanoid(), - - mime_type varchar(255), -- not null - name varchar(255), -- not null, - parent_common_files_id varchar(32) references common.files(id), -- not null - file_url varchar(255), -- not null, - file_size int, -- bytes - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- SITE TEXT -------------------------------------------------------------------------------- - -create type common.egids_scale as enum ( - '0', - '1', - '2', - '3', - '4', - '5', - '6a', - '6b', - '7', - '8a', - '8b', - '9', - '10' -); - --- meant to be extended by all orgs, so everyone has a globally unique id to reference within their language_common_languages_id lists -create table common.languages( - id varchar(32) primary key default common.nanoid(), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.site_text_strings( - id varchar(32) primary key default common.nanoid(), - - -- US English, all translations including other English locales will be in the translation table - english varchar(64), -- unique not null - comment text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.site_text_translations( - id varchar(32) primary key default common.nanoid(), - - language_common_languages_id varchar(32) not null references common.languages(id), - site_text_common_site_text_strings_id varchar(32) not null references common.site_text_strings(id) on delete cascade, - translation varchar(64) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (language_common_languages_id, site_text_common_site_text_strings_id) -); - --- SCRIPTURE REFERENCE ----------------------------------------------------------------- - --- todo -create type common.book_name as enum ( - 'Genesis', - 'Exodus', - 'Leviticus', - 'Numbers', - 'Deuteronomy', - 'Joshua', - 'Judges', - 'Ruth', - '1 Samuel', - '2 Samuel', - '1 Kings', - '2 Kings', - '1 Chronicles', - '2 Chronicles', - 'Ezra', - 'Nehemiah', - 'Esther', - 'Job', - 'Psalms', - 'Proverbs', - 'Ecclesiastes', - 'The Song of Solomon', - 'Isaiah', - 'Jeremiah', - 'Lamentations', - 'Ezekiel', - 'Daniel', - 'Hosea', - 'Joel', - 'Amos', - 'Obadiah', - 'Jonah', - 'Micah', - 'Nahum', - 'Habakkuk', - 'Zephaniah', - 'Haggai', - 'Zechariah', - 'Malachi', - 'Matthew', - 'Mark', - 'Luke', - 'John', - 'Acts', - 'Romans', - '1 Corinthians', - '2 Corinthians', - 'Galatians', - 'Ephesians', - 'Philippians', - 'Colossians', - '1 Thessalonians', - '2 Thessalonians', - '1 Timothy', - '2 Timothy', - 'Titus', - 'Philemon', - 'Hebrews', - 'James', - '1 Peter', - '2 Peter', - '1 John', - '2 John', - '3 John', - 'Jude', - 'Revelation' -); - -create table common.scripture_references ( - id varchar(32) primary key default common.nanoid(), - - start_verse int, -- absolute verse - end_verse int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- CHAT ------------------------------------------------------------ - -create table common.discussion_channels ( - id varchar(32) primary key default common.nanoid(), - - name varchar(32) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - unique (name, owning_group_admin_groups_id) -); - -create table common.cell_channels ( - id varchar(32) primary key default common.nanoid(), - - table_name admin.table_name not null, - column_name varchar(64) not null, - row varchar(32) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (table_name, column_name, row) -); - -create table common.threads ( - id varchar(32) primary key default common.nanoid(), - - channel_common_discussion_channels_id varchar(32) not null references common.discussion_channels(id) on delete cascade, - content text not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.posts ( - id varchar(32) primary key default common.nanoid(), - thread_common_threads_id varchar(32) not null references common.threads(id) on delete cascade, - content text not null, - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- BLOGS --------------- - -create table common.blogs ( - id varchar(32) primary key default common.nanoid(), - - title varchar(64) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (title, owning_group_admin_groups_id) -); - -create table common.blog_posts ( - id varchar(32) primary key default common.nanoid(), - - blog_common_blogs_id varchar(32) not null references common.blogs(id), - content text not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- NOTES ---------------------------------------------------- - -create table common.notes ( - id varchar(32) primary key default common.nanoid(), - - table_name admin.table_name not null, - column_name varchar(64) not null, - row varchar(32) not null, - content text not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- common_locations_id ----------------------------------------------------------------- - -create type common.location_type as enum ( - 'City', - 'County', - 'State', - 'Country', - 'CrossBorderArea' -); - -create table common.locations ( - id varchar(32) primary key default common.nanoid(), - - iso_3166_alpha_3 char(3), -- unique, todo research this column - name varchar(255) unique, -- not null, - sensitivity common.sensitivity not null default 'High', -- todo research the need for this - type common.location_type, -- not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -ALTER TABLE admin.people ADD CONSTRAINT common_people_primary_location_fk foreign key (primary_location_common_locations_id) references common.locations(id); -ALTER TABLE common.locations ADD CONSTRAINT common_locations_created_by_fk foreign key (created_by_admin_people_id) references admin.people(id); -ALTER TABLE common.locations ADD CONSTRAINT common_locations_modified_by_fk foreign key (modified_by_admin_people_id) references admin.people(id); - -create table common.language_locations ( - id varchar(32) primary key default common.nanoid(), - - common_languages_id varchar(32) not null references common.languages(id), - common_locations_id varchar(32) not null references common.locations(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (common_languages_id, common_locations_id) -); --- education_common_education_entries_id - -create type common.education_degree as enum ( - 'Primary', - 'Secondary', - 'Associates', - 'Bachelors', - 'Masters', - 'Doctorate' -); - -create table common.education_entries ( - id varchar(32) primary key default common.nanoid(), - - degree common.education_degree, - institution varchar(64), - major varchar(64), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) - - -- unique (degree, institution, major) -); - -create table common.education_by_person ( - id varchar(32) primary key default common.nanoid(), - - admin_people_id varchar(32) unique not null references admin.people(id), - education_common_education_entries_id varchar(32) not null references common.education_entries(id), - graduation_year int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_people_id, education_common_education_entries_id) -); - --- ORGANIZATIONS ------------------------------------------------------------ - -create table common.organizations ( - id varchar(32) primary key default common.nanoid(), - - name varchar(255), -- unique not null - sensitivity common.sensitivity default 'High', - primary_location_common_locations_id varchar(32) references common.locations(id), - street_address varchar(255), - city varchar(255), - state varchar(32), - nation varchar(32), - root_directory_common_directories_id varchar(32) references common.directories(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.organization_locations( - id varchar(32) primary key default common.nanoid(), - - organization_common_organizations_id varchar(32) not null references common.organizations(id), - location_common_locations_id varchar(32) not null references common.locations(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (organization_common_organizations_id, location_common_locations_id) -); - -create table common.org_chart_positions( - id varchar(32) primary key default common.nanoid(), - - common_organizations_id varchar(32) not null references common.organizations(id), - name varchar(64) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (common_organizations_id, name) -); - -create type common.position_relationship_types as enum ( - 'Reports To', - 'Works With' -); - -create table common.org_chart_position_graph( - id varchar(32) primary key default common.nanoid(), - - from_position_common_org_chart_positions_id varchar(32) not null references common.org_chart_positions(id), - to_position_common_org_chart_positions_id varchar(32) not null references common.org_chart_positions(id), - relationship_type common.position_relationship_types, - position_start date, - position_end date, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (from_position_common_org_chart_positions_id, to_position_common_org_chart_positions_id, relationship_type) -); - --- COALITIONS ---------------------------------------------------------- - -create type common.involvement_options as enum ( - 'CIT', - 'Engagements' -); - -create table common.coalitions( - id varchar(32) primary key default common.nanoid(), - - name varchar(64) unique not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- common_coalitions_id memberships - -create table common.coalition_memberships( - id varchar(32) primary key default common.nanoid(), - - common_coalitions_id varchar(32) not null references common.coalitions(id), - common_organizations_id varchar(32) not null references common.organizations(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (common_coalitions_id, common_organizations_id) -); - --- TICKETS ---------------------------------------------------------------------- - -create type common.ticket_status as enum ( - 'Open', - 'Blocked', - 'Closed' -); - -create table common.tickets ( - id varchar(32) primary key default common.nanoid(), - - title varchar(64) not null, - ticket_status common.ticket_status not null default 'Open', - parent varchar(32), - content text not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -ALTER TABLE common.tickets ADD CONSTRAINT common_tickets_parent_fk foreign key (parent) references common.tickets(id); - -create table common.ticket_graph ( - id varchar(32) primary key default common.nanoid(), - - from_ticket_common_tickets_id varchar(32) not null references common.tickets(id), - to_ticket_common_tickets_id varchar(32) not null references common.tickets(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.ticket_assignments ( - id varchar(32) primary key default common.nanoid(), - - common_tickets_id varchar(32) not null references common.tickets(id), - admin_people_id varchar(32) not null references admin.people(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.work_records( - id varchar(32) primary key default common.nanoid(), - - admin_people_id varchar(32) not null references admin.people(id), - common_tickets_id varchar(32) not null references common.tickets(id), - hours int not null, - minutes int default 0, - total_time decimal generated always as ( - hours + (minutes / 60) - ) stored, - comment text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.work_estimates( - id varchar(32) primary key default common.nanoid(), - common_tickets_id varchar(32) references common.tickets(id), - admin_people_id varchar(32) not null references admin.people(id), - hours int not null, - minutes int default 0, - total_time decimal generated always as ( - hours + (minutes / 60) - ) stored, - comment text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type common.ticket_feedback_options as enum ( - 'Satisfied', - 'Unsatisfied' -); - -create table common.ticket_feedback( - id varchar(32) primary key default common.nanoid(), - - common_tickets_id varchar(32) references common.tickets(id), - stakeholder varchar(32) not null references admin.people(id), - feedback common.ticket_feedback_options not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- WORKFLOW ----------------------------------------------------------------- - -create table common.workflows( - id varchar(32) primary key default common.nanoid(), - - title varchar(128) not null unique, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.stages( - id varchar(32) primary key default common.nanoid(), - - title varchar(128) not null unique, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table common.stage_graph( - id varchar(32) primary key default common.nanoid(), - - from_stage varchar(32) not null references common.stages(id), - to_stage varchar(32) not null references common.stages(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (from_stage, to_stage) -); - -create table common.stage_role_column_grants( - id varchar(32) primary key default common.nanoid(), - - common_stages_id varchar(32) not null references common.stages(id), - admin_role_id varchar(32) not null references admin.roles(id), - table_name admin.table_name not null, - column_name varchar(64) not null, - access_level admin.access_level not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_role_id, table_name, column_name) -); - -create table common.stage_notifications( - id varchar(32) primary key default common.nanoid(), - - common_stages_id varchar(32) not null references common.stages(id), - on_enter bool default false, - on_exit bool default false, - admin_people_id varchar(32) unique references admin.people(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- SOCIAL GRAPH ---------------------------------------------------- - -create type common.people_to_org_relationship_type as enum ( - 'Vendor', - 'Customer', - 'Investor', - 'Associate', - 'Employee', - 'Member', - 'Executive', - 'President/CEO', - 'Board of Directors', - 'Retired', - 'Other' -); - -create table common.people_to_org_relationships ( - id varchar(32) primary key default common.nanoid(), - - common_organizations_id varchar(32) not null references common.organizations(id), - admin_people_id varchar(32) unique not null references admin.people(id), - relationship_type common.people_to_org_relationship_type, - begin_at date, - end_at date, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type common.people_to_people_relationship_types as enum ( - 'Friend', - 'Colleague', - 'Other' -); - -create table common.people_graph ( - id varchar(32) primary key default common.nanoid(), - - from_admin_people_id varchar(32) unique not null references admin.people(id), - to_admin_people_id varchar(32) unique not null references admin.people(id), - rel_type common.people_to_people_relationship_types not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -insert into admin_table_name_enum(value) values - ('common_blogs'), - ('common_blog_posts'), - ('common_cell_channels'), - ('common_coalition_memberships'), - ('common_coalitions'), - ('common_directories'), - ('common_discussion_channels'), - ('common_education_by_person'), - ('common_education_entries'), - ('common_file_versions'), - ('common_files'), - ('common_languages'), - ('common_locations'), - ('common_notes'), - ('common_organizations'), - ('common_org_chart_positions'), - ('common_org_chart_position_graph'), - ('common_people_graph'), - ('common_people_to_org_relationships'), - ('common_posts'), - ('common_up.prayer_requests'), - ('common_up.prayer_notifications'), - ('common_scripture_references'), - ('common_site_text_strings'), - ('common_site_text_translations'), - ('common_stage_graph'), - ('common_stage_notifications'), - ('common_stage_role_column_grants'), - ('common_stages'), - ('common_threads'), - ('common_ticket_assignments'), - ('common_ticket_feedback'), - ('common_ticket_graph'), - ('common_tickets'), - ('common_work_estimates'), - ('common_work_records'), - ('common_workflows'); diff --git a/src/core/postgres/sql/change-scripts/common.v2.sql b/src/core/postgres/sql/change-scripts/common.v2.sql deleted file mode 100644 index d12e6dd205..0000000000 --- a/src/core/postgres/sql/change-scripts/common.v2.sql +++ /dev/null @@ -1,9 +0,0 @@ -alter table common.locations alter column name set not null; -alter table common.locations alter column type set not null; -alter table common.organizations alter column name set not null; -alter table common.files alter column common_directories_id set not null; -alter table common.files alter column name set not null; -alter table common.file_versions alter column name set not null; -alter table common.file_versions alter column mime_type set not null; -alter table common.file_versions alter column file set not null; -alter table common.file_versions alter column file_url set not null; diff --git a/src/core/postgres/sql/change-scripts/dummy.data.sql b/src/core/postgres/sql/change-scripts/dummy.data.sql deleted file mode 100755 index a3d90fa696..0000000000 --- a/src/core/postgres/sql/change-scripts/dummy.data.sql +++ /dev/null @@ -1,23 +0,0 @@ --- sc.languages ---insert into sc.languages(name, display_name,island, coordinates, owning_person,owning_group, created_by, modified_by) ---values ---('English', 'English', 'USA', 'SRID=4326;POINT(-96.1 32.7)', 1,1,1,1), ---('Spanish', 'Spanish', 'MEX', null, 1,1,1,1), ---('Hindi', 'Hindi', 'IND', null,1,1,1,1), ---('Kannada', 'Kannada', 'BLR','SRID=4326;POINT(77.5 12.9)', 1,1,1,1); - - -CREATE OR REPLACE PROCEDURE load_dummy_data() -LANGUAGE PLPGSQL -AS $$ -DECLARE - vEnglishEthId int; - vSpanishEthId int; - vHindiEthId int; - vKannadaEthId int; -BEGIN - -- todo - -END; $$; - -call load_dummy_data(); \ No newline at end of file diff --git a/src/core/postgres/sql/change-scripts/gis.sql b/src/core/postgres/sql/change-scripts/gis.sql deleted file mode 100644 index e3a34da284..0000000000 --- a/src/core/postgres/sql/change-scripts/gis.sql +++ /dev/null @@ -1,16 +0,0 @@ -create extension if not exists postgis; -alter table sc.languages add column if not exists coordinates:common.geography; -delete from sc.languages; -insert into sc.languages(id,name,display_name,owning_person,owning_group, created_by, modified_by, coordinates) -values -(1,'Kannada', 'KND', 1,1,1,1,'SRID=4326;POINT(77.5 12.9)'), -(2,'English', 'ENG',1,1,1,1, 'SRID=4326;POINT(-96.1 32.7)'); - - -select round(common.ST_Distance -( - (select coordinates from sc.languages where id = 1)::common.geography, - (select coordinates from sc.languages where id = 2)::common.geography -)/1000) || ' km' as distance; - -select common.ST_AsLatLonText(coordinates::text) from sc.languages; diff --git a/src/core/postgres/sql/change-scripts/history.sql b/src/core/postgres/sql/change-scripts/history.sql deleted file mode 100644 index 45dcf4d5c1..0000000000 --- a/src/core/postgres/sql/change-scripts/history.sql +++ /dev/null @@ -1,127 +0,0 @@ --- NOTE: using pg_catalog instead of information_schema might speed up the function --- NOTE: if function needs to be extended for multi-dimensional array datatypes for columns - https://stackoverflow.com/questions/39436189/how-to-get-the-dimensionality-of-an-array-column - --- CREATING HISTORY TABLES IDEMPOTENTLY -create or replace procedure admin.create_history_tables() -language plpgsql -as $$ -declare - rec1 record; - rec2 record; - history_table_name text; - status text; -begin - -- FINDING ALL TABLES THAT NEED A HISTORY AND LOOPING OVER THEM - for rec1 in (select table_schema, table_name - from information_schema.tables - where table_schema <> 'pg_catalog' - and table_schema <> 'information_schema' - and table_name not similar to '%(_peer|_history)' - order by table_name) loop - - history_table_name := rec1.table_name || '_history'; - raise info 'history_table_name: % ', history_table_name; - - -- HISTORY TABLE CREATION - execute format('create table if not exists %I.%I ( _history_id serial primary key, - _history_created_at timestamp not null default CURRENT_TIMESTAMP, __event admin.history_event_type)', rec1.table_schema,history_table_name); - - -- UPDATE BOTH SECURITY AND HISTORY TABLE (IDEMPOTENT MANNER) - for rec2 in (select column_name,case - when (data_type = 'USER-DEFINED') then udt_schema || '.' || udt_name - when (data_type = 'ARRAY') then udt_schema || '.' || substr(udt_name, 2, length(udt_name)-1) || '[]' - when (data_type = 'character') then udt_schema || '.' || udt_name || '(' || character_maximum_length || ')' - when (data_type = 'character varying') then udt_schema || '.' || udt_name || '(' || character_maximum_length || ')' - else data_type - end as data_type from information_schema.columns - where table_schema = rec1.table_schema and table_name = rec1.table_name) loop - raise info 'col-name: % | data-type: %', rec2.column_name, rec2.data_type; - - perform column_name from information_schema.columns where table_schema = rec1.table_schema - and table_name = history_table_name and column_name = rec2.column_name; - - if not found then - - raise info 'history table updated'; - execute format('alter table ' || rec1.table_schema || '.' || history_table_name || ' add column ' || rec2.column_name || ' ' || rec2.data_type); - - end if; - - end loop; - end loop; - raise info 'DONE'; -end; $$; - --- GENERIC HISTORY TRIGGER -create or replace function admin.history_trigger() -returns trigger -language plpgsql -as $$ -declare -base_table_name text; -history_table_name text; -history_row_id int; -rec1 record; -begin - base_table_name := TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME; - - history_table_name := base_table_name || '_history'; - execute format('insert into '|| history_table_name || '(_history_id, __event) values (default,' || quote_literal(TG_OP) ||') returning _history_id') into history_row_id; - for rec1 in (select column_name from information_schema.columns where table_schema = TG_TABLE_SCHEMA and table_name = TG_TABLE_NAME) loop - if TG_OP != 'DELETE' then - execute format('update '|| history_table_name || ' set ' || quote_ident(rec1.column_name) || ' = $1.' || quote_ident(rec1.column_name) ||' where _history_id = '|| history_row_id) using new ; - else - execute format('update '|| history_table_name || ' set ' || quote_ident(rec1.column_name) || ' = $1.' || quote_ident(rec1.column_name) ||' where _history_id = '|| history_row_id) using old; - end if; - end loop; - return new; -end; $$; - --- CREATING HISTORY TRIGGERS FOR ALL BASE TABLES THAT NEED THEM -create or replace procedure admin.create_history_triggers() -language plpgsql -as $$ -declare -insert_trigger text; -update_trigger text; -delete_trigger text; -base_table_name text; -rec1 record; -begin - - for rec1 in (select table_schema, table_name - from information_schema.tables - where table_schema <> 'pg_catalog' - and table_schema <> 'information_schema' - and table_type <> 'VIEW' - and table_name not similar to '%(_peer|_history)' - order by table_name) loop - base_table_name := rec1.table_schema || '.' || rec1.table_name; - insert_trigger := quote_ident(base_table_name || '_history_insert_trigger'); - update_trigger := quote_ident(base_table_name || '_history_update_trigger'); - delete_trigger := quote_ident(base_table_name || '_history_delete_trigger'); - -- insert trigger - execute format('drop trigger if exists '|| insert_trigger || ' on ' ||base_table_name); - execute format( - 'create trigger ' || insert_trigger - || ' after insert on ' || base_table_name - || ' for each row - execute procedure admin.history_trigger()'); - -- update trigger - execute format('drop trigger if exists ' || update_trigger || ' on ' || base_table_name); - execute format( - 'create trigger ' || update_trigger - || ' after update on ' || base_table_name || - ' for each row execute procedure admin.history_trigger()'); - -- delete trigger - execute format('drop trigger if exists ' || delete_trigger || ' on ' || base_table_name); - execute format( - 'create trigger ' || delete_trigger - || ' after delete on ' || base_table_name || - ' for each row execute procedure admin.history_trigger()'); - end loop; -end; $$; - - -call admin.create_history_tables(); -call admin.create_history_triggers(); diff --git a/src/core/postgres/sql/change-scripts/peer.sql b/src/core/postgres/sql/change-scripts/peer.sql deleted file mode 100644 index 8ec193a14d..0000000000 --- a/src/core/postgres/sql/change-scripts/peer.sql +++ /dev/null @@ -1,57 +0,0 @@ --- NOTE: using pg_catalog instead of information_schema might speed up the function --- NOTE: if function needs to be extended for multi-dimensional array datatypes for columns - https://stackoverflow.com/questions/39436189/how-to-get-the-dimensionality-of-an-array-column -create or replace procedure admin.create_peer_tables() -language plpgsql -as $$ -declare - rec0 record; - rec1 record; - rec2 record; - peer_table_name text; - status text; -begin - -- GETTING ALL NON-SYSTEM SCHEMAS - for rec0 in (select distinct table_schema from information_schema.tables where table_schema <> 'pg_catalog' - and table_schema <> 'information_schema' ) loop - - -- FINDING ALL TABLES THAT NEED A HISTORY AND LOOPING OVER THEM - for rec1 in (select table_name - from information_schema.tables - where table_schema = rec0.table_schema and table_name not similar to '%(_peer|_history)' - order by table_name) loop - - peer_table_name := rec1.table_name || '_peer'; - raise info 'peer_table_name: % ', peer_table_name; - - -- HISTORY TABLE CREATION - execute format('create table if not exists %I.%I ( _peer_id varchar(32) not null references admin.peers(id), - _row_id serial primary key)', rec0.table_schema,peer_table_name); - - -- UPDATE BOTH SECURITY AND HISTORY TABLE (IDEMPOTENT MANNER) - for rec2 in (select column_name,case - when (data_type = 'USER-DEFINED') then udt_schema || '.' || udt_name - when (data_type = 'ARRAY') then udt_schema || '.' || substr(udt_name, 2, length(udt_name)-1) || '[]' - when (data_type = 'character') then udt_schema || '.' || udt_name || '(' || character_maximum_length || ')' - when (data_type = 'character varying') then udt_schema || '.' || udt_name || '(' || character_maximum_length || ')' - else data_type - end as data_type from information_schema.columns - where table_schema = rec0.table_schema and table_name = rec1.table_name) loop - raise info 'col-name: % | data-type: %', rec2.column_name, rec2.data_type; - - perform column_name from information_schema.columns where table_schema = rec0.table_schema - and table_name = peer_table_name and column_name = rec2.column_name; - - if not found then - - raise info 'peer table updated'; - execute format('alter table ' || rec0.table_schema || '.' || peer_table_name || ' add column ' || rec2.column_name || ' ' || rec2.data_type); - - end if; - - end loop; - end loop; - end loop; - raise info 'DONE'; -end; $$; - -call admin.create_peer_tables(); diff --git a/src/core/postgres/sql/change-scripts/roles.data.sql b/src/core/postgres/sql/change-scripts/roles.data.sql deleted file mode 100755 index 1dbc2c41d2..0000000000 --- a/src/core/postgres/sql/change-scripts/roles.data.sql +++ /dev/null @@ -1,709 +0,0 @@ -CREATE OR REPLACE PROCEDURE admin.roles_migration( -) -LANGUAGE PLPGSQL -AS $$ -DECLARE - vProjectManagerRoleId varchar(32); - vProjectManagersGroupId varchar(32); - vRegionalDirectorRoleId varchar(32); - vRegionalDirectorsGroupId varchar(32); - vFieldOperationsDirectorRoleId varchar(32); - vFieldOperationsDirectorsGroupId varchar(32); - vControllerRoleId varchar(32); - vControllersGroupId varchar(32); - vLeadFinancialAnalystRoleId varchar(32); - vLeadFinancialAnalystsGroupId varchar(32); - vRoleCount int; -BEGIN - -- create roles and groups to replicate the cord field permissions - -- use bootstrap.sql for examples - - -- get admin person id, this will be needed when using UUIDs - select admin.people.id from admin.people - inner join admin.role_memberships on admin.role_memberships.person = admin.people.id - inner join admin.roles on admin.role_memberships.role = admin.roles.id - where admin.roles.name = 'Administrator' - order by admin.people.created_at asc - limit 1 - into vAdminPersonId; - - -- roles - insert into admin.roles(name, created_by, modified_by, owning_person, owning_group) values ('Project Manager', 1, 1, 1, 1) returning id into vProjectManagerRoleId; - insert into admin.roles(name, created_by, modified_by, owning_person, owning_group) values ('Regional Director', 1, 1, 1, 1) returning id into vRegionalDirectorRoleId; - insert into admin.roles(name, created_by, modified_by, owning_person, owning_group) values ('Field Operations Director', 1, 1, 1, 1) returning id into vFieldOperationsDirectorRoleId; - insert into admin.roles(name, created_by, modified_by, owning_person, owning_group) values ('Controller', 1, 1, 1, 1) returning id into vControllerRoleId; - insert into admin.roles(name, created_by, modified_by, owning_person, owning_group) values ('Lead Financial Analyst', 1, 1, 1, 1) returning id into vLeadFinancialAnalystRoleId; - - -- groups - insert into admin.groups(name, created_by, modified_by, owning_person, owning_group) values ('Project Managers', 1, 1, 1, 1) returning id into vProjectManagersGroupId; - insert into admin.groups(name, created_by, modified_by, owning_person, owning_group) values ('Regional Director', 1, 1, 1, 1) returning id into vRegionalDirectorsGroupId; - insert into admin.groups(name, created_by, modified_by, owning_person, owning_group) values ('Field Operations Director', 1, 1, 1, 1) returning id into vFieldOperationsDirectorsGroupId; - insert into admin.groups(name, created_by, modified_by, owning_person, owning_group) values ('Controller', 1, 1, 1, 1) returning id into vControllersGroupId; - insert into admin.groups(name, created_by, modified_by, owning_person, owning_group) values ('Lead Financial Analyst', 1, 1, 1, 1) returning id into vLeadFinancialAnalystsGroupId; - - -- table grants - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vProjectManagerRoleId, 'Create', 'admin.people', 1, 1, 1, 1), (vProjectManagerRoleId, 'Delete', 'admin.people', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vProjectManagerRoleId, 'Create', 'admin.users', 1, 1, 1, 1), (vProjectManagerRoleId, 'Delete', 'admin.users', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vProjectManagerRoleId, 'Create', 'common.organizations', 1, 1, 1, 1), (vProjectManagerRoleId, 'Delete', 'common.organizations', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vProjectManagerRoleId, 'Create', 'sc.languages', 1, 1, 1, 1), (vProjectManagerRoleId, 'Delete', 'sc.languages', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vRegionalDirectorRoleId, 'Create', 'admin.people', 1, 1, 1, 1), (vRegionalDirectorRoleId, 'Delete', 'admin.people', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vRegionalDirectorRoleId, 'Create', 'admin.users', 1, 1, 1, 1), (vRegionalDirectorRoleId, 'Delete', 'admin.users', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vRegionalDirectorRoleId, 'Create', 'common.organizations', 1, 1, 1, 1), (vRegionalDirectorRoleId, 'Delete', 'common.organizations', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vRegionalDirectorRoleId, 'Create', 'sc.languages', 1, 1, 1, 1), (vRegionalDirectorRoleId, 'Delete', 'sc.languages', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vFieldOperationsDirectorRoleId, 'Create', 'admin.people', 1, 1, 1, 1), (vFieldOperationsDirectorRoleId, 'Delete', 'admin.people', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vFieldOperationsDirectorRoleId, 'Create', 'admin.users', 1, 1, 1, 1), (vFieldOperationsDirectorRoleId, 'Delete', 'admin.users', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vFieldOperationsDirectorRoleId, 'Create', 'common.organizations', 1, 1, 1, 1), (vFieldOperationsDirectorRoleId, 'Delete', 'common.organizations', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vFieldOperationsDirectorRoleId, 'Create', 'sc.languages', 1, 1, 1, 1), (vFieldOperationsDirectorRoleId, 'Delete', 'sc.languages', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vControllerRoleId, 'Create', 'admin.people', 1, 1, 1, 1), (vControllerRoleId, 'Delete', 'admin.people', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vControllerRoleId, 'Create', 'admin.users', 1, 1, 1, 1), (vControllerRoleId, 'Delete', 'admin.users', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vControllerRoleId, 'Create', 'common.organizations', 1, 1, 1, 1), (vControllerRoleId, 'Delete', 'common.organizations', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vControllerRoleId, 'Create', 'sc.languages', 1, 1, 1, 1), (vControllerRoleId, 'Delete', 'sc.languages', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vLeadFinancialAnalystRoleId, 'Create', 'admin.people', 1, 1, 1, 1), (vLeadFinancialAnalystRoleId, 'Delete', 'admin.people', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vLeadFinancialAnalystRoleId, 'Create', 'admin.users', 1, 1, 1, 1), (vLeadFinancialAnalystRoleId, 'Delete', 'admin.users', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vLeadFinancialAnalystRoleId, 'Create', 'common.organizations', 1, 1, 1, 1), (vLeadFinancialAnalystRoleId, 'Delete', 'common.organizations', 1, 1, 1, 1); - insert into admin.role_table_permissions(role, table_permission, table_name, created_by, modified_by, owning_person, owning_group) values (vLeadFinancialAnalystRoleId, 'Create', 'sc.languages', 1, 1, 1, 1), (vLeadFinancialAnalystRoleId, 'Delete', 'sc.languages', 1, 1, 1, 1); - - -- column grants - - -- people's table - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'neo4j', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'about', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_at', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_by', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_at', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_by', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'phone', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'picture', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_org', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_first_name', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_last_name', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_first_name', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_last_name', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_location', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_full_name', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_full_name', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'sensitivity_clearance', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'time_zone', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'title', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'status', vProjectManagerRoleId, 'admin.people', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'neo4j', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'about', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_at', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_by', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_at', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_by', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'phone', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'picture', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_org', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_first_name', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_last_name', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_first_name', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_last_name', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_location', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_full_name', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_full_name', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'sensitivity_clearance', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'time_zone', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'title', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'status', vRegionalDirectorRoleId, 'admin.people', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'neo4j', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'about', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_at', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_by', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_at', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_by', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'phone', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'picture', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_org', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_first_name', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_last_name', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_first_name', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_last_name', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_location', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_full_name', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_full_name', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'sensitivity_clearance', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'time_zone', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'title', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'status', vFieldOperationsDirectorRoleId, 'admin.people', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'neo4j', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'about', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_at', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_by', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_at', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_by', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'phone', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'picture', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_org', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_first_name', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_last_name', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_first_name', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_last_name', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_location', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_full_name', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_full_name', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'sensitivity_clearance', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'time_zone', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'title', vControllerRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'status', vControllerRoleId, 'admin.people', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'neo4j', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'about', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_at', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'created_by', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_at', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'modified_by', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'phone', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'picture', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_org', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_first_name', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_last_name', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_first_name', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_last_name', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'primary_location', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'private_full_name', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'public_full_name', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'sensitivity_clearance', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'time_zone', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'title', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1), - ('Write', 'status', vLeadFinancialAnalystRoleId, 'admin.people', 1, 1, 1, 1); - - -- grants on users - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'person', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'owning_org', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'email', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'password', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_at', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_by', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_at', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_by', vProjectManagerRoleId, 'admin.users', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'person', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'owning_org', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'email', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'password', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_at', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_by', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_at', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_by', vRegionalDirectorRoleId, 'admin.users', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'person', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'owning_org', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'email', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'password', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_at', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_by', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_at', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_by', vFieldOperationsDirectorRoleId, 'admin.users', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'person', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'owning_org', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'email', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'password', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_at', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_by', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_at', vControllerRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_by', vControllerRoleId, 'admin.users', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'id', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'person', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'owning_org', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'email', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'password', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_at', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'created_by', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_at', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1), - ('Write', 'modified_by', vLeadFinancialAnalystRoleId, 'admin.users', 1, 1, 1, 1); - - -- grants on sc.languages - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'prioritization', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'progress_bible', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'location_long', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'island', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'province', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'first_language_population', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'population_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'least_reached_progress_jps_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'least_reached_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'partner_interest_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_linguistic_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_joint_training_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_language_development_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_scripture_translation_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'access_to_scripture_in_lwc_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_geo_challenges_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_rel_pol_obstacles_level', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_value', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_description', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_source', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'suggested_strategies', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'comments', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'created_at', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'created_by', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_at', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_by', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_person', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_group', vProjectManagerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'prioritization', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'progress_bible', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'location_long', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'island', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'province', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'first_language_population', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'population_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'least_reached_progress_jps_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'least_reached_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'partner_interest_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_linguistic_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_joint_training_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_language_development_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_scripture_translation_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'access_to_scripture_in_lwc_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_geo_challenges_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_rel_pol_obstacles_level', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_value', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_description', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_source', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'suggested_strategies', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'comments', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'created_at', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'created_by', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_at', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_by', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_person', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_group', vRegionalDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'prioritization', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'progress_bible', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'location_long', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'island', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'province', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'first_language_population', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'population_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'least_reached_progress_jps_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'least_reached_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'partner_interest_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_linguistic_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_joint_training_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_language_development_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_scripture_translation_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'access_to_scripture_in_lwc_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_geo_challenges_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_rel_pol_obstacles_level', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_value', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_description', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_source', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'suggested_strategies', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'comments', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'created_at', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'created_by', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_at', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_by', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_person', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_group', vFieldOperationsDirectorRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'prioritization', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'progress_bible', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'location_long', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'island', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'province', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'first_language_population', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'population_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'least_reached_progress_jps_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'least_reached_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'partner_interest_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_linguistic_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_joint_training_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_language_development_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_scripture_translation_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'access_to_scripture_in_lwc_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_geo_challenges_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_rel_pol_obstacles_level', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_value', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_description', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_source', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'suggested_strategies', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'comments', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'created_at', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'created_by', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_at', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_by', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_person', vControllerRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_group', vControllerRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'prioritization', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'progress_bible', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'location_long', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'island', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'province', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'first_language_population', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'population_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'egids_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'least_reached_progress_jps_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'least_reached_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'partner_interest_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'partner_interest_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_linguistic_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_linguistic_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'multiple_languages_leverage_joint_training_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'multiple_languages_leverage_joint_training_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_language_development_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_language_development_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'lang_comm_int_in_scripture_translation_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'lang_comm_int_in_scripture_translation_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'access_to_scripture_in_lwc_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'access_to_scripture_in_lwc_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_geo_challenges_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_geo_challenges_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'begin_work_rel_pol_obstacles_level', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_value', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_description', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'begin_work_rel_pol_obstacles_source', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'suggested_strategies', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'comments', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values - ('Write', 'created_at', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'created_by', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_at', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'modified_by', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_person', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1), - ('Write', 'owning_group', vLeadFinancialAnalystRoleId, 'sc.languages', 1, 1, 1, 1); - - -- grants on organizations - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'neo4j', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_at', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_by', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_at', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_by', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'name', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'sensitivity', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'primary_location', vProjectManagerRoleId, 'common.organizations', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'neo4j', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_at', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_by', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_at', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_by', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'name', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'sensitivity', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'primary_location', vRegionalDirectorRoleId, 'common.organizations', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'neo4j', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_at', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_by', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_at', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_by', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'name', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'sensitivity', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'primary_location', vFieldOperationsDirectorRoleId, 'common.organizations', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'neo4j', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_at', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_by', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_at', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_by', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'name', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'sensitivity', vControllerRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'primary_location', vControllerRoleId, 'common.organizations', 1, 1, 1, 1); - - insert into admin.role_column_grants(access_level, column_name, role, table_name, created_by, modified_by, owning_person, owning_group) - values ('Write', 'id', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'neo4j', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_at', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'created_by', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_at', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'modified_by', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'name', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'sensitivity', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1), - ('Write', 'primary_location', vLeadFinancialAnalystRoleId, 'common.organizations', 1, 1, 1, 1); - -END; $$; - -call admin.roles_migration(); diff --git a/src/core/postgres/sql/change-scripts/sc.v1.sql b/src/core/postgres/sql/change-scripts/sc.v1.sql deleted file mode 100644 index e702686a10..0000000000 --- a/src/core/postgres/sql/change-scripts/sc.v1.sql +++ /dev/null @@ -1,44 +0,0 @@ - -insert into admin_table_name_enum(value) values - ('sc_budget_records'), - ('sc_budget_records_partnerships'), - ('sc_budgets'), - ('sc_ceremonies'), - ('sc_change_to_plans'), - ('sc_ethno_arts'), - ('sc_ethnologue'), - ('sc_field_regions'), - ('sc_field_zones'), - ('sc_file_versions'), - ('sc_films'), - ('sc_funding_accounts'), - ('sc_global_partner_assessments'), - ('sc_global_partner_engagements'), - ('sc_global_partner_engagement_people'), - ('sc_global_partner_performance'), - ('sc_global_partner_transitions'), - ('sc_internship_engagements'), - ('sc_known_languages_by_person'), - ('sc_language_engagements'), - ('sc_language_goal_definitions'), -- not finishe), - ('sc_language_goals'), -- not finishe), - ('sc_language_locations'), -- not finishe), - ('sc_languages'), - ('sc_locations'), - ('sc_organization_locations'), - ('sc_organizations'), - ('sc_partners'), - ('sc_partnerships'), - ('sc_people'), - ('sc_periodic_reports'), - ('sc_periodic_reports_directory'), - ('sc_person_unavailabilities'), - ('sc_pinned_projects'), - ('sc_posts'), - ('sc_posts_directory'), - ('sc_product_scripture_references'), - ('sc_products'), - ('sc_project_locations'), - ('sc_project_members'), - ('sc_projects'), - ('sc_stories'); diff --git a/src/core/postgres/sql/change-scripts/sc.v3.sql b/src/core/postgres/sql/change-scripts/sc.v3.sql deleted file mode 100644 index 155059d7a3..0000000000 --- a/src/core/postgres/sql/change-scripts/sc.v3.sql +++ /dev/null @@ -1,1352 +0,0 @@ --- Seed Company Schema ------------------------------------------------------------- - -create schema sc; - -create type common.product_mediums_enum as enum ( - 'Print', - 'Web', - 'EBook', - 'App', - 'TrainedStoryTellers', - 'Audio', - 'Video', - 'Other', - 'OralTranslation' -); - -create type common.product_methodologies as enum ( - 'AdobeAudition', - 'Audacity', - 'Craft2Tell', - 'Film', - 'OneStory', - 'OtherOralStories', - 'OtherOralTranslation', - 'OtherWritten', - 'OtherVisual', - 'Paratext', - 'Render', - 'SeedCompanyMethod', - 'SignLanguage', - 'StoryTogether' - ); - -create type common.product_approach as enum ( - 'OralStories', - 'OralTranslation', - 'Visual', - 'Written' -); - -create type common.product_purposes as enum ( - 'EvangelismChurchPlanting', - 'ChurchLife', - 'ChurchMaturity', - 'SocialIssues', - 'Discipleship' -); - - --- POSTS ---------------------------------------------------------- - -create table sc.posts_directory ( -- does not need to be secure - id varchar(32) primary key default common.nanoid(), - created_at timestamp not null default CURRENT_TIMESTAMP -); - -create type sc.post_shareability as enum ( - 'ProjectTeam', - 'Internal', - 'AskToShareExternally', - 'External', - 'Membership' -); - -create type sc.post_type as enum ( - 'Note', - 'Story', - 'Prayer' -); - -create type sc.post_parent_type_enum as enum ( - 'TranslationProject', - 'InternshipProject', - 'LanguageEngagement', - 'InternshipEngagement', - 'Partner', - 'Language', - 'User' -); - --- CHANGE SETS -------------------------------------------------------------------- --- todo -create type sc.change_set_type as enum ( - 'a', - 'b', - 'c' -); - --- todo -create type sc.change_set_status as enum ( - 'a', - 'b', - 'c' -); - -create table sc.change_sets ( - id varchar(32) primary key default common.nanoid(), - - status sc.change_set_status, - summary text, - type sc.change_set_type, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.posts ( - id varchar(32) primary key default common.nanoid(), - - parent_id varchar(32), - parent_type_admin_table_name_enum_value varchar(64) not null references admin_table_name_enum(value), - common_directories_id varchar(32) references common.directories(id), -- not null - type sc.post_type, --not null, - shareability sc.post_shareability, --not null, - body text, --not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- ACCOUNTING TABLES -------------------------------------------------------- - -create table sc.funding_accounts ( - id varchar(32) primary key default common.nanoid(), - - account_number int unique, -- not null, - name varchar(255), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- common_locations_id TABLES ---------------------------------------------------------- - --- todo Ken to review in DOMO -create table sc.field_zones ( - id varchar(32) primary key default common.nanoid(), - - director_admin_people_id varchar(32) references admin.people(id), - name varchar(64) unique, -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- todo Ken to review in DOMO -create table sc.field_regions ( - id varchar(32) primary key default common.nanoid(), - sc_field_zone_id varchar(32) references sc.field_zones(id), - - director_admin_people_id varchar(32) references admin.people(id), - name varchar(32) unique, -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.locations ( - id varchar(32) unique not null references common.locations(id), - - -- todo research using aliases - default_region varchar(32) references sc.field_regions(id), - funding_account varchar(32) references sc.funding_accounts(id), - sensitivity common.sensitivity not null default 'High', - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.field_region_locations ( - id varchar(32) unique not null references common.locations(id), - - sc_field_regions_id varchar(32) references sc.field_regions(id), - common_locations_id varchar(32) references common.locations(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.field_zone_locations ( - id varchar(32) unique not null references common.locations(id), - - sc_field_zones_id varchar(32) references sc.field_zones(id), - common_locations_id varchar(32) references common.locations(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- common_organizations_id TABLES - -create type sc.periodic_report_type as enum ( - 'Financial', - 'Narrative', - 'Progress' -); - -DO $$ BEGIN - create type sc.financial_reporting_types as enum ( - 'Funded', - 'FieldEngaged' - ); - EXCEPTION - WHEN duplicate_object THEN null; -END; $$; - -DO $$ BEGIN - create type sc.partner_types as enum ( - 'Managing', - 'Funding', - 'Impact', - 'Technical', - 'Resource' - ); - EXCEPTION - WHEN duplicate_object THEN null; -END; $$; - -create table sc.partners ( - id varchar(32) primary key default common.nanoid(), - common_organizations_id varchar(32) references common.organizations(id), - active bool, - financial_reporting_types sc.financial_reporting_types[], - is_innovations_client bool, - pmc_entity_code varchar(32), - point_of_contact_people_id varchar(32) references admin.people(id), - types sc.partner_types[], - address varchar(255), - sensitivity common.sensitivity not null default 'High', - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- PROJECTS ---------------------------------------------------------------------------------------------------------------- - -create type sc.project_step as enum ( - 'EarlyConversations', - 'PendingConceptApproval', - 'PrepForConsultantEndorsement', - 'PendingConsultantEndorsement', - 'PrepForFinancialEndorsement', - 'PendingFinancialEndorsement', - 'FinalizingProposal', - 'PendingRegionalDirectorApproval', - 'PendingZoneDirectorApproval', - 'PendingFinanceConfirmation', - 'OnHoldFinanceConfirmation', - 'DidNotDevelop', - 'Rejected', - 'Active', - 'ActiveChangedPlan', - 'DiscussingChangeToPlan', - 'PendingChangeToPlanApproval', - 'PendingChangeToPlanConfirmation', - 'DiscussingSuspension', - 'PendingSuspensionApproval', - 'Suspended', - 'DiscussingReactivation', - 'PendingReactivationApproval', - 'DiscussingTermination', - 'PendingTerminationApproval', - 'FinalizingCompletion', - 'Terminated', - 'Completed' -); - -create type sc.project_status as enum ( - 'InDevelopment', - 'Active', - 'Terminated', - 'Completed', - 'DidNotDevelop' -); - -create type sc.project_type as enum ( - 'Translation', - 'Internship' -); - - -create type sc.financial_report_period_type as enum ( - 'Monthly', - 'Quarterly' -); - --- extension table to common -create table sc.projects ( - id varchar(32) primary key default common.nanoid(), - - name varchar(64), -- not null - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - department_id varchar(5), - estimated_submission date, - sc_field_regions_id varchar(32) references sc.field_regions(id), - financial_report_period sc.financial_report_period_type default 'Quarterly', - initial_mou_end date, - marketing_common_locations_id varchar(32) references common.locations(id), - mou_start date, - mou_end date, - primary_common_locations_id varchar(32) references common.locations(id), - root_directory_common_directories_id varchar(32) references common.directories(id), - status sc.project_status, -- not null todo - step sc.project_step, -- not null todo - step_changed_at timestamp, - sensitivity common.sensitivity not null default 'High', -- not null todo - tags text[], - type sc.project_type, - financial_report_received_at timestamp, -- legacy, not in api - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (id, sc_change_set_id) -); - -create table sc.translation_projects ( - id varchar(32) primary key references sc.projects(id), - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - - preset_inventory bool, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (id, sc_change_set_id) -); - -create table sc.internship_projects ( - id varchar(32) primary key references sc.projects(id), - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (id, sc_change_set_id) -); - -create table sc.project_members ( - id varchar(32) primary key default common.nanoid(), - - sc_projects_id varchar(32) references sc.projects(id), --not null - admin_people_id varchar(32) references admin.people(id), --not null - admin_groups_id varchar(32) unique references admin.groups(id), --not null - admin_role_id varchar(32) references admin.roles(id), --not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (sc_projects_id, admin_people_id, admin_groups_id, admin_role_id) -); - --- ENGAGEMENTS - --- todo -create type common.internship_methodology as enum ( - 'A', - 'B', - 'C' -); - -create type common.internship_position as enum ( - 'ConsultantInTraining', - 'ExegeticalFacilitator', - 'LeadershipDevelopment', - 'Mobilization', - 'Personnel', - 'Communication', - 'Administration', - 'Technology', - 'Finance', - 'LanguageProgramManager', - 'Literacy', - 'TranslationFacilitator', - 'OralityFacilitator', - 'ScriptureEngagement', - 'OtherAttached', - 'OtherTranslationCapacity', - 'OtherPartnershipCapacity' -); - -create type sc.engagement_types_enum as enum ( - 'Language', - 'Internship' -); - - -create type common.engagement_status as enum ( - 'InDevelopment', - 'DidNotDevelop', - 'Active', - 'DiscussingTermination', - 'DiscussingReactivation', - 'DiscussingChangeToPlan', - 'DiscussingSuspension', - 'FinalizingCompletion', - 'ActiveChangedPlan', - 'Suspended', - 'Terminated', - 'Completed', - 'Converted', - 'Unapproved', - 'Transferred', - 'NotRenewed', - 'Rejected' -); - -create table sc.engagements ( - id varchar(32) primary key default common.nanoid(), - - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - sc_projects_id varchar(32) references sc.projects(id), -- not null - engagement_type sc.engagement_types_enum, -- not null - status common.engagement_status, -- not null - ceremony varchar(32), -- not null, - complete_date date, - disbursement_complete_date date, - end_date date, - end_date_override date, - start_date date, - start_date_override date, - sensitivity common.sensitivity not null default 'High', initial_end_date date, - last_suspended_at timestamp, - last_reactivated_at timestamp, - status_modified_at timestamp, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (sc_projects_id, sc_change_set_id) -); - - --- todo -create type common.project_engagement_tag as enum ( - 'A', - 'B', - 'C' -); - -create table sc.language_engagements ( - id varchar(32) primary key references sc.engagements(id), - - common_languages_id varchar(32) references common.languages(id), -- not null - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - is_open_to_investor_visit bool, - is_first_scripture bool, - is_luke_partnership bool, - sent_printing_date date, - paratext_registry varchar(64), - pnp_common_files_id varchar(32) references common.files(id), - historic_goal varchar(255), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (common_languages_id, sc_change_set_id) -); - -create table sc.internship_engagements ( - id varchar(32) primary key references sc.engagements(id), - - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - country_of_origin_common_locations_id varchar(32) references common.locations(id), - intern_admin_people_id varchar(32) references admin.people(id), -- not null - mentor_admin_people_id varchar(32) references admin.people(id), - methodologies common.product_methodologies[], - position common.internship_position, - growth_plan_common_files_id varchar(32) references common.files(id), --references files, not file-versions in neo4j - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - - --- language_common_languages_id TABLES ---------------------------------------------------------- - ---create table sc.ethnologue ( --- id varchar(32) primary key default common.nanoid(), --- --- language_index varchar(32) not null references sil.language_index(id), --- code varchar(32), --- language_name varchar(75), -- override for language_index --- population int, --- provisional_code varchar(32), --- --- created_at timestamp not null default CURRENT_TIMESTAMP, --- created_by_admin_people_id varchar(32) not null references admin.people(id), --- modified_at timestamp not null default CURRENT_TIMESTAMP, --- modified_by_admin_people_id varchar(32) not null references admin.people(id), --- owning_person_admin_people_id varchar(32) not null references admin.people(id), --- owning_group_admin_groups_id varchar(32) not null references admin.groups(id) ---); - -create type sc.least_reached_progress_scale as enum ( - '0', - '1', - '2', - '3', - '4', - '5' -); - -create type sc.partner_interest_scale as enum ( - 'NoPartnerInterest', - 'Some', - 'Significant', - 'Considerable' -); - -create type sc.multiple_languages_leverage_linguistic_scale as enum ( - 'None', - 'Some', - 'Significant', - 'Considerable', - 'Large', - 'Vast' -); - -create type sc.multiple_languages_leverage_joint_training_scale as enum ( - 'None', - 'Some', - 'Significant', - 'Considerable', - 'Large', - 'Vast' -); - -create type sc.lang_comm_int_in_language_development_scale as enum ( - 'NoInterest', - 'Some', - 'Significant', - 'Considerable' -); - -create type sc.lang_comm_int_in_scripture_translation_scale as enum ( - 'NoInterest', - 'Some', - 'ExpressedNeed', - 'Significant', - 'Considerable' -); - -create type sc.access_to_scripture_in_lwc_scale as enum ( - 'FullAccess', - 'VastMajority', - 'LargeMajority', - 'Majority', - 'Significant', - 'Some', - 'Few' -); - -create type sc.begin_work_geo_challenges_scale as enum ( - 'None', - 'VeryDifficult', - 'Difficult', - 'Moderate', - 'Easy' -); - -create type sc.begin_work_rel_pol_obstacles_scale as enum ( - 'None', - 'VeryDifficult', - 'Difficult', - 'Moderate', - 'Easy' -); - -create table sc.languages( - id varchar(32) primary key references common.languages(id), - - -- sc_ethnologue_id varchar(32) references sc.ethnologue(id), -- may not be needed - name varchar(255), -- not null unique - display_name varchar(255), -- not null unique - display_name_pronunciation varchar(255), - tags text[], - is_preset_inventory bool, -- if false = grandfathered - is_dialect bool, - is_sign_language bool, - is_least_of_these bool, -- todo is going away, keep for historical - least_of_these_reason varchar(255), - population_override int, - provisional_code char(3), - registry_of_dialects_code char(5) unique, - sensitivity common.sensitivity not null default 'High', - sign_language_code char(4), - sponsor_start_date date, -- derived - sponsor_estimated_end_date date, -- todo research this field. new? - has_external_first_scripture bool, - first_scripture_engagement varchar(32) references sc.language_engagements(id), - --- language_name varchar(32), --- iso varchar(4), - - prioritization decimal generated always as ( - population_value * 2 + - egids_value * 3 + - least_reached_value * 2 + - partner_interest_value * 2 + - multiple_languages_leverage_linguistic_value * 1 + - multiple_languages_leverage_joint_training_value * 1 + - lang_comm_int_in_language_development_value * 1 + - lang_comm_int_in_scripture_translation_value * 1 + - access_to_scripture_in_lwc_value * 1 + - begin_work_geo_challenges_value * 0.5 + - begin_work_rel_pol_obstacles_value * 0.5 - ) stored, - progress_bible bool, - - location_long text, - island varchar(32), - province varchar(32), - - first_language_population int, - population_value decimal default 0, -- calculated from first_language_population - - egids_level common.egids_scale, - egids_value decimal default 0, -- calculated from _level - - -- todo research removing value columns - least_reached_progress_jps_level sc.least_reached_progress_scale, - least_reached_value decimal default 0, -- calculated from _level - - partner_interest_level sc.partner_interest_scale, - partner_interest_value decimal default 0, -- calculated from _level - partner_interest_description text, - partner_interest_source text, - - multiple_languages_leverage_linguistic_level sc.multiple_languages_leverage_linguistic_scale, - multiple_languages_leverage_linguistic_value decimal default 0, -- calculated from _level - multiple_languages_leverage_linguistic_description text, - multiple_languages_leverage_linguistic_source text, - - multiple_languages_leverage_joint_training_level sc.multiple_languages_leverage_joint_training_scale, - multiple_languages_leverage_joint_training_value decimal default 0, -- calculated from _level - multiple_languages_leverage_joint_training_description text, - multiple_languages_leverage_joint_training_source text, - - lang_comm_int_in_language_development_level sc.lang_comm_int_in_language_development_scale, - lang_comm_int_in_language_development_value decimal default 0, -- calculated from _level - lang_comm_int_in_language_development_description text, - lang_comm_int_in_language_development_source text, - - lang_comm_int_in_scripture_translation_level sc.lang_comm_int_in_scripture_translation_scale, - lang_comm_int_in_scripture_translation_value decimal default 0, -- calculated from _level - lang_comm_int_in_scripture_translation_description text, - lang_comm_int_in_scripture_translation_source text, - - access_to_scripture_in_lwc_level sc.access_to_scripture_in_lwc_scale, - access_to_scripture_in_lwc_value decimal default 0, -- calculated from _level - access_to_scripture_in_lwc_description text, - access_to_scripture_in_lwc_source text, - - begin_work_geo_challenges_level sc.begin_work_geo_challenges_scale, - begin_work_geo_challenges_value decimal default 0, -- calculated from _level - begin_work_geo_challenges_description text, - begin_work_geo_challenges_source text, - - begin_work_rel_pol_obstacles_level sc.begin_work_rel_pol_obstacles_scale, - begin_work_rel_pol_obstacles_value decimal default 0, -- calculated from _level - begin_work_rel_pol_obstacles_description text, - begin_work_rel_pol_obstacles_source text, - - coordinates common.geography, - suggested_strategies text, - comments text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.language_goal_definitions ( - id varchar(32) primary key default common.nanoid(), - - -- todo - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.language_goals ( - id varchar(32) primary key default common.nanoid(), - - common_languages_id varchar(32) not null references common.languages(id), - sc_language_goal_definitions_id varchar(32) not null references sc.language_goal_definitions(id), - -- todo - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (common_languages_id, sc_language_goal_definitions_id) -); - --- USER TABLES -------------------------------------------------------------- - -create table sc.known_languages_by_person ( - id varchar(32) primary key default common.nanoid(), - - admin_people_id varchar(32) unique not null references admin.people(id), - sc_languages_id varchar(32) not null references common.languages(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (admin_people_id, sc_languages_id) -); - -create type sc.user_status as enum ( - 'Active', - 'Disabled' -); - --- extension table from commmon -create table sc.people ( - id varchar(32) primary key references admin.people(id), - - skills varchar(32)[], - status sc.user_status, - title varchar(255), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.person_unavailabilities ( - id varchar(32) primary key default common.nanoid(), - - admin_people_id varchar(32) references admin.people(id), - period_start date not null, - period_end date not null, - description text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - - --- sc_projects_id TABLES ---------------------------------------------------------- - - - - - -create type sc.periodic_report_parent_type as enum ( - 'a', - 'b', - 'c' -); - -create table sc.periodic_reports ( - id varchar(32) primary key default common.nanoid(), - - parent varchar(32), - parent_type sc.periodic_report_parent_type, - common_directories_id varchar(32) references common.directories(id), - end_at date, - report_common_files_id varchar(32) references common.files(id), - start_at date, - type sc.periodic_report_type, - skipped_reason text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - - - - -create type sc.pinned_types as enum ( - 'LanguageProject', - 'InternshipProject', - 'TranslationEngagement', - 'InternshipEngagement', - 'language_common_languages_id', - 'Partner', - 'sc_products_id' -); - -create table sc.pinned ( - id varchar(32) primary key default common.nanoid(), - admin_people_id varchar(32) unique references admin.people(id), -- not null - pinned varchar(32), -- not null - type sc.pinned_types, -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sc.partnership_agreement_status as enum ( - 'NotAttached', - 'AwaitingSignature', - 'Signed' -); - -create table sc.partnerships ( - id varchar(32) primary key default common.nanoid(), - - sc_projects_id varchar(32) references sc.projects(id), -- not null - sc_partners_id varchar(32) references sc.partners(id), -- not null - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - agreement_status sc.partnership_agreement_status, - mou varchar(32) references common.files(id), - agreement varchar(32) references common.files(id), - mou_status sc.partnership_agreement_status, - mou_start date, -- derived from sc.projects unless overridden - mou_end date, -- derived from sc.projects unless overridden - mou_start_override date, - mou_end_override date, - financial_reporting_type sc.financial_reporting_types, - is_primary bool, - sensitivity common.sensitivity not null default 'High', - - types sc.partner_types[], -- added because exists in neo4j - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) - -); - --- sc_projects_id BUDGETS - -create type common.budget_status as enum ( - 'Pending', - 'Current', - 'Superseded', - 'Rejected' -); - -create table sc.budgets ( - id varchar(32) primary key default common.nanoid(), - - sc_change_set_id varchar(32), -- not null - sc_projects_id varchar(32) references sc.projects(id), -- not null - status common.budget_status, - universal_template varchar(32) references common.files(id), - sensitivity common.sensitivity not null default 'High', -- derived from sc.projects - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (id, sc_change_set_id) -); - -create table sc.budget_records ( - id varchar(32) primary key default common.nanoid(), - - sc_budgets_id varchar(32) references sc.budgets(id), -- not null - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - amount decimal, - fiscal_year int, - partnership varchar(32) not null references sc.partnerships(id), - sensitivity common.sensitivity not null default 'High', -- derived from sc.projects - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - peer varchar(32) references admin.peers(id) - -); - --- sc_projects_id common_locations_id - -create table sc.project_locations ( - id varchar(32) primary key default common.nanoid(), - - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - common_locations_id varchar(32) references common.locations(id), -- not null - sc_projects_id varchar(32) references sc.projects(id), -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (sc_projects_id, common_locations_id, sc_change_set_id) -); - - -create table sc.partnership_producing_mediums ( - id varchar(32) primary key references sc.engagements(id), - - engagement_sc_engagements_id varchar(32) references sc.engagements(id), -- not null - partnership_sc_partnerships_id varchar(32) references sc.partnerships(id), -- not null - product_medium common.product_mediums_enum, -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- PRODUCTS - - - --- move to table - films stories ethnoart --- names and scripture references ---create type sc.product_type as enum ( --- 'BibleStories', --- 'DirectScriptureProduct', --- 'DerivativeScriptureProduct', --- 'EthnoArts', --- 'Film', --- 'FullBible', --- 'Genesis', --- 'Gospel', --- 'IndividualBooks', --- 'JesusFilm', --- 'LiteracyMaterials', --- 'NewTestamentFull', --- 'OldTestamentPortions', --- 'OldTestamentFull', --- 'Songs', --- 'OtherProduct', --- 'Story' ---); - -create type common.progress_measurement as enum ( - 'Percent', - 'Number', - 'Boolean' -); - -create type common.product_steps_enum as enum ( - 'ExegesisAndFirstDraft', - 'TeamCheck', - 'CommunityTesting', - 'BackTranslation', - 'ConsultantCheck', - 'InternalizationAndDrafting', - 'PeerRevision', - 'ConsistencyCheckAndFinalEdits', - 'Craft', - 'Test', - 'Check', - 'Record', - 'Completed' -); - -create type sc.producible_types as enum ( - 'Film', - 'Story', - 'EthnoArt' -); - -create table sc.products ( - id varchar(32) primary key default common.nanoid(), - - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - sc_language_engagements_id varchar(32) references sc.language_engagements(id), - mediums common.product_mediums_enum[], - purposes common.product_purposes[], -- todo may need for historical data, delete - methodology common.product_methodologies, - sensitivity common.sensitivity not null default 'High', - steps common.product_steps_enum[], - describe_completion text, - progress_step_measurement common.progress_measurement, - progress_target decimal, - placeholder_description text, - - -- todo, are these needed now that we have the 3 products tables? - -- pnp_index int, - -- total verses, - -- total verse equivalents -- derived from scripture references - -- name varchar(64), -- not null - -- active bool, - -- type sc.product_type, - -- description text, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (id, sc_change_set_id) -); - -create table sc.direct_scripture_products ( - id varchar(32) references sc.products(id), - - common_scripture_references_id varchar(32)[], - total_verses int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.derivative_products ( - id varchar(32) references sc.products(id), - - composite bool, - producible varchar(32), -- not null - type sc.producible_types, -- not null, - scripture_reference_override_common_scripture_references_id varchar(32) references common.scripture_references(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.other_products ( - id varchar(32) references sc.products(id), - - title varchar(128), - description text, - common_scripture_references_id varchar(32)[], - total_verses int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.product_scripture_references ( - id varchar(32) primary key default common.nanoid(), - sc_products_id varchar(32) references sc.products(id), -- not null - common_scripture_references_id varchar(32) references common.scripture_references(id), -- not null - sc_change_set_id varchar(32) references sc.change_sets(id), -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (id) -); - -create table sc.product_progress ( - id varchar(32) primary key default common.nanoid(), - - sc_products_id varchar(32) references sc.products(id), - sc_periodic_reports_id varchar(32) references sc.periodic_reports(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table sc.step_progress ( - id varchar(32) primary key default common.nanoid(), - - sc_product_progress_id varchar(32) references sc.product_progress(id), - step common.product_steps_enum, - completed decimal, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sc.report_period_enum as enum ( - 'Monthly', - 'Quarterly', - 'FiscalYearToDate', - 'Cumulative' -); - -create table sc.progress_summary ( - id varchar(32) primary key default common.nanoid(), - - actual decimal, - planned decimal, - report_period sc.report_period_enum, -- not null - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - - - --- CEREMONIES - -create type common.ceremony_type as enum ( - 'Dedication', - 'Certification' -); - -create table sc.ceremonies ( - id varchar(32) primary key default common.nanoid(), - - sc_engagements_id varchar(32) references sc.engagements(id), -- not null - engagement_type sc.engagement_types_enum, -- not null - ethnologue_sil_table_of_languages_id varchar(32) references sil.table_of_languages(id), - actual_date date, - estimated_date date, - is_planned bool, - type common.ceremony_type, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- PARTNER CRM STUFF --------------------------------------------------------------------------------------------------- - -create type sc.partner_maturity_scale as enum ( - 'Level 1', -- Non-Existent or Reactive - 'Level 2', -- Repeatable and Active - 'Level 3', -- Proactive and Defined - 'Level 4' -- Fully Capable and Managed -); - -create table sc.global_partner_assessments ( - id varchar(32) primary key default common.nanoid(), - - partner_common_organizations_id varchar(32) not null references common.organizations(id), - - governance_trans sc.partner_maturity_scale, - director_trans sc.partner_maturity_scale, - identity_trans sc.partner_maturity_scale, - growth_trans sc.partner_maturity_scale, - comm_support_trans sc.partner_maturity_scale, - systems_trans sc.partner_maturity_scale, - fin_management_trans sc.partner_maturity_scale, - hr_trans sc.partner_maturity_scale, - it_trans sc.partner_maturity_scale, - program_design_trans sc.partner_maturity_scale, - tech_translation_trans sc.partner_maturity_scale, - director_opp sc.partner_maturity_scale, - financial_management_opp sc.partner_maturity_scale, - program_design_opp sc.partner_maturity_scale, - tech_translation_opp sc.partner_maturity_scale, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sc.partner_performance_options as enum( - '1', '2', '3', '4' -); - -create table sc.global_partner_performance ( - id varchar(32) primary key default common.nanoid(), - - common_organizations_id varchar(32) unique not null references common.organizations(id), - - reporting_performance sc.partner_performance_options, - financial_performance sc.partner_performance_options, - translation_performance sc.partner_performance_options, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sc.global_partner_transition_options as enum( - 'common_organizations_id Assessment', - 'Development' -); - - create table sc.global_partner_transitions ( - id varchar(32) primary key default common.nanoid(), - - common_organizations_id varchar(32) unique not null references common.organizations(id), - transition_type sc.global_partner_transition_options not null, - effective_date date, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) - ); - -create type sc.global_partner_roles as enum ( - 'A', - 'B' -); - -create table sc.global_partner_engagements ( - id varchar(32) primary key default common.nanoid(), - - common_organizations_id varchar(32) not null references common.organizations(id), - type common.involvement_options not null, - mou_start date, - mou_end date, - sc_roles sc.global_partner_roles[], - partner_roles sc.global_partner_roles[], - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (common_organizations_id, type) -); - -create table sc.global_partner_engagement_people ( - id varchar(32) primary key default common.nanoid(), - - sc_global_partner_engagements_id varchar(32) not null references sc.global_partner_engagements(id), - admin_people_id varchar(32) not null references admin.people(id), - admin_role_id common.people_to_org_relationship_type not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id), - - unique (sc_global_partner_engagements_id, admin_people_id, admin_role_id) -); diff --git a/src/core/postgres/sql/change-scripts/sc.v4.sql b/src/core/postgres/sql/change-scripts/sc.v4.sql deleted file mode 100644 index db784d8833..0000000000 --- a/src/core/postgres/sql/change-scripts/sc.v4.sql +++ /dev/null @@ -1,41 +0,0 @@ -alter table sc.funding_accounts alter column account_number set not null; -alter table sc.field_zones alter column name set not null; -alter table sc.field_regions alter column name set not null; -alter table sc.locations alter column name set not null; -alter table sc.locations alter column type set not null; -alter table sc.languages alter column name set not null; -alter table sc.languages alter column display_name set not null; -alter table sc.periodic_reports alter column common_directories_id set not null; -alter table sc.periodic_reports alter column end_at set not null; -alter table sc.periodic_reports alter column report_file set not null; -alter table sc.periodic_reports alter column start_at set not null; -alter table sc.periodic_reports alter column type set not null; -alter table sc.projects alter column name set not null; -alter table sc.projects alter column change_to_plan set not null; -alter table sc.project_members alter column sc_projects_id set not null; -alter table sc.project_members alter column admin_people_id set not null; -alter table sc.project_members alter column admin_groups_id set not null; -alter table sc.project_members alter column admin_role_id set not null; -alter table sc.pinned_projects alter column admin_people_id set not null; -alter table sc.pinned_projects alter column sc_projects_id set not null; -alter table sc.partnerships alter column sc_projects_id set not null; -alter table sc.partnerships alter column partner set not null; -alter table sc.partnerships alter column change_to_plan set not null; -alter table sc.budgets alter column change_to_plan set not null; -alter table sc.budgets alter column sc_projects_id set not null; -alter table sc.budget_records alter column sc_budgets_id set not null; -alter table sc.budget_records alter column change_to_plan set not null; -alter table sc.project_locations alter column change_to_plan set not null; -alter table sc.project_locations alter column common_locations_id set not null; -alter table sc.project_locations alter column sc_projects_id set not null; -alter table sc.language_engagements alter column sc_projects_id set not null; -alter table sc.language_engagements alter column language_common_languages_id set not null; -alter table sc.language_engagements alter column change_to_plan set not null; -alter table sc.products alter column name set not null; -alter table sc.products alter column change_to_plan set not null; -alter table sc.product_scripture_references alter column sc_products_id set not null; -alter table sc.product_scripture_references alter column common_scripture_references_id set not null; -alter table sc.product_scripture_references alter column change_to_plan set not null; -alter table sc.internship_engagements alter column sc_projects_id set not null; -alter table sc.internship_engagements alter column change_to_plan set not null; -alter table sc.ceremonies alter column ethnologue set not null; diff --git a/src/core/postgres/sql/change-scripts/sil.v1.sql b/src/core/postgres/sql/change-scripts/sil.v1.sql deleted file mode 100644 index cfa5091971..0000000000 --- a/src/core/postgres/sql/change-scripts/sil.v1.sql +++ /dev/null @@ -1,274 +0,0 @@ --- sil tables are copied from SIL schema docs and adorned with columns this system needs --- https://www.ethnologue.com/codes/code-table-structure --- http://www.ethnologue.com/sites/default/files/Ethnologue-19-Global%20Dataset%20Doc.pdf - -create schema sil; - -create type sil.lang_status_type as enum ( - 'L', -- L(iving) - 'X' -- (e)X(tinct) -); - -CREATE TABLE sil.language_codes ( - id varchar(32) primary key default common.nanoid(), - - lang char(3) not null, -- Three-letter code - country char(2) not null, -- Main country where used - lang_status sil.lang_status_type not null, - name varchar(75) not null, -- Primary name in that country - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -CREATE TABLE sil.country_codes ( - id varchar(32) primary key default common.nanoid(), - - country char(2) not null, -- Two-letter code from ISO3166 - name varchar(75) not null, -- Country name - area varchar(10) not null, -- World area - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sil.language_name_type as enum ( - 'L', -- L(anguage) - 'LA', -- LA(lternate) - 'D', -- D(ialect) - 'DA', -- DA(lternate) - 'LP', -- LP (a pejorative alternate) - 'DP' -- DP (a pejorative alternate) -); - -CREATE TABLE sil.language_index ( - id varchar(32) primary key not null references common.languages(id), - - lang char(3) not null, -- Three-letter code for language_common_languages_id - country char(2) not null, -- Country where this name is used - name_type sil.language_name_type not null, - name varchar(75) not null, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sil.iso_639_3_scope_options as enum ( - 'I', -- Individual - 'M', -- Macrolanguage - 'S' -- Special -); - -create type sil.iso_639_3_type_options as enum ( - 'A', -- Ancient - 'C', -- Constructed - 'E', -- Extinct - 'H', -- Historical - 'L', -- Living - 'S' -- Special -); - -CREATE TABLE sil.iso_639_3 ( - id varchar(32) primary key default common.nanoid(), - - _id char(3) not null, -- three letter 639-3 identifier - part_2b char(3), -- equivalent 639-2 identifier of the bibliographic applications code set, if there is one - part_2t char(3), -- equivalent 639-2 identifier of the terminology applications code set, if there is one - part_1 char(2), -- equivalent 639-1 identifier, if there is one - scope sil.iso_639_3_scope_options not null, - type sil.iso_639_3_type_options not null, - ref_name varchar(150) not null, -- reference language_common_languages_id name - comment varchar(150), -- comment relating to one or more of the columns - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -CREATE TABLE sil.iso_639_3_names ( - id varchar(32) primary key default common.nanoid(), - - _id char(3) not null, -- three letter 639-3 identifier - print_name varchar(75) not null, -- one of the names associated with this identifier - inverted_name varchar(75) not null, -- the inverted form of this print_name form - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sil.iso_639_3_status_options as enum ( - 'A', -- Active - 'R' -- Retired -); - -CREATE TABLE sil.iso_639_3_macrolanguages ( - id varchar(32) primary key default common.nanoid(), - - m_id char(3) not null, -- the identifier for a macrolanguage - i_id char(3) not null, -- the identifier for an individual language_common_languages_id that is a member of the macrolanguage - i_status sil.iso_639_3_status_options not null, -- indicating the status of the individual code element - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create type sil.iso_639_3_retirement_reason_options as enum ( - 'C', -- Change - 'D', -- Duplicate - 'N', -- Non-existent - 'S', -- Split - 'M' -- Merge -); - -CREATE TABLE sil.iso_639_3_retirements ( - id varchar(32) primary key default common.nanoid(), - - _id char(3) not null, -- three letter 639-3 identifier - ref_name varchar(150) not null, -- reference name of the language_common_languages_id - ret_reason sil.iso_639_3_retirement_reason_options, -- code for retirement - change_to char(3), -- in the cases of C, D, and M, the identifier to which all instances of this id should be changed - ret_remedy varchar(300), -- the instructions for updating an instance of the retired (split) identifier - effective timestamp not null, -- the date the retirement became effective - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -CREATE TABLE sil.table_of_countries ( - id varchar(32) primary key default common.nanoid(), - - country_code char(2), - country_name varchar(40), - languages int, - indigenous int, - established int, - unestablished int, - diversity decimal, - included int, - sum_of_populations int, - mean int, - median int, - population int, - literacy_rate decimal, - conventions int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -CREATE TABLE sil.table_of_languages ( - id varchar(32) primary key default common.nanoid(), - - iso_639 char(3), - language_name varchar(50), - uninverted_name varchar(50), - country_code char(2), - country_name varchar(40), - region_code char(3), - region_name varchar(30), - area varchar(8), - l1_users int, - digits int, - all_users int, - countries int, - family varchar(30), - classification varchar(250), - latitude decimal, - longitude decimal, - egids varchar(3), - is_written char(1), - institutional int, - developing int, - vigorous int, - in_trouble int, - dying int, - extinct int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -CREATE TABLE sil.table_of_languages_in_country ( - id varchar(32) primary key default common.nanoid(), - - iso_639 char(3), - language_name varchar(50), - uninverted_name varchar(50), - country_code char(2), - country_name varchar(40), - region_code char(3), - region_name varchar(30), - area varchar(8), - is_primary char(1), - is_indigenous char(1), - is_established char(1), - all_users int, - l1_users int, - l2_users int, - family varchar(30), - egids varchar(3), - function_code varchar(3), - function_label varchar(42), - institutional int, - developing int, - vigorous int, - in_trouble int, - dying int, - extinct int, - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - --- todo Ken to give additional SIL tables - -insert into admin_table_name_enum(value) values - ('sil_country_codes'), - ('sil_language_codes'), - ('sil_language_index'), - ('sil_iso_639_3'), - ('sil_iso_639_3_names'), - ('sil_iso_639_3_macrolanguages'), - ('sil_iso_639_3_retirements'), - ('sil_table_of_countries'), - ('sil_table_of_languages'), - ('sil_table_of_languages_in_country'); diff --git a/src/core/postgres/sql/change-scripts/up.v1.sql b/src/core/postgres/sql/change-scripts/up.v1.sql deleted file mode 100644 index 2981d72d22..0000000000 --- a/src/core/postgres/sql/change-scripts/up.v1.sql +++ /dev/null @@ -1,45 +0,0 @@ --- PRAYER -------------------------------------------------------------- -create schema if not exists up; - -create type up.prayer_type as enum ( - 'Request', - 'Update', - 'Celebration' -); - -create table up.prayer_requests( - id varchar(32) primary key default common.nanoid(), - - request_common_languages_id varchar(32) references common.languages(id), - target_common_languages_id varchar(32) references common.languages(id), - sensitivity common.sensitivity default 'High', - organization_name varchar(64), - parent_up_prayer_requests_id varchar(32) references up.prayer_requests(id), - translator_admin_people_id varchar(32) references admin.people(id), - common_locations_id varchar(64), - title varchar(64) not null, - content text not null, - reviewed bool default false, - prayer_type up.prayer_type default 'Request', - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); - -create table up.prayer_notifications( - id varchar(32) primary key default common.nanoid(), - - request_up_prayer_requests_id varchar(32) references up.prayer_requests(id), - admin_people_id varchar(32) unique references admin.people(id), - - created_at timestamp not null default CURRENT_TIMESTAMP, - created_by_admin_people_id varchar(32) not null references admin.people(id), - modified_at timestamp not null default CURRENT_TIMESTAMP, - modified_by_admin_people_id varchar(32) not null references admin.people(id), - owning_person_admin_people_id varchar(32) not null references admin.people(id), - owning_group_admin_groups_id varchar(32) not null references admin.groups(id) -); diff --git a/src/core/postgres/sql/migration/ethnologue.migration.sql b/src/core/postgres/sql/migration/ethnologue.migration.sql deleted file mode 100644 index b95edaffc3..0000000000 --- a/src/core/postgres/sql/migration/ethnologue.migration.sql +++ /dev/null @@ -1,92 +0,0 @@ -CREATE OR REPLACE PROCEDURE sc.sc_migrate_ethnologue( - in pIso_639 VARCHAR(3), - in pLanguage_name varchar(64), - in pPopulation int, - in pProvisional_code varchar(32), - in pSensitivity common.sensitivity, - inout error_type varchar(32) default 'UnknownError' -) -LANGUAGE PLPGSQL -AS $$ -DECLARE - vLangId int; -BEGIN - -- look up the iso, create if not found - select id - from sc.ethnologue - into vLangId - where iso_639 = pIso_639; - - if found then - -- update each cell only if there is a diff - update sc.ethnologue - set language_name = pLanguage_name, - modified_at = CURRENT_TIMESTAMP - where iso_639 = pIso_639 and - ( - (language_name != pLanguage_name) - OR - (language_name IS NULL AND pLanguage_name IS NOT NULL) - OR - (language_name IS NOT NULL AND pLanguage_name IS NULL) - ); - - update sc.ethnologue - set population = pPopulation, - modified_at = CURRENT_TIMESTAMP - where iso_639 = pIso_639 and - ( - (population != pPopulation) - OR - (population IS NULL AND pPopulation IS NOT NULL) - OR - (population IS NOT NULL AND pPopulation IS NULL) - ); - - update sc.ethnologue - set provisional_code = pProvisional_code, - modified_at = CURRENT_TIMESTAMP - where iso_639 = pIso_639 and - ( - (provisional_code != pProvisional_code) - OR - (provisional_code IS NULL AND pProvisional_code IS NOT NULL) - OR - (provisional_code IS NOT NULL AND pProvisional_code IS NULL) - ); - - update sc.ethnologue - set sensitivity = pSensitivity, - modified_at = CURRENT_TIMESTAMP - where iso_639 = pIso_639 and - sensitivity != pSensitivity; - - error_type := 'NoError'; - - else - insert into sc.ethnologue( - iso_639, - language_name, - population, - provisional_code, - sensitivity, - created_by, - modified_by, - owning_person, - owning_group - ) values ( - pIso_639, - pLanguage_name, - pPopulation, - pProvisional_code, - pSensitivity, - 1, - 1, - 1, - 1 - ); - - error_type := 'NoError'; - end if; - -END; $$; diff --git a/src/core/postgres/sql/migration/language.migration.sql b/src/core/postgres/sql/migration/language.migration.sql deleted file mode 100644 index b63b6f67e8..0000000000 --- a/src/core/postgres/sql/migration/language.migration.sql +++ /dev/null @@ -1,219 +0,0 @@ -CREATE OR REPLACE PROCEDURE sc.sc_migrate_language( - in pIso_639 char(3), - in pNeo4j_id VARCHAR(32), - in pName varchar(255), - in pDisplay_name varchar(255), - in pDisplay_name_pronunciation varchar(255), - in pIs_dialect bool, - in pPopulation_override int, - in pRegistry_of_dialects_code varchar(32), - in pIs_least_of_these bool, - in pLeast_of_these_reason varchar(255), - in pSign_language_code varchar(32), - in pSponsor_estimated_end_date timestamp, - in pSensitivity common.sensitivity, - in pIs_sign_language bool, - in pHas_external_first_scripture bool, - in pTags text[], - in pPreset_inventory bool, - inout error_type varchar(32) default 'UnknownError' -) -LANGUAGE PLPGSQL -AS $$ -DECLARE - vLangId int; - l_eth int; -BEGIN - select id - from sc.languages - into vLangId - where neo4j_id = pNeo4j_id; - - if found then - -- update each cell only if there is a diff - update sc.languages - set name = pName, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - name != pName; - - update sc.languages - set display_name = pDisplay_name, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - display_name != pDisplay_name; - - update sc.languages - set display_name_pronunciation = pDisplay_name_pronunciation, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - ( - (display_name_pronunciation != pDisplay_name_pronunciation) - OR - (display_name_pronunciation IS NULL AND pDisplay_name_pronunciation IS NOT NULL) - OR - (display_name_pronunciation IS NOT NULL AND pDisplay_name_pronunciation IS NULL ) - ); - - update sc.languages - set tags = pTags, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - tags != pTags; - - update sc.languages - set preset_inventory = pPreset_inventory, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - preset_inventory != pPreset_inventory; - - update sc.languages - set is_dialect = pIs_dialect, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - is_dialect != pIs_dialect; - - update sc.languages - set is_sign_language = pIs_sign_language, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - is_sign_language != pIs_sign_language; - - - update sc.languages - set is_least_of_these = pIs_least_of_these, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - is_least_of_these != pIs_least_of_these; - - - - update sc.languages - set least_of_these_reason = pLeast_of_these_reason, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - ( - (least_of_these_reason != pLeast_of_these_reason) - OR - (least_of_these_reason IS NULL AND pLeast_of_these_reason IS NOT NULL) - OR - (least_of_these_reason IS NOT NULL AND pLeast_of_these_reason IS NULL) - ); - - update sc.languages - set population_override = pPopulation_override, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - ( - (population_override != pPopulation_override) - OR - (population_override IS NULL AND pPopulation_override IS NOT NULL) - OR - (population_override IS NOT NULL AND pPopulation_override IS NULL) - ); - - update sc.languages - set registry_of_dialects_code = pRegistry_of_dialects_code, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - ( - (registry_of_dialects_code != pRegistry_of_dialects_code) - OR - (registry_of_dialects_code IS NULL AND pRegistry_of_dialects_code IS NOT NULL) - OR - (registry_of_dialects_code IS NOT NULL AND pRegistry_of_dialects_code IS NULL) - ); - - update sc.languages - set sensitivity = pSensitivity, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - sensitivity != pSensitivity; - - update sc.languages - set sign_language_code = pSign_language_code, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - ( - (sign_language_code != pSign_language_code) - OR - (sign_language_code IS NULL AND pSign_language_code IS NOT NULL) - OR - (sign_language_code IS NOT NULL AND pSign_language_code IS NULL) - ); - - update sc.languages - set sponsor_estimated_end_date = pSponsor_estimated_end_date, - modified_at = CURRENT_TIMESTAMP - where neo4j_id = pNeo4j_id and - ( - (sponsor_estimated_end_date != pSponsor_estimated_end_date) - OR - (sponsor_estimated_end_date IS NULL AND pSponsor_estimated_end_date IS NOT NULL) - OR - (sponsor_estimated_end_date IS NOT NULL AND pSponsor_estimated_end_date IS NULL) - ); - error_type := 'NoError'; - - else - insert into sc.languages( - neo4j_id, - name, - display_name, - display_name_pronunciation, - tags, - preset_inventory, - is_dialect, - is_sign_language, - is_least_of_these, - least_of_these_reason, - population_override, - registry_of_dialects_code, - sensitivity, - sign_language_code, - sponsor_estimated_end_date, - created_by, - modified_by, - owning_person, - owning_group - ) values ( - pNeo4j_id, - pName, - pDisplay_name, - pDisplay_name_pronunciation, - pTags, - pPreset_inventory, - pIs_dialect, - pIs_sign_language, - pIs_least_of_these, - pLeast_of_these_reason, - pPopulation_override, - pRegistry_of_dialects_code, - pSensitivity, - pSign_language_code, - pSponsor_estimated_end_date, - 1, - 1, - 1, - 1 - ); - error_type := 'NoError'; - end if; - - -- update the "relationship" props. - SELECT ethnologue INTO l_eth FROM sc.languages WHERE ethnologue IS NULL and neo4j_id = pNeo4j_id; - if found then - WITH eth AS (select id from sc.ethnologue where iso_639 = pIso_639) - update sc.languages - set ethnologue = eth.id - FROM eth - WHERE neo4j_id = pNeo4j_id; - else - WITH eth AS (select id from sc.ethnologue where iso_639 = pIso_639) - update sc.languages - set ethnologue = eth.id - FROM eth - WHERE neo4j_id = pNeo4j_id - AND ethnologue != eth.id; - END IF; -END; $$; diff --git a/src/core/postgres/sql/migration/language_index.migration.sql b/src/core/postgres/sql/migration/language_index.migration.sql deleted file mode 100644 index 237c67c417..0000000000 --- a/src/core/postgres/sql/migration/language_index.migration.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE OR REPLACE PROCEDURE sil.sil_migrate_language_index( - in pLang VARCHAR(3), - in pCountry VARCHAR(2), - in pNameType VARCHAR(2), - in pName VARCHAR(75) -) -LANGUAGE PLPGSQL -AS $$ -DECLARE - vCommonId varchar(64); - vPersonId varchar(64); - vGroupId varchar(64); -BEGIN - select id from admin.people where sensitivity_clearance = 'High' into vPersonId; - SELECT id FROM admin.groups INTO vGroupId WHERE name='Administrators'; - - if vPersonId is not null then - insert into common.languages(created_by, modified_by, owning_person, owning_group) - values (vPersonId::varchar(32), vPersonId::varchar(32), vPersonId::varchar(32), vGroupId::varchar(32)) - returning id - into vCommonId; - - insert into sil.language_index(id, lang, country, name_type, name, created_by, modified_by, owning_person, owning_group) - values (vCommonId::varchar(32), pLang, pCountry, pNameType::sil.language_name_type, pName, vPersonId::varchar(32), vPersonId::varchar(32), vPersonId::varchar(32), vGroupId::varchar(32)); - - end if; - -END; $$; diff --git a/src/core/postgres/transaction.decorator.ts b/src/core/postgres/transaction.decorator.ts deleted file mode 100644 index ebd56ee079..0000000000 --- a/src/core/postgres/transaction.decorator.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Inject } from '@nestjs/common'; -import { Pg } from './pg.service'; - -type AsyncFn = (...args: any[]) => Promise; - -const PgKey = Symbol('PgForTransaction'); - -/** - * Run all {@link Pg.query} calls inside a transaction with the same single client. - * - * Client is acquired lazily, so this will do nothing until query() is called. - * - * This is just a shortcut for calling {@link Pg.inTx}. - */ -export const PgTransaction = - (): MethodDecorator => - ( - target: any, - methodName: string | symbol, - theDescriptor: TypedPropertyDescriptor, - ) => { - // Use property-based injection to get access to the Pg object at a known location. - if (target[PgKey] === undefined) { - Inject(Pg)(target, PgKey); - // ensure prop injection is only done once. - target[PgKey] = null; - } - - // @ts-expect-error cannot enforce type of decorated method to be async, - // but we still expect it. - const descriptor = theDescriptor as TypedPropertyDescriptor; - - // Wrap the method in a inTx call - const origMethod = descriptor.value!; - descriptor.value = async function (...args: any[]) { - // @ts-expect-error this works but TS still has problems with indexing on symbols - const pg: Pg = this[PgKey]; - return await pg.inTx(() => origMethod.apply(this, args)); - }; - }; diff --git a/yarn.lock b/yarn.lock index 143d65aab6..d59b179019 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3592,17 +3592,6 @@ __metadata: languageName: node linkType: hard -"@types/pg@npm:^8.10.2": - version: 8.10.2 - resolution: "@types/pg@npm:8.10.2" - dependencies: - "@types/node": "*" - pg-protocol: "*" - pg-types: ^4.0.1 - checksum: 49da89f64cec1bd12a3fbc0c72b17d685c2fee579726a529f62fcab395dbc5696d80455073409947a577164b3c53a90181a331e4a5d9357679f724d4ce37f4b9 - languageName: node - linkType: hard - "@types/prismjs@npm:^1.26.0": version: 1.26.0 resolution: "@types/prismjs@npm:1.26.0" @@ -4569,13 +4558,6 @@ __metadata: languageName: node linkType: hard -"buffer-writer@npm:2.0.0": - version: 2.0.0 - resolution: "buffer-writer@npm:2.0.0" - checksum: 11736b48bb75106c52ca8ec9f025e7c1b3b25ce31875f469d7210eabd5c576c329e34f6b805d4a8d605ff3f0db1e16342328802c4c963e9c826b0e43a4e631c2 - languageName: node - linkType: hard - "buffer@npm:^5.5.0": version: 5.7.1 resolution: "buffer@npm:5.7.1" @@ -5269,7 +5251,6 @@ __metadata: "@types/luxon": ^3.3.1 "@types/node": ^18.17.7 "@types/pako": ^2.0.0 - "@types/pg": ^8.10.2 "@types/prismjs": ^1.26.0 "@types/react": ^18.2.20 "@types/stack-trace": ^0.0.30 @@ -5322,7 +5303,6 @@ __metadata: nestjs-console: ^9.0.0 p-retry: ^5.1.2 pako: ^2.1.0 - pg: ^8.11.3 pkg-up: ^4.0.0 plur: ^5.1.0 prismjs-terminal: ^1.2.2 @@ -10375,13 +10355,6 @@ __metadata: languageName: node linkType: hard -"obuf@npm:~1.1.2": - version: 1.1.2 - resolution: "obuf@npm:1.1.2" - checksum: 41a2ba310e7b6f6c3b905af82c275bf8854896e2e4c5752966d64cbcd2f599cfffd5932006bcf3b8b419dfdacebb3a3912d5d94e10f1d0acab59876c8757f27f - languageName: node - linkType: hard - "on-finished@npm:2.4.1": version: 2.4.1 resolution: "on-finished@npm:2.4.1" @@ -10582,13 +10555,6 @@ __metadata: languageName: node linkType: hard -"packet-reader@npm:1.0.0": - version: 1.0.0 - resolution: "packet-reader@npm:1.0.0" - checksum: 0b7516f0cbf3e322aad591bed29ba544220088c53943145c0d9121a6f59182ad811f7fd6785a8979a34356aca69d97653689029964c5998dc02645633d88ffd7 - languageName: node - linkType: hard - "pako@npm:^2.1.0": version: 2.1.0 resolution: "pako@npm:2.1.0" @@ -10742,111 +10708,6 @@ __metadata: languageName: node linkType: hard -"pg-cloudflare@npm:^1.1.1": - version: 1.1.1 - resolution: "pg-cloudflare@npm:1.1.1" - checksum: 32aac06b5dc4588bbf78801b6267781bc7e13be672009df949d08e9627ba9fdc26924916665d4de99d47f9b0495301930547488dad889d826856976c7b3f3731 - languageName: node - linkType: hard - -"pg-connection-string@npm:^2.6.2": - version: 2.6.2 - resolution: "pg-connection-string@npm:2.6.2" - checksum: 22265882c3b6f2320785378d0760b051294a684989163d5a1cde4009e64e84448d7bf67d9a7b9e7f69440c3ee9e2212f9aa10dd17ad6773f6143c6020cebbcb5 - languageName: node - linkType: hard - -"pg-int8@npm:1.0.1": - version: 1.0.1 - resolution: "pg-int8@npm:1.0.1" - checksum: a1e3a05a69005ddb73e5f324b6b4e689868a447c5fa280b44cd4d04e6916a344ac289e0b8d2695d66e8e89a7fba023affb9e0e94778770ada5df43f003d664c9 - languageName: node - linkType: hard - -"pg-numeric@npm:1.0.2": - version: 1.0.2 - resolution: "pg-numeric@npm:1.0.2" - checksum: 8899f8200caa1744439a8778a9eb3ceefb599d893e40a09eef84ee0d4c151319fd416634a6c0fc7b7db4ac268710042da5be700b80ef0de716fe089b8652c84f - languageName: node - linkType: hard - -"pg-pool@npm:^3.6.1": - version: 3.6.1 - resolution: "pg-pool@npm:3.6.1" - peerDependencies: - pg: ">=8.0" - checksum: 8a6513e6f74a794708c9dd16d2ccda0debadc56435ec2582de2b2e35b01315550c5dab8a0a9a2a16f4adce45523228f5739940fb7687ec7e9c300f284eb08fd1 - languageName: node - linkType: hard - -"pg-protocol@npm:*, pg-protocol@npm:^1.6.0": - version: 1.6.0 - resolution: "pg-protocol@npm:1.6.0" - checksum: e12662d2de2011e0c3a03f6a09f435beb1025acdc860f181f18a600a5495dc38a69d753bbde1ace279c8c442536af9c1a7c11e1d0fe3fad3aa1348b28d9d2683 - languageName: node - linkType: hard - -"pg-types@npm:^2.1.0": - version: 2.2.0 - resolution: "pg-types@npm:2.2.0" - dependencies: - pg-int8: 1.0.1 - postgres-array: ~2.0.0 - postgres-bytea: ~1.0.0 - postgres-date: ~1.0.4 - postgres-interval: ^1.1.0 - checksum: bf4ec3f594743442857fb3a8dfe5d2478a04c98f96a0a47365014557cbc0b4b0cee01462c79adca863b93befbf88f876299b75b72c665b5fb84a2c94fbd10316 - languageName: node - linkType: hard - -"pg-types@npm:^4.0.1": - version: 4.0.1 - resolution: "pg-types@npm:4.0.1" - dependencies: - pg-int8: 1.0.1 - pg-numeric: 1.0.2 - postgres-array: ~3.0.1 - postgres-bytea: ~3.0.0 - postgres-date: ~2.0.1 - postgres-interval: ^3.0.0 - postgres-range: ^1.1.1 - checksum: 05258ef2f27a75f1bf4e243f36bb749f85148339d3be818147bcc4aebe019ad7589a6869150713140250d81e5a46ec25dc6e0a031ea77e23db5ca232a0d7a3dc - languageName: node - linkType: hard - -"pg@npm:^8.11.3": - version: 8.11.3 - resolution: "pg@npm:8.11.3" - dependencies: - buffer-writer: 2.0.0 - packet-reader: 1.0.0 - pg-cloudflare: ^1.1.1 - pg-connection-string: ^2.6.2 - pg-pool: ^3.6.1 - pg-protocol: ^1.6.0 - pg-types: ^2.1.0 - pgpass: 1.x - peerDependencies: - pg-native: ">=3.0.1" - dependenciesMeta: - pg-cloudflare: - optional: true - peerDependenciesMeta: - pg-native: - optional: true - checksum: 8af9468b8969fa0d73a6b349216c8cbc953d938fcae5594f2d24043060e9226a072c8085fc4230172b5576fcab4c39c8563c655f271dc2a9209b6ad5370cafe5 - languageName: node - linkType: hard - -"pgpass@npm:1.x": - version: 1.0.5 - resolution: "pgpass@npm:1.0.5" - dependencies: - split2: ^4.1.0 - checksum: 947ac096c031eebdf08d989de2e9f6f156b8133d6858c7c2c06c041e1e71dda6f5f3bad3c0ec1e96a09497bbc6ef89e762eefe703b5ef9cb2804392ec52ec400 - languageName: node - linkType: hard - "picocolors@npm:^1.0.0": version: 1.0.0 resolution: "picocolors@npm:1.0.0" @@ -10929,73 +10790,6 @@ __metadata: languageName: node linkType: hard -"postgres-array@npm:~2.0.0": - version: 2.0.0 - resolution: "postgres-array@npm:2.0.0" - checksum: 0e1e659888147c5de579d229a2d95c0d83ebdbffc2b9396d890a123557708c3b758a0a97ed305ce7f58edfa961fa9f0bbcd1ea9f08b6e5df73322e683883c464 - languageName: node - linkType: hard - -"postgres-array@npm:~3.0.1": - version: 3.0.2 - resolution: "postgres-array@npm:3.0.2" - checksum: 5955f9dffeb6fa960c1a0b04fd4b2ba16813ddb636934ad26f902e4d76a91c0b743dcc6edc4cffc52deba7d547505e0020adea027c1d50a774f989cf955420d1 - languageName: node - linkType: hard - -"postgres-bytea@npm:~1.0.0": - version: 1.0.0 - resolution: "postgres-bytea@npm:1.0.0" - checksum: d844ae4ca7a941b70e45cac1261a73ee8ed39d72d3d74ab1d645248185a1b7f0ac91a3c63d6159441020f4e1f7fe64689ac56536a307b31cef361e5187335090 - languageName: node - linkType: hard - -"postgres-bytea@npm:~3.0.0": - version: 3.0.0 - resolution: "postgres-bytea@npm:3.0.0" - dependencies: - obuf: ~1.1.2 - checksum: 5f917a003fcaa0df7f285e1c37108ad474ce91193466b9bd4bcaecef2cdea98ca069c00aa6a8dbe6d2e7192336cadc3c9b36ae48d1555a299521918e00e2936b - languageName: node - linkType: hard - -"postgres-date@npm:~1.0.4": - version: 1.0.7 - resolution: "postgres-date@npm:1.0.7" - checksum: 5745001d47e51cd767e46bcb1710649cd705d91a24d42fa661c454b6dcbb7353c066a5047983c90a626cd3bbfea9e626cc6fa84a35ec57e5bbb28b49f78e13ed - languageName: node - linkType: hard - -"postgres-date@npm:~2.0.1": - version: 2.0.1 - resolution: "postgres-date@npm:2.0.1" - checksum: 0304bf8641a01412e4f5c3a374604e2e3dbc9dbee71d30df12fe60b32560c5674f887c2d15bafa2996f3b618b617398e7605f0e3669db43f31e614dfe69f8de7 - languageName: node - linkType: hard - -"postgres-interval@npm:^1.1.0": - version: 1.2.0 - resolution: "postgres-interval@npm:1.2.0" - dependencies: - xtend: ^4.0.0 - checksum: 746b71f93805ae33b03528e429dc624706d1f9b20ee81bf743263efb6a0cd79ae02a642a8a480dbc0f09547b4315ab7df6ce5ec0be77ed700bac42730f5c76b2 - languageName: node - linkType: hard - -"postgres-interval@npm:^3.0.0": - version: 3.0.0 - resolution: "postgres-interval@npm:3.0.0" - checksum: c7a1cf006de97de663b6b8c4d2b167aa9909a238c4866a94b15d303762f5ac884ff4796cd6e2111b7f0a91302b83c570453aa8506fd005b5a5d5dfa87441bebc - languageName: node - linkType: hard - -"postgres-range@npm:^1.1.1": - version: 1.1.3 - resolution: "postgres-range@npm:1.1.3" - checksum: bf7e194a18c490d02bda0bd02035a8da454d8fd2b22c55d3d03f185c038b2a6f52d0804417d8090864afefc2b7ed664b2d12c2454a4a0f545dcbbb86488fbdf1 - languageName: node - linkType: hard - "prelude-ls@npm:^1.2.1": version: 1.2.1 resolution: "prelude-ls@npm:1.2.1" @@ -11952,13 +11746,6 @@ __metadata: languageName: node linkType: hard -"split2@npm:^4.1.0": - version: 4.2.0 - resolution: "split2@npm:4.2.0" - checksum: 05d54102546549fe4d2455900699056580cca006c0275c334611420f854da30ac999230857a85fdd9914dc2109ae50f80fda43d2a445f2aa86eccdc1dfce779d - languageName: node - linkType: hard - "sprintf-js@npm:~1.0.2": version: 1.0.3 resolution: "sprintf-js@npm:1.0.3"