Migration

الترحيل (Migration)

GLS-000099

Intermediatedatabase1 min read
database migrationschema migrationdb migrationprisma migratesupabase migration

Definition

A versioned change to a database schema — adding a column, creating a table, or modifying a field safely.

تغيير مُصنَّف بإصدار على مخطط قاعدة البيانات — إضافة عمود أو إنشاء جدول أو تعديل حقل بأمان.

Why It Matters

Without migrations, updating a production database schema is risky and error-prone. Migrations create a safe, auditable record of all schema changes.

بدون الترحيلات، تحديث مخطط قاعدة بيانات الإنتاج محفوف بالمخاطر وعرضة للأخطاء. الترحيلات تُنشئ سجلًا آمنًا وقابلًا للتدقيق لجميع تغييرات المخطط.

Full Definition

A migration is a script that changes a database schema in a controlled, reproducible way. Migrations are version-controlled so every environment (development, staging, production) can be updated consistently. Tools like Prisma Migrate and Supabase CLI generate and apply migrations. Firestore is schemaless so it doesn't need migrations — but you write patch routes instead.
الترحيل هو سكريبت يُغيِّر مخطط قاعدة البيانات بطريقة مضبوطة وقابلة للتكرار. الترحيلات تحت إدارة الإصدار بحيث يمكن تحديث كل بيئة (تطوير وتجهيز وإنتاج) بشكل متسق. أدوات مثل Prisma Migrate وSupabase CLI تولّد الترحيلات وتطبّقها. Firestore بدون مخطط لذا لا يحتاج ترحيلات — بل تكتب مسارات تصحيح عوضًا عن ذلك.

Example Usage

npx prisma migrate dev --name add-bio-to-users creates a SQL migration file that adds a bio column to the users table.

npx prisma migrate dev --name add-bio-to-users يُنشئ ملف ترحيل SQL يضيف عمود bio إلى جدول users.

Knowledge Graph

Avoid these mistakes when using Migration:

1

Running migrations manually on production instead of using a controlled process

2

Writing irreversible migrations without a rollback plan

Sign in to unlock guided AI explanations from AI Teacher.

Generate a Prompt

Copy this prompt and use it directly with any AI model — no setup needed.

Ready-to-Use Prompt
Help me build a project using Migration.

Explain:
1. What is Migration and why it matters
2. The core architecture and required tools
3. Step-by-step implementation plan
4. Common mistakes to avoid: Running migrations manually on production instead of using a controlled process, Writing irreversible migrations without a rollback plan
5. Best practices and production tips

Official Resources