Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
import { SQL, sql } from 'drizzle-orm'
import { bigint, boolean, datetime, mysqlTable, uniqueIndex, varchar } from 'drizzle-orm/mysql-core'
import { pathVarchar } from '../../../infrastructure/database/columns.js'
import { SPACE_PERMS_SEP } from '../constants/spaces.js'
/*
alias: used to navigate over api & webdav, must be unique
name: set by user and showed on web
storageQuota:
0 : no storage
null : unlimited
other: limited to value
*/
export const spaces = mysqlTable(
'spaces',
{
id: bigint('id', { mode: 'number', unsigned: true }).autoincrement().primaryKey(),
alias: pathVarchar('alias', { length: 255 }).notNull(),
name: pathVarchar('name', { length: 255 }).notNull(),
description: varchar('description', { length: 255 }),
enabled: boolean('enabled').default(true).notNull(),
storageUsage: bigint('storageUsage', { mode: 'number', unsigned: true }).default(0).notNull(),
storageQuota: bigint('storageQuota', { mode: 'number', unsigned: true }),
storageIndexing: boolean('storageIndexing').default(true).notNull(),
createdAt: datetime('createdAt', { mode: 'date' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
modifiedAt: datetime('modifiedAt', { mode: 'date' }).default(sql`CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`),
disabledAt: datetime('disabledAt', { mode: 'date' })
},
(table) => [uniqueIndex('alias_idx').on(table.alias)]
)
export const spaceGroupConcatPermissions = (column: any): SQL<string> =>
sql`IFNULL(GROUP_CONCAT(DISTINCT(IF(${column} = '', null, ${column})) SEPARATOR ${SPACE_PERMS_SEP}), '')`