सामग्री पर जाएँ
ऑराबेस लोगो
aurabase

Appwrite से माइग्रेट करें

उपयोगकर्ता पासवर्ड रीसेट किए बिना Appwrite प्रोजेक्ट को Aurabase पर ले जाएं: संग्रह को समर्पित PostgreSQL 18 तालिकाओं (या एक समर्पित MongoDB-इंजन NoSQL प्रोजेक्ट) पर मैप करें, aura.authAdmin.importUsers() के माध्यम से Argon2id/bcrypt हैश आयात करें, और दस्तावेज़ अनुमतियों को PostgreSQL RLS से बदलें।

कैसे-करें गाइड11 मि॰ पढ़ेंस्तर मध्यवर्ती

यह पृष्ठ स्वचालित रूप से अनुवादित किया गया था. अंग्रेजी संस्करण प्रामाणिक है.

त्वरित जवाब#

को Appwrite से Aurabase पर माइग्रेट करने के लिए, अपने Appwrite संग्रह को Appwrite सर्वर SDK (node-appwrite) के माध्यम से निर्यात करें, उन्हें समर्पित PostgreSQL 18 प्रोजेक्ट में लोड करें (या यदि आप चाहें तो एक समर्पित --engine mongodb प्रोजेक्ट में लोड करें) aura.nosql के माध्यम से स्कीमा-रहित JSON संग्रह), aura.authAdmin.importUsers() (Appwrite के डिफ़ॉल्ट Argon2id और bcrypt हैश के साथ बैच-आयात Appwrite उपयोगकर्ता पासवर्ड रीसेट के बिना काम करते हैं), और Permission.read(Role.user()) नियमों का अनुवाद करें PostgreSQL पंक्ति-स्तरीय सुरक्षा नीतियां।

घटक मानचित्रण#

AppwriteAurabase समकक्षप्रवासन नोट्स
Appwrite डेटाबेस एवं संग्रहसमर्पित PostgreSQL 18 या --engine mongodb NoSQL प्रोजेक्टरिलेशनल एसक्यूएल के लिए Postgres 18 चुनें, RLS और pgvector को जोड़ें; लचीले JSON दस्तावेज़ों के लिए --engine mongodb चुनें
दस्तावेज़ अनुमतियाँ (Role.user(), Role.team())मूल निवासी PostgreSQL RLS (auth.uid(), JWT दावे)REST, रीयलटाइम CDC और MCP में Postgres के अंदर मूल्यांकन किया गया
Appwrite प्रामाणिक (argon2 / bcrypt)Aurabase प्रामाणिक (OAuth 2.1, पासकी, TOTP MFA)Argon2id और bcrypt हैश सीधे आयात करते हैं (1,000 उपयोगकर्ता/बैच तक)
Appwrite संग्रहणसॉवरेन S3 भंडारण (समुद्री शैवालएफएस)S3- हस्ताक्षरित यूआरएल, छवि परिवर्तन और प्रति-पथ के साथ संगत बकेट RLS
Appwrite फ़ंक्शनEdge Functions (Deno/TypeScript या WASM)मानक Deno.serve() पर पोर्ट करें और aura functions deploy के साथ तैनात करें
Appwrite वास्तविक समयAurabase रीयलटाइम (वेबसॉकेट/एसएसई + NATS CDC)कॉलम-फ़िल्टर किया गया Postgres CDC, उपस्थिति, और प्रसारण

1. PostgreSQL 18 बनाम NoSQL इंजन चुनें#

प्रति Aurabase प्रोजेक्ट में एक डेटाबेस इंजन

Aurabase /v1/nosql रूट केवल --engine mongodb (aura projects create my-app --engine mongodb) के साथ बनाए गए प्रोजेक्ट पर मौजूद होते हैं। एक मानक PostgreSQL 18 प्रोजेक्ट SQL तालिकाओं + jsonb कॉलम + PostgREST का उपयोग करता है। यदि आप जुड़ना चाहते हैं, सख्त विदेशी कुंजी, pgvector और पूर्ण SQL RLS चाहते हैं तो PostgreSQL 18 चुनें; MongoDB इंजन तभी चुनें जब आपका ऐप स्कीमलेस BSON/JSON संग्रह और एकत्रीकरण पाइपलाइनों पर बहुत अधिक निर्भर करता है।

2. Appwrite संग्रह निर्यात और लोड करें#

प्रत्येक संग्रह (Query.limit(100) + Query.cursorAfter) को पेजिनेट करने के लिए node-appwrite का उपयोग करें और पंक्तियों को बैचों में Aurabase में लोड करें:

import { Client, Databases, Query } from 'node-appwrite'
import { createClient } from '@aurabase/aurabase-js'

const appwrite = new Client()
  .setEndpoint(process.env.APPWRITE_ENDPOINT!)
  .setProject(process.env.APPWRITE_PROJECT_ID!)
  .setKey(process.env.APPWRITE_API_KEY!)

const databases = new Databases(appwrite)
const aura = createClient(
  process.env.NEXT_PUBLIC_AURABASE_URL!,
  process.env.AURABASE_SERVICE_ROLE_KEY!,
)

async function migrateCollection(databaseId: string, collectionId: string, targetTable: string) {
  let cursor: string | undefined

  while (true) {
    const queries = [Query.limit(100), ...(cursor ? [Query.cursorAfter(cursor)] : [])]
    const page = await databases.listDocuments(databaseId, collectionId, queries)
    if (page.documents.length === 0) break

    const rows = page.documents.map(({ $id, $createdAt, $updatedAt, $permissions, $databaseId, $collectionId, ...fields }) => ({
      legacy_id: $id,
      created_at: $createdAt,
      updated_at: $updatedAt,
      ...fields,
    }))

    const { error } = await aura.from(targetTable).insert(rows)
    if (error) throw new Error(`Insert failed on ${targetTable}: ${error.message}`)

    cursor = page.documents[page.documents.length - 1].$id
    if (page.documents.length < 100) break
  }
}

3. पासवर्ड रीसेट किए बिना Appwrite उपयोगकर्ताओं को आयात करें#

आधुनिक Appwrite उदाहरण हैश पासवर्ड Argon2id ($argon2id$v=19$...) या bcrypt ($2a$/$2b$/$2y$) के साथ। दोनों को मूल रूप से aura.authAdmin.importUsers() द्वारा स्वीकार किया जाता है ( प्रति बैच 1,000 उपयोगकर्ताओं तक; bcrypt हैश पहले लॉगिन पर Argon2id में स्वत: अपग्रेड हो जाता है):

import { Client, Users, Query } from 'node-appwrite'
import { createClient } from '@aurabase/aurabase-js'

const appwrite = new Client()
  .setEndpoint(process.env.APPWRITE_ENDPOINT!)
  .setProject(process.env.APPWRITE_PROJECT_ID!)
  .setKey(process.env.APPWRITE_API_KEY!)

const usersApi = new Users(appwrite)
const aura = createClient(
  process.env.NEXT_PUBLIC_AURABASE_URL!,
  process.env.AURABASE_SERVICE_ROLE_KEY!,
)

let cursor: string | undefined

while (true) {
  const queries = [Query.limit(100), ...(cursor ? [Query.cursorAfter(cursor)] : [])]
  const page = await usersApi.list(queries)
  if (page.users.length === 0) break

  const batch = page.users
    .filter((u) => Boolean(u.email))
    .map((u) => ({
      email: u.email,
      emailVerified: u.emailVerification,
      ...(u.password && /^\$(argon2id|2[aby])\$/.test(u.password) ? { passwordHash: u.password } : {}),
      ...(u.name ? { name: u.name } : {}),
      userMetadata: { legacy_appwrite_id: u.$id, prefs: u.prefs },
    }))

  const { data, error } = await aura.authAdmin.importUsers(batch)
  if (error) throw new Error(`User import failed: ${error.message}`)
  console.log(`Imported batch: created=${data.created} skipped=${data.skipped} errors=${data.errors}`)

  cursor = page.users[page.users.length - 1].$id
  if (page.users.length < 100) break
}
विरासत Appwrite SHA/MD5/स्क्रिप्ट हैश

यदि पुराने Appwrite खाते sha256, md5, या scrypt का उपयोग करते हैं, तो importUsers() पर कॉल करते समय passwordHash को छोड़ दें ताकि खाता अभी भी साफ-सुथरा बना रहे, फिर उन उपयोगकर्ताओं को मैजिक लिंक या पासवर्ड रीसेट प्रवाह के साथ साइन इन करने दें।

4. Appwrite अनुमतियों को PostgreSQL RLS में बदलें#

Appwrite अनुमतिसमतुल्य Aurabase PostgreSQL RLS
Permission.read(Role.any())FOR SELECT TO aura_anon, aura_authenticated USING (true)
Permission.read(Role.users())FOR SELECT TO aura_authenticated USING (true)
Permission.read(Role.user(userId))FOR SELECT TO aura_authenticated USING (user_id = auth.uid())
Permission.write(Role.user(userId))FOR ALL TO aura_authenticated USING (user_id = auth.uid()) WITH CHECK (user_id = auth.uid())
Permission.read(Role.team(teamId))USING (EXISTS (SELECT 1 FROM team_members tm WHERE tm.team_id = rows.team_id AND tm.user_id = auth.uid()))
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;

CREATE POLICY documents_owner_all ON documents
  FOR ALL TO aura_authenticated
  USING (user_id = auth.uid())
  WITH CHECK (user_id = auth.uid());

5. स्टोरेज, फ़ंक्शंस और एसडीके कॉल माइग्रेट करें#

  • भंडारण: Appwrite से storage.getFileDownload(bucketId, fileId) के साथ फ़ाइलें डाउनलोड करें और aura.storage.from(bucket).upload(path, buffer, { contentType }) के साथ Aurabase पर अपलोड करें।
  • फ़ंक्शन: Appwrite के ({ req, res }) => res.json(...) एंट्रीपॉइंट को मानक वेब Deno.serve(async (req) => Response.json(...)) में परिवर्तित करें और aura functions deploy के माध्यम से तैनात करें।
  • क्लाइंट SDK:
// पहले (Appwrite)
// स्थिरांक = प्रतीक्षा डेटाबेस.सूची दस्तावेज़ (डीबी_आईडी, 'कार्य', [क्वेरी.बराबर ('स्थिति', 'खुला')])

// के बाद (Aurabase)
const { data: tasks, error } = await aura
  .from('tasks')
  .select('*')
  .eq('status', 'open')

आईडी, टीमें और सामान्य नुकसान#

  • Appwrite $id बनाम Postgres UUID: Appwrite आईडी 20-वर्ण अल्फ़ान्यूमेरिक स्ट्रिंग्स (ID.unique()) हैं, RFC 4122 UUID नहीं। विदेशी संदर्भों को स्थानांतरित करते समय पुराने $id को legacy_id text UNIQUE कॉलम में संग्रहीत करें, या id text PRIMARY KEY को स्थानांतरित तालिकाओं पर रखें।
  • Appwrite टीमें: मॉडल टीमें स्पष्ट रूप से teams + team_members(team_id, user_id, role) तालिकाओं के साथ और एकल अनुक्रमित RLS EXISTS चेक के साथ पहुंच लागू करती हैं (देखें मल्टी-टेनेंट RBAC)।
  • दस्तावेज़-स्तरीय अनुमति सरणी: प्रत्येक पंक्ति पर अनुमति सरणी को डुप्लिकेट करने के बजाय, अनुक्रमित कॉलम में स्वामित्व (user_id, team_id, is_public) को सामान्यीकृत करें ताकि PostgreSQL RLS नीतियों के अंदर बी-ट्री इंडेक्स का उपयोग कर सकें।

आगे जाने के लिए#