{ if (hasReplResult) { dbManagerContent?.clearReplResult() } else { handleClose() } }} CloseIcon={hasReplResult ? ArrowLeft : undefined} noPadding overflow_y={false} fullScreen={false} titleClass="text-sm text-primary" id="db-manager-drawer" > {#if contentInput && ws && roleSettled} {#key `${selectedDatatable}~${selectedRole ?? ''}`} (uriState.selectedDatatable = dt)} onSelectRole={(dt, role) => { // Setting the data table clears the role, so the order matters. uriState.selectedDatatable = dt uriState.selectedRole = role }} bind:pendingAction canManageDatatable={!!($superadmin || $userStore?.is_admin)} onDatatableAction={runDatatableAction} bind:workerTag={() => workerTag.tag, (v) => (workerTag.tag = v)} bind:hasReplResult bind:selectedSchemaKey={uriState.selectedSchema} bind:selectedTableKey={uriState.selectedTable} onImport={enableImportExport ? (mode) => ( (importTarget = undefined), (importDrawerOpen = true), (importBehavior = mode) ) : undefined} > {/key} {/if} {#snippet titleExtra()} {@const mainPaneLeft = dbManagerContent?.dbManager()?.mainPaneLeft()} {@const tabs = dbManagerContent?.tabsModel()} {#if tabs && mainPaneLeft}
{#each tabs?.tabs ?? [] as tab (tab.id)} {@const active = tab.id === tabs?.activeId} {@const Icon = TAB_KINDS.find((k) => k.kind === tab.kind)!.icon} {@const dropSide = dropTarget?.id === tab.id ? dropTarget.side : undefined}
{ draggedTabId = tab.id e.dataTransfer?.setData('text/plain', tab.id) if (e.dataTransfer) e.dataTransfer.effectAllowed = 'move' }} ondragover={(e) => { if (!draggedTabId) return e.preventDefault() if (draggedTabId === tab.id) { dropTarget = undefined return } const rect = e.currentTarget.getBoundingClientRect() const side = e.clientX < rect.left + rect.width / 2 ? 'before' : 'after' if (dropTarget?.id !== tab.id || dropTarget.side !== side) dropTarget = { id: tab.id, side } }} ondrop={(e) => { e.preventDefault() if (draggedTabId && dropTarget) tabs?.move(draggedTabId, dropTarget.id, dropTarget.side) draggedTabId = undefined dropTarget = undefined }} ondragend={() => { draggedTabId = undefined dropTarget = undefined }} {@attach (el) => { if (active) el.scrollIntoView({ block: 'nearest', inline: 'nearest' }) }} > {#if dropSide}
{/if}
{/each} k.kind !== 'diagram' || diagramSupported).map((k) => ({ displayName: k.label, icon: k.icon, action: () => { // A query opened from a data tab starts on that tab's table. const from = tabs?.active.kind === 'data' ? tabs.active : undefined tabs?.add( k.kind, k.kind === 'sql' && from?.table ? { code: `SELECT * FROM ${quotedTableName(from.schema, from.table)}` } : {} ) logFeatureUsage('db_manager', 'view_mode', { key: k.kind }) } }))} btnId="db-manager-new-tab" > {#snippet buttonReplacement()}
{/snippet}
{/if} {/snippet} {#snippet actions()} {#if uriState.effectiveInput && ws} {@const input = uriState.effectiveInput}
[ { displayName: workerTag.tag ? `Worker tag: ${workerTag.tag}` : 'Worker tag', icon: Tag, action: () => (workerTagOpen = true) }, // A data table exports and imports from its row menu in the tree; a // plain database has no tree row to hold them. ...(enableImportExport && !uriState.isDatatableInput ? [ { displayName: 'Export database', icon: Download, action: () => handleExportSchema() }, { displayName: 'Import database', icon: Upload, action: () => ((importTarget = undefined), (importDrawerOpen = true)) } ] : []) ]} btnId="db-manager-database-actions" /> workerTag.tag, (v) => (workerTag.tag = v)} bind:open={workerTagOpen} hideTrigger {input} workspace={ws} />
{/if} {/if}
(importDrawerOpen = false)}>
This will import the schemas from the selected source into the current database. Existing tables with the same names may be affected.
Source database
Import mode