Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ RUN chown -R appuser:appuser /run
USER appuser

WORKDIR /app/backend
CMD [ "/app/backend/runner.sh" ]
ENTRYPOINT ["/app/backend/entrypoint.sh"]
CMD [ "/app/backend/runner.sh" ]
5 changes: 4 additions & 1 deletion backend/.development.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
ROCKETADMIN_COOKIE_DOMAIN=

# connection parameters to your main database
DATABASE_URL=postgres://postgres:abc123@postgres:5432/postgres
# DATABASE_URL=postgres://postgres:abc123@postgres:5432/postgres

# pglite file path, if you want to use it instead of main database
PGLITE_FOLDER_PATH=

# optional parameter. you need it if you want to use sentry service.
SENTRY_DSN=
Expand Down
2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"dependencies": {
"@amplitude/node": "1.10.2",
"@aws-sdk/lib-dynamodb": "^3.873.0",
"@electric-sql/pglite": "^0.3.8",
"@faker-js/faker": "^10.0.0",
"@nestjs/common": "11.1.6",
"@nestjs/config": "4.0.2",
Expand Down Expand Up @@ -94,6 +95,7 @@
"safe-regex2": "^5.0.0",
"secure-json-parse": "4.0.0",
"typeorm": "0.3.26",
"typeorm-pglite": "^0.3.2",
"uuid": "^11.1.0",
"validator": "^13.15.15",
"winston": "3.17.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export class ConnectionPropertiesEntity {
@Column({ default: null })
company_name: string;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
tables_audit: boolean;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
human_readable_table_names: boolean;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
allow_ai_requests: boolean;

@Column({ default: null })
Expand Down
12 changes: 6 additions & 6 deletions backend/src/entities/connection/connection.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ConnectionEntity {
@Column({ default: '' })
title?: string;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
masterEncryption: boolean;

@Column({ default: null })
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ConnectionEntity {
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
updatedAt: Date;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
ssh?: boolean;

@Column({ default: null })
Expand All @@ -84,19 +84,19 @@ export class ConnectionEntity {
@Column({ default: null })
sshUsername?: string | null;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
ssl?: boolean | null;

@Column({ default: null })
cert?: string | null;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
isTestConnection: boolean;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
azure_encryption: boolean;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
is_frozen: boolean;

@Column({ default: 0 })
Expand Down
2 changes: 1 addition & 1 deletion backend/src/entities/group/group.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class GroupEntity {
@Column()
title: string;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
isMain: boolean;

@ManyToMany((_) => PermissionEntity, (permission) => permission.groups, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class ActionEventsEntity {
})
event!: TableActionEventEnum;


@Column('enum', {
nullable: false,
enum: TableActionTypeEnum,
Expand All @@ -33,7 +32,7 @@ export class ActionEventsEntity {
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
created_at: Date;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
require_confirmation: boolean;

@ManyToOne((type) => ActionRulesEntity, (rules) => rules.table_actions, { onDelete: 'CASCADE' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class TableFieldInfoEntity {
@PrimaryGeneratedColumn('uuid')
id: string;

@Column({ default: null })
@Column({ default: null, type: 'boolean' })
allow_null: boolean;

@Column({ default: null })
Expand Down
10 changes: 5 additions & 5 deletions backend/src/entities/table-settings/table-settings.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ export class TableSettingsEntity {
@Column('varchar', { array: true, default: null })
columns_view: string[];

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
can_delete: boolean;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
can_update: boolean;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
can_add: boolean;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
allow_csv_export: boolean;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
allow_csv_import: boolean;

@Column('varchar', { array: true, default: null })
Expand Down
2 changes: 1 addition & 1 deletion backend/src/entities/user-actions/user-action.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class UserActionEntity {
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
createdAt: Date;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
mail_sent: boolean;

@OneToOne(() => UserEntity, (user) => user.user_action, { onDelete: 'CASCADE' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const userCustomRepositoryExtension: IUserRepository = {
const newUser: UserEntity = new UserEntity();
newUser.id = userData.id;
newUser.isActive = true;
newUser.gclid = userData.gclidValue;
newUser.gclid = userData.gclidValue || null;
return await this.save(newUser);
},

Expand Down
10 changes: 5 additions & 5 deletions backend/src/entities/user/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export class UserEntity {
@Column({ default: null })
name: string;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
suspended: boolean;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
isDemoAccount: boolean;

@BeforeInsert()
Expand Down Expand Up @@ -78,7 +78,7 @@ export class UserEntity {
@Column({ default: null })
gclid: string;

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
isOTPEnabled: boolean;

@Column({ default: null })
Expand Down Expand Up @@ -123,7 +123,7 @@ export class UserEntity {
@OneToMany((_) => AiResponsesToUserEntity, (response) => response.user)
ai_responses: Relation<AiResponsesToUserEntity>[];

@Column({ default: false })
@Column({ default: false, type: 'boolean' })
isActive: boolean;

@Column('enum', {
Expand All @@ -143,7 +143,7 @@ export class UserEntity {
@Column({ default: null })
samlNameId: string;

@Column({ default: true })
@Column({ default: true, type: 'boolean' })
showTestConnections: boolean;

private emailToLowerCase() {
Expand Down
41 changes: 39 additions & 2 deletions backend/src/shared/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import parse from 'pg-connection-string';
import dotenv from 'dotenv';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import { uuid_ossp } from '@electric-sql/pglite/contrib/uuid_ossp';
import { PGliteDriver } from 'typeorm-pglite';
import fs from 'fs';
import { isTest } from '../../helpers/app/is-test.js';

dotenv.config();

Expand Down Expand Up @@ -40,7 +44,38 @@ class ConfigService {
}

public getTypeOrmConfig(): DataSourceOptions {
const connectionParams = this.parseTypeORMUrl(this.getValue('DATABASE_URL'));
const pgLiteFolderPath = process.env.PGLITE_FOLDER_PATH;

let pgLiteDriver = null;
let connectionParams = {};

if (pgLiteFolderPath && pgLiteFolderPath.length > 0) {
const fullPath = isTest()
? path.join(process.cwd(), ...pgLiteFolderPath.split('/'))
: path.join(__dirname, '..', '..', '..', pgLiteFolderPath);

const resolvedPath = path.resolve(fullPath);
try {
fs.accessSync(resolvedPath, fs.constants.F_OK);
console.log('PGLite directory exists');
try {
fs.accessSync(resolvedPath, fs.constants.W_OK);
console.log('PGLite directory is writable');
} catch (writeError) {
console.warn('PGLite directory exists but may not be writable:', writeError.message);
}
} catch (error) {
console.log('PGLite directory does not exist, will be created by PGLite', error);
}

pgLiteDriver = new PGliteDriver({
extensions: { uuid_ossp },
dataDir: path.resolve(resolvedPath),
}).driver;
} else {
connectionParams = this.parseTypeORMUrl(this.getValue('DATABASE_URL'));
}

const newTypeOrmProdConfig: DataSourceOptions = {
type: 'postgres',
...connectionParams,
Expand All @@ -52,6 +87,7 @@ class ConfigService {
max: 20,
idle_in_transaction_session_timeout: 20 * 1000,
},
driver: pgLiteDriver ? pgLiteDriver : undefined,
};

const newTypeOrmTestConfig: DataSourceOptions = {
Expand All @@ -66,6 +102,7 @@ class ConfigService {
max: 2,
},
logger: 'advanced-console',
driver: pgLiteDriver ? pgLiteDriver : undefined,
};

return this.isTestEnvironment() ? newTypeOrmTestConfig : newTypeOrmProdConfig;
Expand Down Expand Up @@ -93,6 +130,6 @@ class ConfigService {
}
}

const configService = new ConfigService(process.env).ensureValues(['DATABASE_URL']);
const configService = new ConfigService(process.env).ensureValues([]);

export { configService };
3 changes: 3 additions & 0 deletions backend/src/types/pglite-contrib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '@electric-sql/pglite/contrib/uuid_ossp' {
export const uuid_ossp: any;
}
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,13 @@ __metadata:
languageName: node
linkType: hard

"@electric-sql/pglite@npm:^0.3.8":
version: 0.3.8
resolution: "@electric-sql/pglite@npm:0.3.8"
checksum: 0329f79f2b0fd0dcab48853a9db2d314f88e5e52569ec87c7ce8d30ab60c2b334aca8e90ac863ad3f54e92f7f12726f4bf79d80a02550448f83aeac2d1b5e590
languageName: node
linkType: hard

"@emnapi/core@npm:^1.4.3":
version: 1.4.3
resolution: "@emnapi/core@npm:1.4.3"
Expand Down Expand Up @@ -5638,6 +5645,7 @@ __metadata:
"@amplitude/node": 1.10.2
"@ava/typescript": 6.0.0
"@aws-sdk/lib-dynamodb": ^3.873.0
"@electric-sql/pglite": ^0.3.8
"@faker-js/faker": ^10.0.0
"@nestjs/cli": ^11.0.10
"@nestjs/common": 11.1.6
Expand Down Expand Up @@ -5726,6 +5734,7 @@ __metadata:
ts-node: ^10.9.2
tsconfig-paths: ^4.2.0
typeorm: 0.3.26
typeorm-pglite: ^0.3.2
typescript: 5.9.2
uuid: ^11.1.0
validator: ^13.15.15
Expand Down Expand Up @@ -14040,6 +14049,15 @@ __metadata:
languageName: node
linkType: hard

"typeorm-pglite@npm:^0.3.2":
version: 0.3.2
resolution: "typeorm-pglite@npm:0.3.2"
peerDependencies:
"@electric-sql/pglite": ">= 0.2.12"
checksum: 0b3a21f5ca166bc2af675e9d282340c0e2e259ad4715dbecdab8365d8b961df9b3b4f6af7604cf98f413707f9c79271f116b524a573117405c0903e543c9a512
languageName: node
linkType: hard

"typeorm@npm:0.3.26":
version: 0.3.26
resolution: "typeorm@npm:0.3.26"
Expand Down
Loading