refactor: rename database to schema

This commit is contained in:
Fabio Di Stasio 2021-03-17 11:15:14 +01:00
parent d892fa6fb3
commit 4d844fe2c9
13 changed files with 59 additions and 59 deletions

View File

@ -7,7 +7,7 @@ import functions from './functions';
import schedulers from './schedulers'; import schedulers from './schedulers';
import updates from './updates'; import updates from './updates';
import application from './application'; import application from './application';
import database from './database'; import schema from './schema';
import users from './users'; import users from './users';
const connections = {}; const connections = {};
@ -20,7 +20,7 @@ export default () => {
routines(connections); routines(connections);
functions(connections); functions(connections);
schedulers(connections); schedulers(connections);
database(connections); schema(connections);
users(connections); users(connections);
updates(); updates();
application(); application();

View File

@ -2,9 +2,9 @@
import { ipcMain } from 'electron'; import { ipcMain } from 'electron';
export default connections => { export default connections => {
ipcMain.handle('create-database', async (event, params) => { ipcMain.handle('create-schema', async (event, params) => {
try { try {
await connections[params.uid].createDatabase(params); await connections[params.uid].createSchema(params);
return { status: 'success' }; return { status: 'success' };
} }
@ -13,9 +13,9 @@ export default connections => {
} }
}); });
ipcMain.handle('update-database', async (event, params) => { ipcMain.handle('update-schema', async (event, params) => {
try { try {
await connections[params.uid].alterDatabase(params); await connections[params.uid].alterSchema(params);
return { status: 'success' }; return { status: 'success' };
} }
@ -24,9 +24,9 @@ export default connections => {
} }
}); });
ipcMain.handle('delete-database', async (event, params) => { ipcMain.handle('delete-schema', async (event, params) => {
try { try {
await connections[params.uid].dropDatabase(params); await connections[params.uid].dropSchema(params);
return { status: 'success' }; return { status: 'success' };
} }
@ -35,7 +35,7 @@ export default connections => {
} }
}); });
ipcMain.handle('get-database-collation', async (event, params) => { ipcMain.handle('get-schema-collation', async (event, params) => {
try { try {
const collation = await connections[params.uid].getDatabaseCollation(params); const collation = await connections[params.uid].getDatabaseCollation(params);

View File

@ -410,7 +410,7 @@ export class MySQLClient extends AntaresCore {
* @returns {Array.<Object>} parameters * @returns {Array.<Object>} parameters
* @memberof MySQLClient * @memberof MySQLClient
*/ */
async createDatabase (params) { async createSchema (params) {
return await this.raw(`CREATE DATABASE \`${params.name}\` COLLATE ${params.collation}`); return await this.raw(`CREATE DATABASE \`${params.name}\` COLLATE ${params.collation}`);
} }
@ -420,7 +420,7 @@ export class MySQLClient extends AntaresCore {
* @returns {Array.<Object>} parameters * @returns {Array.<Object>} parameters
* @memberof MySQLClient * @memberof MySQLClient
*/ */
async alterDatabase (params) { async alterSchema (params) {
return await this.raw(`ALTER DATABASE \`${params.name}\` COLLATE ${params.collation}`); return await this.raw(`ALTER DATABASE \`${params.name}\` COLLATE ${params.collation}`);
} }
@ -430,7 +430,7 @@ export class MySQLClient extends AntaresCore {
* @returns {Array.<Object>} parameters * @returns {Array.<Object>} parameters
* @memberof MySQLClient * @memberof MySQLClient
*/ */
async dropDatabase (params) { async dropSchema (params) {
return await this.raw(`DROP DATABASE \`${params.database}\``); return await this.raw(`DROP DATABASE \`${params.database}\``);
} }

View File

@ -375,7 +375,7 @@ export class PostgreSQLClient extends AntaresCore {
* @returns {Array.<Object>} parameters * @returns {Array.<Object>} parameters
* @memberof MySQLClient * @memberof MySQLClient
*/ */
async createDatabase (params) { async createSchema (params) {
return await this.raw(`CREATE SCHEMA "${params.name}"`); return await this.raw(`CREATE SCHEMA "${params.name}"`);
} }
@ -385,7 +385,7 @@ export class PostgreSQLClient extends AntaresCore {
* @returns {Array.<Object>} parameters * @returns {Array.<Object>} parameters
* @memberof MySQLClient * @memberof MySQLClient
*/ */
async alterDatabase (params) { async alterSchema (params) {
return await this.raw(`ALTER SCHEMA "${params.name}"`); return await this.raw(`ALTER SCHEMA "${params.name}"`);
} }
@ -395,7 +395,7 @@ export class PostgreSQLClient extends AntaresCore {
* @returns {Array.<Object>} parameters * @returns {Array.<Object>} parameters
* @memberof MySQLClient * @memberof MySQLClient
*/ */
async dropDatabase (params) { async dropSchema (params) {
return await this.raw(`DROP SCHEMA "${params.database}"`); return await this.raw(`DROP SCHEMA "${params.database}"`);
} }

View File

@ -53,7 +53,7 @@
</div> </div>
</div> </div>
<div class="modal-footer text-light"> <div class="modal-footer text-light">
<button class="btn btn-primary mr-2" @click.stop="updateDatabase"> <button class="btn btn-primary mr-2" @click.stop="updateSchema">
{{ $t('word.update') }} {{ $t('word.update') }}
</button> </button>
<button class="btn btn-link" @click.stop="closeModal"> <button class="btn btn-link" @click.stop="closeModal">
@ -66,10 +66,10 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import Database from '@/ipc-api/Database'; import Schema from '@/ipc-api/Schema';
export default { export default {
name: 'ModalEditDatabase', name: 'ModalEditSchema',
props: { props: {
selectedDatabase: String selectedDatabase: String
}, },
@ -98,7 +98,7 @@ export default {
async created () { async created () {
let actualCollation; let actualCollation;
try { try {
const { status, response } = await Database.getDatabaseCollation({ uid: this.selectedWorkspace, database: this.selectedDatabase }); const { status, response } = await Schema.getDatabaseCollation({ uid: this.selectedWorkspace, database: this.selectedDatabase });
if (status === 'success') if (status === 'success')
actualCollation = response; actualCollation = response;
@ -130,10 +130,10 @@ export default {
...mapActions({ ...mapActions({
addNotification: 'notifications/addNotification' addNotification: 'notifications/addNotification'
}), }),
async updateDatabase () { async updateSchema () {
if (this.database.collation !== this.database.prevCollation) { if (this.database.collation !== this.database.prevCollation) {
try { try {
const { status, response } = await Database.updateDatabase({ const { status, response } = await Schema.updateSchema({
uid: this.selectedWorkspace, uid: this.selectedWorkspace,
...this.database ...this.database
}); });

View File

@ -52,7 +52,7 @@
<button <button
class="btn btn-primary mr-2" class="btn btn-primary mr-2"
:class="{'loading': isLoading}" :class="{'loading': isLoading}"
@click.stop="createDatabase" @click.stop="createSchema"
> >
{{ $t('word.add') }} {{ $t('word.add') }}
</button> </button>
@ -66,10 +66,10 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import Database from '@/ipc-api/Database'; import Schema from '@/ipc-api/Schema';
export default { export default {
name: 'ModalNewDatabase', name: 'ModalNewSchema',
data () { data () {
return { return {
isLoading: false, isLoading: false,
@ -109,10 +109,10 @@ export default {
...mapActions({ ...mapActions({
addNotification: 'notifications/addNotification' addNotification: 'notifications/addNotification'
}), }),
async createDatabase () { async createSchema () {
this.isLoading = true; this.isLoading = true;
try { try {
const { status, response } = await Database.createDatabase({ const { status, response } = await Schema.createSchema({
uid: this.selectedWorkspace, uid: this.selectedWorkspace,
...this.database ...this.database
}); });

View File

@ -101,7 +101,7 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import Database from '@/ipc-api/Database'; import Schema from '@/ipc-api/Schema';
import BaseVirtualScroll from '@/components/BaseVirtualScroll'; import BaseVirtualScroll from '@/components/BaseVirtualScroll';
import ProcessesListRow from '@/components/ProcessesListRow'; import ProcessesListRow from '@/components/ProcessesListRow';
@ -181,7 +181,7 @@ export default {
this.results = []; this.results = [];
try { // Table data try { // Table data
const { status, response } = await Database.getProcesses(this.connection.uid); const { status, response } = await Schema.getProcesses(this.connection.uid);
if (status === 'success') { if (status === 'success') {
this.results = response; this.results = response;

View File

@ -44,7 +44,7 @@
:connection="connection" :connection="connection"
/> />
<div v-else class="workspace-explorebar-body"> <div v-else class="workspace-explorebar-body">
<WorkspaceExploreBarDatabase <WorkspaceExploreBarSchema
v-for="db of workspace.structure" v-for="db of workspace.structure"
:key="db.name" :key="db.name"
:database="db" :database="db"
@ -55,7 +55,7 @@
/> />
</div> </div>
</div> </div>
<ModalNewDatabase <ModalNewSchema
v-if="isNewDBModal" v-if="isNewDBModal"
@close="hideNewDBModal" @close="hideNewDBModal"
@reload="refresh" @reload="refresh"
@ -137,11 +137,11 @@ import Functions from '@/ipc-api/Functions';
import Schedulers from '@/ipc-api/Schedulers'; import Schedulers from '@/ipc-api/Schedulers';
import WorkspaceConnectPanel from '@/components/WorkspaceConnectPanel'; import WorkspaceConnectPanel from '@/components/WorkspaceConnectPanel';
import WorkspaceExploreBarDatabase from '@/components/WorkspaceExploreBarDatabase'; import WorkspaceExploreBarSchema from '@/components/WorkspaceExploreBarSchema';
import DatabaseContext from '@/components/WorkspaceExploreBarDatabaseContext'; import DatabaseContext from '@/components/WorkspaceExploreBarSchemaContext';
import TableContext from '@/components/WorkspaceExploreBarTableContext'; import TableContext from '@/components/WorkspaceExploreBarTableContext';
import MiscContext from '@/components/WorkspaceExploreBarMiscContext'; import MiscContext from '@/components/WorkspaceExploreBarMiscContext';
import ModalNewDatabase from '@/components/ModalNewDatabase'; import ModalNewSchema from '@/components/ModalNewSchema';
import ModalNewTable from '@/components/ModalNewTable'; import ModalNewTable from '@/components/ModalNewTable';
import ModalNewView from '@/components/ModalNewView'; import ModalNewView from '@/components/ModalNewView';
import ModalNewTrigger from '@/components/ModalNewTrigger'; import ModalNewTrigger from '@/components/ModalNewTrigger';
@ -153,11 +153,11 @@ export default {
name: 'WorkspaceExploreBar', name: 'WorkspaceExploreBar',
components: { components: {
WorkspaceConnectPanel, WorkspaceConnectPanel,
WorkspaceExploreBarDatabase, WorkspaceExploreBarSchema,
DatabaseContext, DatabaseContext,
TableContext, TableContext,
MiscContext, MiscContext,
ModalNewDatabase, ModalNewSchema,
ModalNewTable, ModalNewTable,
ModalNewView, ModalNewView,
ModalNewTrigger, ModalNewTrigger,

View File

@ -157,7 +157,7 @@ import { mapActions, mapGetters } from 'vuex';
import { formatBytes } from 'common/libs/formatBytes'; import { formatBytes } from 'common/libs/formatBytes';
export default { export default {
name: 'WorkspaceExploreBarDatabase', name: 'WorkspaceExploreBarSchema',
props: { props: {
database: Object, database: Object,
connection: Object connection: Object

View File

@ -78,7 +78,7 @@
</div> </div>
</div> </div>
</ConfirmModal> </ConfirmModal>
<ModalEditDatabase <ModalEditSchema
v-if="isEditModal" v-if="isEditModal"
:selected-database="selectedDatabase" :selected-database="selectedDatabase"
@close="hideEditModal" @close="hideEditModal"
@ -90,15 +90,15 @@
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import BaseContextMenu from '@/components/BaseContextMenu'; import BaseContextMenu from '@/components/BaseContextMenu';
import ConfirmModal from '@/components/BaseConfirmModal'; import ConfirmModal from '@/components/BaseConfirmModal';
import ModalEditDatabase from '@/components/ModalEditDatabase'; import ModalEditSchema from '@/components/ModalEditSchema';
import Database from '@/ipc-api/Database'; import Schema from '@/ipc-api/Schema';
export default { export default {
name: 'WorkspaceExploreBarDatabaseContext', name: 'WorkspaceExploreBarSchemaContext',
components: { components: {
BaseContextMenu, BaseContextMenu,
ConfirmModal, ConfirmModal,
ModalEditDatabase ModalEditSchema
}, },
props: { props: {
contextEvent: MouseEvent, contextEvent: MouseEvent,
@ -160,7 +160,7 @@ export default {
}, },
async deleteSchema () { async deleteSchema () {
try { try {
const { status, response } = await Database.deleteDatabase({ const { status, response } = await Schema.deleteSchema({
uid: this.selectedWorkspace, uid: this.selectedWorkspace,
database: this.selectedDatabase database: this.selectedDatabase
}); });

View File

@ -68,7 +68,7 @@
</template> </template>
<script> <script>
import Database from '@/ipc-api/Database'; import Schema from '@/ipc-api/Schema';
import QueryEditor from '@/components/QueryEditor'; import QueryEditor from '@/components/QueryEditor';
import BaseLoader from '@/components/BaseLoader'; import BaseLoader from '@/components/BaseLoader';
import WorkspaceQueryTable from '@/components/WorkspaceQueryTable'; import WorkspaceQueryTable from '@/components/WorkspaceQueryTable';
@ -150,7 +150,7 @@ export default {
query query
}; };
const { status, response } = await Database.rawQuery(params); const { status, response } = await Schema.rawQuery(params);
if (status === 'success') { if (status === 'success') {
this.results = Array.isArray(response) ? response : [response]; this.results = Array.isArray(response) ? response : [response];

View File

@ -2,20 +2,20 @@
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
export default class { export default class {
static createDatabase (params) { static createSchema (params) {
return ipcRenderer.invoke('create-database', params); return ipcRenderer.invoke('create-schema', params);
} }
static updateDatabase (params) { static updateSchema (params) {
return ipcRenderer.invoke('update-database', params); return ipcRenderer.invoke('update-schema', params);
} }
static getDatabaseCollation (params) { static getDatabaseCollation (params) {
return ipcRenderer.invoke('get-database-collation', params); return ipcRenderer.invoke('get-schema-collation', params);
} }
static deleteDatabase (params) { static deleteSchema (params) {
return ipcRenderer.invoke('delete-database', params); return ipcRenderer.invoke('delete-schema', params);
} }
static getStructure (params) { static getStructure (params) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import Connection from '@/ipc-api/Connection'; import Connection from '@/ipc-api/Connection';
import Database from '@/ipc-api/Database'; import Schema from '@/ipc-api/Schema';
import Users from '@/ipc-api/Users'; import Users from '@/ipc-api/Users';
import { uidGen } from 'common/libs/uidGen'; import { uidGen } from 'common/libs/uidGen';
const tabIndex = []; const tabIndex = [];
@ -270,7 +270,7 @@ export default {
break; break;
} }
const { status, response: version } = await Database.getVersion(connection.uid); const { status, response: version } = await Schema.getVersion(connection.uid);
if (status === 'error') if (status === 'error')
dispatch('notifications/addNotification', { status, message: version }, { root: true }); dispatch('notifications/addNotification', { status, message: version }, { root: true });
@ -309,7 +309,7 @@ export default {
}, },
async refreshStructure ({ dispatch, commit, getters }, uid) { async refreshStructure ({ dispatch, commit, getters }, uid) {
try { try {
const { status, response } = await Database.getStructure({ uid, schemas: getters.getLoadedSchemas(uid) }); const { status, response } = await Schema.getStructure({ uid, schemas: getters.getLoadedSchemas(uid) });
if (status === 'error') if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true }); dispatch('notifications/addNotification', { status, message: response }, { root: true });
@ -322,7 +322,7 @@ export default {
}, },
async refreshSchema ({ dispatch, commit }, { uid, schema }) { async refreshSchema ({ dispatch, commit }, { uid, schema }) {
try { try {
const { status, response } = await Database.getStructure({ uid, schemas: new Set([schema]) }); const { status, response } = await Schema.getStructure({ uid, schemas: new Set([schema]) });
if (status === 'error') if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true }); dispatch('notifications/addNotification', { status, message: response }, { root: true });
else else
@ -334,7 +334,7 @@ export default {
}, },
async refreshCollations ({ dispatch, commit }, uid) { async refreshCollations ({ dispatch, commit }, uid) {
try { try {
const { status, response } = await Database.getCollations(uid); const { status, response } = await Schema.getCollations(uid);
if (status === 'error') if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true }); dispatch('notifications/addNotification', { status, message: response }, { root: true });
else else
@ -346,7 +346,7 @@ export default {
}, },
async refreshVariables ({ dispatch, commit }, uid) { async refreshVariables ({ dispatch, commit }, uid) {
try { try {
const { status, response } = await Database.getVariables(uid); const { status, response } = await Schema.getVariables(uid);
if (status === 'error') if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true }); dispatch('notifications/addNotification', { status, message: response }, { root: true });
else else
@ -358,7 +358,7 @@ export default {
}, },
async refreshEngines ({ dispatch, commit }, uid) { async refreshEngines ({ dispatch, commit }, uid) {
try { try {
const { status, response } = await Database.getEngines(uid); const { status, response } = await Schema.getEngines(uid);
if (status === 'error') if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true }); dispatch('notifications/addNotification', { status, message: response }, { root: true });
else else
@ -430,7 +430,7 @@ export default {
if (lastBreadcrumbs.schema === payload.schema && hasLastChildren && !hasChildren) return; if (lastBreadcrumbs.schema === payload.schema && hasLastChildren && !hasChildren) return;
if (lastBreadcrumbs.schema !== payload.schema) if (lastBreadcrumbs.schema !== payload.schema)
Database.useSchema({ uid: getters.getSelected, schema: payload.schema }); Schema.useSchema({ uid: getters.getSelected, schema: payload.schema });
commit('CHANGE_BREADCRUMBS', { uid: getters.getSelected, breadcrumbs: { ...breadcrumbsObj, ...payload } }); commit('CHANGE_BREADCRUMBS', { uid: getters.getSelected, breadcrumbs: { ...breadcrumbsObj, ...payload } });
lastBreadcrumbs = { ...breadcrumbsObj, ...payload }; lastBreadcrumbs = { ...breadcrumbsObj, ...payload };