Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

feat: sandboxes

mertmitdf4b128c4fa3
diff --git a/packages/nc-gui/components/general/ShareProject.vue b/packages/nc-gui/components/general/ShareProject.vue
index b77cffddd3..7b82cdab10 100644
--- a/packages/nc-gui/components/general/ShareProject.vue
+++ b/packages/nc-gui/components/general/ShareProject.vue
@@ -12,7 +12,7 @@ const { visibility, showShareModal } = storeToRefs(useShare())
const { activeTable } = storeToRefs(useTablesStore())
-const { base, isSharedBase, isManagedAppMaster } = storeToRefs(useBase())
+const { base, isSharedBase, isManagedAppMaster, isSandbox } = storeToRefs(useBase())
const { hideSharedBaseBtn } = storeToRefs(useConfigStore())
@@ -46,7 +46,7 @@ const copySharedBase = async () => {
<template>
<div
- v-if="!isSharedBase && !isManagedAppMaster && isUIAllowed('baseShare') && visibility !== 'hidden' && (activeTable || base)"
+ v-if="!isSharedBase && !isManagedAppMaster && !isSandbox && isUIAllowed('baseShare') && visibility !== 'hidden' && (activeTable || base)"
class="nc-share-base-button flex flex-col justify-center"
data-testid="share-base-button"
:data-sharetype="visibility"
diff --git a/packages/nc-gui/components/project/View.vue b/packages/nc-gui/components/project/View.vue
index a713fa839b..b615d13d9c 100644
--- a/packages/nc-gui/components/project/View.vue
+++ b/packages/nc-gui/components/project/View.vue
@@ -259,6 +259,7 @@ onMounted(() => {
</div>
<div v-if="!showEmptySkeleton && !isMobileMode" class="flex items-center gap-2">
<SmartsheetTopbarManagedAppStatus />
+ <SmartsheetTopbarSandboxStatus />
<LazyGeneralShareProject />
</div>
</div>
diff --git a/packages/nc-gui/components/smartsheet/Topbar.vue b/packages/nc-gui/components/smartsheet/Topbar.vue
index ce0e4891f9..3482696930 100644
--- a/packages/nc-gui/components/smartsheet/Topbar.vue
+++ b/packages/nc-gui/components/smartsheet/Topbar.vue
@@ -75,6 +75,9 @@ const topbarBreadcrumbItemWidth = computed(() => {
<!-- Managed App Status -->
<LazySmartsheetTopbarManagedAppStatus v-if="!isSharedBase && !isMobileMode" />
+ <!-- Sandbox Status -->
+ <LazySmartsheetTopbarSandboxStatus v-if="!isSharedBase && !isMobileMode" />
+
<NcButton
v-if="
(appInfo.isOnPrem || isEeUI || isFeatureEnabled(FEATURE_FLAG.EXTENSIONS)) &&
diff --git a/packages/nocodb-sdk/src/lib/enums.ts b/packages/nocodb-sdk/src/lib/enums.ts
index e7b75ac1f4..3242639550 100644
--- a/packages/nocodb-sdk/src/lib/enums.ts
+++ b/packages/nocodb-sdk/src/lib/enums.ts
@@ -255,6 +255,10 @@ export enum AppEvents {
WORKFLOW_DELETE = 'workflow.delete',
WORKFLOW_DUPLICATE = 'workflow.duplicate',
WORKFLOW_EXECUTE = 'workflow.execute',
+
+ SANDBOX_CREATE = 'sandbox.create',
+ SANDBOX_DISCARD = 'sandbox.discard',
+ SANDBOX_MERGE = 'sandbox.merge',
}
export enum ClickhouseTables {
diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
index 0c2a2839a7..990bfc9074 100644
--- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
+++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
@@ -16,6 +16,7 @@ import * as nc_015_managed_apps from './v0/nc_015_managed_apps';
import * as nc_016_automation_error_notifications from './v0/nc_016_automation_error_notifications';
import * as nc_017_add_canonical_email_to_users from './v0/nc_017_add_canonical_email_to_users';
import * as nc_018_add_enabled_to_filter_exp_v2 from './v0/nc_018_add_enabled_to_filter_exp_v2';
+import * as nc_019_sandboxes from './v0/nc_019_sandboxes';
// Create a custom migration source class
export default class XcMigrationSourcev0 {
@@ -43,6 +44,7 @@ export default class XcMigrationSourcev0 {
'nc_016_automation_error_notifications',
'nc_017_add_canonical_email_to_users',
'nc_018_add_enabled_to_filter_exp_v2',
+ 'nc_019_sandboxes',
]);
}
@@ -88,6 +90,8 @@ export default class XcMigrationSourcev0 {
return nc_017_add_canonical_email_to_users;
case 'nc_018_add_enabled_to_filter_exp_v2':
return nc_018_add_enabled_to_filter_exp_v2;
+ case 'nc_019_sandboxes':
+ return nc_019_sandboxes;
}
}
}
diff --git a/packages/nocodb/src/meta/migrations/v0/nc_019_sandboxes.ts b/packages/nocodb/src/meta/migrations/v0/nc_019_sandboxes.ts
new file mode 100644
index 0000000000..0e2748b825
--- /dev/null
+++ b/packages/nocodb/src/meta/migrations/v0/nc_019_sandboxes.ts
@@ -0,0 +1,65 @@
+import type { Knex } from 'knex';
+import { MetaTable } from '~/utils/globals';
+
+const up = async (knex: Knex) => {
+ // Create sandboxes table for development environment feature
+ await knex.schema.createTable(MetaTable.SANDBOXES, (table) => {
+ table.string('id', 20).primary();
+ table.string('fk_workspace_id', 20).notNullable();
+
+ // Reference to the master (original) base
+ table.string('master_base_id', 20).notNullable();
+
+ // Reference to the sandbox (duplicate) base
+ table.string('sandbox_base_id', 20).notNullable();
+
+ // Who created the sandbox
+ table.string('created_by', 20).notNullable();
+
+ // Metadata (JSON) for additional info
+ table.text('meta');
+
+ // Timestamps
+ table.timestamps(true, true);
+
+ // Indexes for performance
+ table.index(['fk_workspace_id'], 'nc_sandboxes_v2_workspace_id_idx');
+ table.index(['master_base_id'], 'nc_sandboxes_v2_master_base_id_idx');
+ table.index(['sandbox_base_id'], 'nc_sandboxes_v2_sandbox_base_id_idx');
+ table.index(['created_by'], 'nc_sandboxes_v2_created_by_idx');
+ });
+
+ // Add sandbox-related columns to bases table (nc_bases_v2)
+ await knex.schema.alterTable(MetaTable.PROJECT, (table) => {
+ // Points to SANDBOXES.id if this base has an active sandbox
+ table.string('fk_sandbox_id', 20);
+
+ // Is this base a sandbox base?
+ table.boolean('is_sandbox').defaultTo(false);
+ });
+
+ // Add indexes for sandbox relationship columns
+ await knex.schema.alterTable(MetaTable.PROJECT, (table) => {
+ table.index(['is_sandbox'], 'nc_bases_is_sandbox_idx');
+ table.index(['fk_sandbox_id'], 'nc_bases_fk_sandbox_id_idx');
+ });
+};
+
+const down = async (knex: Knex) => {
+ // Drop indexes from bases table
+ await knex.schema.alterTable(MetaTable.PROJECT, (table) => {
+ table.dropIndex(['is_sandbox'], 'nc_bases_is_sandbox_idx');
+ table.dropIndex(['fk_sandbox_id'], 'nc_bases_fk_sandbox_id_idx');
+ });
+
+ // Drop sandbox columns from bases table
+ await knex.schema.alterTable(MetaTable.PROJECT, (table) => {
+ table.dropColumn('is_sandbox');
+ table.dropColumn('fk_sandbox_id');
+ });
+
+ // Drop sandboxes table
+ await knex.schema.dropTable(MetaTable.SANDBOXES);
+};
+
+export { up, down };
diff --git a/packages/nocodb/src/models/Base.ts b/packages/nocodb/src/models/Base.ts
index cc168f81e5..0adae2a68c 100644
--- a/packages/nocodb/src/models/Base.ts
+++ b/packages/nocodb/src/models/Base.ts
@@ -64,6 +64,11 @@ export default class Base implements BaseType {
managed_app_published_at?: string; // When this version was published
managed_app_schema_locked?: boolean; // Computed: whether schema modifications are allowed
+ // sandbox props
+ fk_sandbox_id?: string; // Points to SANDBOXES.id if this base has an active sandbox
+ is_sandbox?: boolean; // Is this base a sandbox base?
+ sandbox_schema_locked?: boolean; // Computed: whether schema is locked due to active sandbox
+
constructor(base: Partial<Base>) {
Object.assign(this, base);
}
@@ -76,6 +81,10 @@ export default class Base implements BaseType {
return;
}
+ public static async populateSandboxInfo(_base: Base): Promise<void> {
+ return;
+ }
+
public static async createProject(
base: Partial<BaseType>,
ncMeta = Noco.ncMeta,
@@ -95,6 +104,8 @@ export default class Base implements BaseType {
'managed_app_id',
'managed_app_version_id',
'auto_update',
+ 'fk_sandbox_id',
+ 'is_sandbox',
]);
if (!insertObj.order) {
@@ -476,6 +487,8 @@ export default class Base implements BaseType {
'managed_app_id',
'managed_app_version_id',
'auto_update',
+ 'fk_sandbox_id',
+ 'is_sandbox',
]);
// stringify meta
diff --git a/packages/nocodb/src/schema/swagger-v2.json b/packages/nocodb/src/schema/swagger-v2.json
index 2e52f8281c..73765ecb53 100644
--- a/packages/nocodb/src/schema/swagger-v2.json
+++ b/packages/nocodb/src/schema/swagger-v2.json
@@ -18835,6 +18835,14 @@
"fk_custom_url_id": {
"$ref": "#/components/schemas/StringOrNull",
"description": "ID of custom url"
+ },
+ "is_sandbox": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Indicates if the base is a sandbox"
+ },
+ "fk_sandbox_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "If the base has a sandbox, this is the sandbox ID"
}
},
"x-stoplight": {
diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json
index 82b1990a89..fa7e369879 100644
--- a/packages/nocodb/src/schema/swagger.json
+++ b/packages/nocodb/src/schema/swagger.json
@@ -26811,6 +26811,14 @@
"granted_type"
]
}
+ },
+ "is_sandbox": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Indicates if the base is a sandbox"
+ },
+ "fk_sandbox_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "If the base has a sandbox, this is the sandbox ID"
}
},
"x-stoplight": {
diff --git a/packages/nocodb/src/utils/globals.ts b/packages/nocodb/src/utils/globals.ts
index d58813c5ca..f7a4be59d5 100644
--- a/packages/nocodb/src/utils/globals.ts
+++ b/packages/nocodb/src/utils/globals.ts
@@ -109,6 +109,7 @@ export enum MetaTable {
MANAGED_APP_VERSIONS = 'nc_managed_app_versions',
MANAGED_APP_DEPLOYMENT_LOGS = 'nc_managed_app_deployment_logs',
AUTOMATION_SUBSCRIBERS = 'nc_automation_subscribers',
+ SANDBOXES = 'nc_sandboxes_v2',
}
export const BaseRelatedMetaTables = [
@@ -335,6 +336,7 @@ export enum CacheScope {
MANAGED_APP_DEPLOYMENT_LOG = 'managedAppDeploymentLog',
SUBSCRIPTIONS_ALIAS = 'subscriptionsAlias',
AUTOMATION_SUBSCRIBER = 'automationSubscriber',
+ SANDBOX = 'sandbox',
}
export enum CacheGetType {
@@ -385,6 +387,7 @@ export const RootScopeTables = {
MetaTable.MANAGED_APPS,
MetaTable.MANAGED_APP_VERSIONS,
MetaTable.MANAGED_APP_DEPLOYMENT_LOGS,
+ MetaTable.SANDBOXES,
// Temporarily added need to be discussed within team
MetaTable.AUDIT,
MetaTable.CUSTOM_URLS,