mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 07:12:04 +10:00
Replace space privacy with visibility
* Make creatorId nullable
This commit is contained in:
@ -13,7 +13,7 @@ import { User } from '../../user/entities/user.entity';
|
||||
import { Workspace } from '../../workspace/entities/workspace.entity';
|
||||
import { SpaceUser } from './space-user.entity';
|
||||
import { Page } from '../../page/entities/page.entity';
|
||||
import { SpacePrivacy, SpaceRole } from '../../../helpers/types/permission';
|
||||
import { SpaceVisibility, SpaceRole } from '../../../helpers/types/permission';
|
||||
import { SpaceGroup } from './space-group.entity';
|
||||
|
||||
@Entity('spaces')
|
||||
@ -34,13 +34,13 @@ export class Space {
|
||||
@Column({ length: 255, nullable: true })
|
||||
icon: string;
|
||||
|
||||
@Column({ length: 100, default: SpacePrivacy.OPEN })
|
||||
privacy: string;
|
||||
@Column({ length: 100, default: SpaceVisibility.OPEN })
|
||||
visibility: string;
|
||||
|
||||
@Column({ length: 100, default: SpaceRole.WRITER })
|
||||
defaultRole: string;
|
||||
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
creatorId: string;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
|
||||
@ -52,9 +52,9 @@ export class Workspace {
|
||||
@Column({ nullable: true, type: 'uuid' })
|
||||
creatorId: string;
|
||||
|
||||
//@ManyToOne(() => User, (user) => user.workspaces)
|
||||
// @JoinColumn({ name: 'creatorId' })
|
||||
// creator: User;
|
||||
@OneToOne(() => User)
|
||||
@JoinColumn({ name: 'creatorId' })
|
||||
creator: User;
|
||||
|
||||
@Column({ nullable: true })
|
||||
defaultSpaceId: string;
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class RenameSpacePrivacyColumn1711051968957 implements MigrationInterface {
|
||||
name = 'RenameSpacePrivacyColumn1711051968957'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "spaces" RENAME COLUMN "privacy" TO "visibility"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "spaces" RENAME COLUMN "visibility" TO "privacy"`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class WorkspaceCreatorFK1711052439145 implements MigrationInterface {
|
||||
name = 'WorkspaceCreatorFK1711052439145'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "UQ_2aab2dd12dc65eb183d99b953e0" UNIQUE ("creatorId")`);
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0"`);
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "UQ_2aab2dd12dc65eb183d99b953e0"`);
|
||||
await queryRunner.query(`ALTER TABLE "spaces" RENAME COLUMN "visibility" TO "privacy"`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class MakeSpaceCreatorIdNullable1711053025788 implements MigrationInterface {
|
||||
name = 'MakeSpaceCreatorIdNullable1711053025788'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35"`);
|
||||
await queryRunner.query(`ALTER TABLE "spaces" ALTER COLUMN "creatorId" DROP NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35"`);
|
||||
await queryRunner.query(`ALTER TABLE "spaces" ALTER COLUMN "creatorId" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,7 +10,7 @@ export enum SpaceRole {
|
||||
READER = 'reader', // can only read pages in space
|
||||
}
|
||||
|
||||
export enum SpacePrivacy {
|
||||
export enum SpaceVisibility {
|
||||
OPEN = 'open', // any workspace member can see and join.
|
||||
PRIVATE = 'private', // only added space users can see
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user