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

View File

@ -2,9 +2,9 @@
import { ipcMain } from 'electron';
export default connections => {
ipcMain.handle('create-database', async (event, params) => {
ipcMain.handle('create-schema', async (event, params) => {
try {
await connections[params.uid].createDatabase(params);
await connections[params.uid].createSchema(params);
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 {
await connections[params.uid].alterDatabase(params);
await connections[params.uid].alterSchema(params);
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 {
await connections[params.uid].dropDatabase(params);
await connections[params.uid].dropSchema(params);
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 {
const collation = await connections[params.uid].getDatabaseCollation(params);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
'use strict';
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 { uidGen } from 'common/libs/uidGen';
const tabIndex = [];
@ -270,7 +270,7 @@ export default {
break;
}
const { status, response: version } = await Database.getVersion(connection.uid);
const { status, response: version } = await Schema.getVersion(connection.uid);
if (status === 'error')
dispatch('notifications/addNotification', { status, message: version }, { root: true });
@ -309,7 +309,7 @@ export default {
},
async refreshStructure ({ dispatch, commit, getters }, uid) {
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')
dispatch('notifications/addNotification', { status, message: response }, { root: true });
@ -322,7 +322,7 @@ export default {
},
async refreshSchema ({ dispatch, commit }, { uid, schema }) {
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')
dispatch('notifications/addNotification', { status, message: response }, { root: true });
else
@ -334,7 +334,7 @@ export default {
},
async refreshCollations ({ dispatch, commit }, uid) {
try {
const { status, response } = await Database.getCollations(uid);
const { status, response } = await Schema.getCollations(uid);
if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true });
else
@ -346,7 +346,7 @@ export default {
},
async refreshVariables ({ dispatch, commit }, uid) {
try {
const { status, response } = await Database.getVariables(uid);
const { status, response } = await Schema.getVariables(uid);
if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true });
else
@ -358,7 +358,7 @@ export default {
},
async refreshEngines ({ dispatch, commit }, uid) {
try {
const { status, response } = await Database.getEngines(uid);
const { status, response } = await Schema.getEngines(uid);
if (status === 'error')
dispatch('notifications/addNotification', { status, message: response }, { root: true });
else
@ -430,7 +430,7 @@ export default {
if (lastBreadcrumbs.schema === payload.schema && hasLastChildren && !hasChildren) return;
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 } });
lastBreadcrumbs = { ...breadcrumbsObj, ...payload };