mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
refactor: migrations
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"@appwrite.io/console": "0.1.0",
|
||||
"@appwrite.io/console": "^0.1.1",
|
||||
"@appwrite.io/pink": "^0.0.6-rc.14",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
|
||||
@@ -169,6 +169,16 @@ export const scopes: {
|
||||
scope: 'health.read',
|
||||
description: "Access to read your project's health status",
|
||||
category: 'Other'
|
||||
},
|
||||
{
|
||||
scope: 'migrations.read',
|
||||
description: "Access to read your project's migration status",
|
||||
category: 'Other'
|
||||
},
|
||||
{
|
||||
scope: 'migrations.write',
|
||||
description: 'Access to create migrations',
|
||||
category: 'Other'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -73,48 +73,48 @@ type FormData = typeof initialFormData;
|
||||
export const formData = writable({ ...initialFormData });
|
||||
|
||||
type Resource =
|
||||
| 'user'
|
||||
| 'team'
|
||||
| 'teammembership'
|
||||
| 'file'
|
||||
| 'bucket'
|
||||
| 'function'
|
||||
| 'envvar'
|
||||
| 'deployment'
|
||||
| 'database'
|
||||
| 'collection'
|
||||
| 'index'
|
||||
| 'attribute'
|
||||
| 'document';
|
||||
| 'User'
|
||||
| 'Team'
|
||||
| 'Membership'
|
||||
| 'File'
|
||||
| 'Bucket'
|
||||
| 'Function'
|
||||
| 'EnvVar'
|
||||
| 'Deployment'
|
||||
| 'Database'
|
||||
| 'Collection'
|
||||
| 'Index'
|
||||
| 'Attribute'
|
||||
| 'Document';
|
||||
|
||||
export const formDataToResources = (formData: FormData): Resource[] => {
|
||||
const resources: Resource[] = [];
|
||||
if (formData.users.root) {
|
||||
resources.push('user');
|
||||
resources.push('User');
|
||||
}
|
||||
if (formData.users.teams) {
|
||||
resources.push('team');
|
||||
resources.push('teammembership');
|
||||
resources.push('Team');
|
||||
resources.push('Membership');
|
||||
}
|
||||
if (formData.databases.root) {
|
||||
resources.push('database');
|
||||
resources.push('Database');
|
||||
}
|
||||
if (formData.databases.documents) {
|
||||
resources.push('collection');
|
||||
resources.push('document');
|
||||
resources.push('Collection');
|
||||
resources.push('Document');
|
||||
}
|
||||
if (formData.functions.root) {
|
||||
resources.push('function');
|
||||
resources.push('Function');
|
||||
}
|
||||
if (formData.functions.env) {
|
||||
resources.push('envvar');
|
||||
resources.push('EnvVar');
|
||||
}
|
||||
if (formData.functions.inactive) {
|
||||
resources.push('deployment');
|
||||
resources.push('Deployment');
|
||||
}
|
||||
if (formData.storage.root) {
|
||||
resources.push('bucket');
|
||||
resources.push('file');
|
||||
resources.push('Bucket');
|
||||
resources.push('File');
|
||||
}
|
||||
|
||||
return resources;
|
||||
|
||||
@@ -16,15 +16,31 @@
|
||||
|
||||
const onFinish = async () => {
|
||||
const resources = formDataToResources($formData);
|
||||
if ($provider.provider === 'appwrite') {
|
||||
const res = await sdk.forProject.migrations.importAppwrite(
|
||||
resources,
|
||||
$provider.endpoint,
|
||||
$provider.projectID,
|
||||
$provider.apiKey
|
||||
);
|
||||
console.log(res);
|
||||
invalidate(Dependencies.MIGRATIONS);
|
||||
switch ($provider.provider) {
|
||||
case 'appwrite': {
|
||||
const res = await sdk.forProject.migrations.migrationAppwrite(
|
||||
resources,
|
||||
$provider.endpoint,
|
||||
$provider.projectID,
|
||||
$provider.apiKey
|
||||
);
|
||||
console.log(res);
|
||||
invalidate(Dependencies.MIGRATIONS);
|
||||
break;
|
||||
}
|
||||
case 'supabase': {
|
||||
const res = await sdk.forProject.migrations.migrationSupabase(
|
||||
resources,
|
||||
$provider.endpoint,
|
||||
$provider.apiKey,
|
||||
$provider.host,
|
||||
$provider.username,
|
||||
$provider.password,
|
||||
$provider.port
|
||||
);
|
||||
console.log(res);
|
||||
invalidate(Dependencies.MIGRATIONS);
|
||||
}
|
||||
}
|
||||
resetImportStores();
|
||||
wizard.hide();
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
let showDetails = false;
|
||||
let showCloudExport = false;
|
||||
|
||||
const mockImport = async () => {
|
||||
const mockMigrate = async () => {
|
||||
console.log(await sdk.forProject.migrations.list());
|
||||
};
|
||||
|
||||
mockImport();
|
||||
mockMigrate();
|
||||
|
||||
const getStatus = (status: string) => {
|
||||
if (status === 'failed') {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { sdk } from '$lib/stores/sdk';
|
||||
export async function load({ depends }) {
|
||||
depends(Dependencies.MIGRATIONS);
|
||||
|
||||
const { migrations } = await sdk.forProject.migrations.list();
|
||||
// const { migrations } = await sdk.forProject.migrations.list();
|
||||
|
||||
return {
|
||||
migrations: []
|
||||
|
||||
Reference in New Issue
Block a user