mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
35 lines
1016 B
TypeScript
35 lines
1016 B
TypeScript
import { TenantModel } from '../System/models/TenantModel';
|
|
import { TenantAlreadyInitialized } from './exceptions/TenantAlreadyInitialized';
|
|
import { TenantAlreadySeeded } from './exceptions/TenantAlreadySeeded';
|
|
import { TenantDatabaseNotBuilt } from './exceptions/TenantDatabaseNotBuilt';
|
|
|
|
/**
|
|
* Throws error if the tenant already seeded.
|
|
* @throws {TenantAlreadySeeded}
|
|
*/
|
|
export const throwErrorIfTenantAlreadySeeded = (tenant: TenantModel) => {
|
|
if (tenant.seededAt) {
|
|
throw new TenantAlreadySeeded();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Throws error if the tenant database is not built yut.
|
|
* @param {ITenant} tenant
|
|
*/
|
|
export const throwErrorIfTenantNotBuilt = (tenant: TenantModel) => {
|
|
if (!tenant.initializedAt) {
|
|
throw new TenantDatabaseNotBuilt();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Throws error if the tenant already migrated.
|
|
* @throws {TenantAlreadyInitialized}
|
|
*/
|
|
export const throwErrorIfTenantAlreadyInitialized = (tenant: TenantModel) => {
|
|
if (tenant.initializedAt) {
|
|
throw new TenantAlreadyInitialized();
|
|
}
|
|
};
|