mirror of
https://github.com/colanode/colanode.git
synced 2025-12-25 16:09:31 +01:00
Refactor some columns
This commit is contained in:
@@ -51,7 +51,6 @@ const createAccountsTable: Migration = {
|
||||
.addColumn('email', 'text', (col) => col.notNull())
|
||||
.addColumn('avatar', 'text')
|
||||
.addColumn('token', 'text', (col) => col.notNull())
|
||||
.addColumn('status', 'text', (col) => col.defaultTo('active').notNull())
|
||||
.execute();
|
||||
},
|
||||
down: async (db) => {
|
||||
|
||||
@@ -23,7 +23,6 @@ interface AccountTable {
|
||||
avatar: ColumnType<string | null, string | null, string | null>;
|
||||
token: ColumnType<string, string, string>;
|
||||
device_id: ColumnType<string, string, never>;
|
||||
status: ColumnType<string, string, string>;
|
||||
}
|
||||
|
||||
export type SelectAccount = Selectable<AccountTable>;
|
||||
|
||||
@@ -13,7 +13,7 @@ const createUsersTable: Migration = {
|
||||
.addColumn('role', 'text', (col) => col.notNull())
|
||||
.addColumn('storage_limit', 'integer', (col) => col.notNull())
|
||||
.addColumn('max_file_size', 'integer', (col) => col.notNull())
|
||||
.addColumn('status', 'text', (col) => col.notNull())
|
||||
.addColumn('status', 'integer', (col) => col.notNull())
|
||||
.addColumn('created_at', 'text', (col) => col.notNull())
|
||||
.addColumn('updated_at', 'text')
|
||||
.addColumn('version', 'integer')
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
WorkspaceRole,
|
||||
MessageType,
|
||||
TransactionOperation,
|
||||
UserStatus,
|
||||
} from '@colanode/core';
|
||||
import { ColumnType, Insertable, Selectable, Updateable } from 'kysely';
|
||||
|
||||
@@ -21,7 +22,7 @@ interface UserTable {
|
||||
role: ColumnType<WorkspaceRole, WorkspaceRole, WorkspaceRole>;
|
||||
storage_limit: ColumnType<bigint, bigint, bigint>;
|
||||
max_file_size: ColumnType<bigint, bigint, bigint>;
|
||||
status: ColumnType<string, string, never>;
|
||||
status: ColumnType<UserStatus, UserStatus, UserStatus>;
|
||||
created_at: ColumnType<string, string, never>;
|
||||
updated_at: ColumnType<string | null, string | null, string | null>;
|
||||
version: ColumnType<bigint, bigint, bigint>;
|
||||
|
||||
@@ -83,7 +83,6 @@ export class AccountUpdateMutationHandler
|
||||
avatar: updatedAccount.avatar,
|
||||
deviceId: updatedAccount.device_id,
|
||||
server: updatedAccount.server,
|
||||
status: updatedAccount.status,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ export class AccountListQueryHandler
|
||||
return databaseService.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('status', '=', 'active')
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ class AccountService {
|
||||
email: output.account.email,
|
||||
token: output.token,
|
||||
server,
|
||||
status: 'active',
|
||||
})
|
||||
.executeTakeFirst();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SyncUserData } from '@colanode/core';
|
||||
import { SyncUserData, UserStatus } from '@colanode/core';
|
||||
|
||||
import { mapUser } from '@/main/utils';
|
||||
import { databaseService } from '@/main/data/database-service';
|
||||
@@ -23,7 +23,7 @@ class UserService {
|
||||
version: BigInt(user.version),
|
||||
created_at: user.createdAt,
|
||||
updated_at: user.updatedAt,
|
||||
status: 'active',
|
||||
status: UserStatus.Active,
|
||||
custom_name: user.customName,
|
||||
custom_avatar: user.customAvatar,
|
||||
})
|
||||
|
||||
@@ -234,7 +234,6 @@ export const mapAccount = (row: SelectAccount): Account => {
|
||||
deviceId: row.device_id,
|
||||
email: row.email,
|
||||
token: row.token,
|
||||
status: row.status,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,5 @@ export type Account = {
|
||||
avatar?: string | null;
|
||||
token: string;
|
||||
deviceId: string;
|
||||
status: string;
|
||||
server: string;
|
||||
};
|
||||
|
||||
@@ -70,6 +70,7 @@ export class UserSynchronizer extends BaseSynchronizer<SyncUsersInput> {
|
||||
createdAt: user.created_at.toISOString(),
|
||||
updatedAt: user.updated_at?.toISOString() ?? null,
|
||||
version: user.version.toString(),
|
||||
status: user.status,
|
||||
}));
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { WorkspaceRole } from '../types/workspaces';
|
||||
import { UserStatus, WorkspaceRole } from '../types/workspaces';
|
||||
|
||||
export type SyncUsersInput = {
|
||||
type: 'users';
|
||||
@@ -18,6 +18,7 @@ export type SyncUserData = {
|
||||
createdAt: string;
|
||||
updatedAt: string | null;
|
||||
version: string;
|
||||
status: UserStatus;
|
||||
};
|
||||
|
||||
declare module '@colanode/core' {
|
||||
|
||||
Reference in New Issue
Block a user