Use your existing database to jumpstart a new resource and generate Amplication entities and relationships by uploading its Prisma schema.
schema.prisma
file based on your database.
Amplication will instantly create entities, fields, and relationships based on your schema, significantly accelerating your development process and letting you focus on business logic, not database setup.
This feature quickly translates your existing database structure into Amplication’s internal model, giving you a ready-to-go starting point.
Install Prisma CLI
Create a Prisma Schema File
schema.prisma
in your project. In this file, set the url
in the datasource
block to point to your existing database:Run Prisma Introspection
schema.prisma
file, then run:schema.prisma
.Validate Your Generated Schema
schema.prisma
in a text editor to ensure it’s error-free and follows your organization’s naming conventions or best practices. If you notice issues (e.g., missing relations or improperly named fields), make the necessary adjustments.Initialize a Migrations Folder
Generate a Baseline Migration Script
schema.prisma
, run:migration.sql
to ensure accuracy.Apply the Baseline Migration
_prisma_migrations
table without making changes.schema.prisma
file is ready, upload it to Amplication from the Resources section of your service.
Open Your Resource in Amplication
Navigate to Entities
Click 'Upload Schema'
Attach Your File
schema.prisma
file using the provided form.schema.prisma
file is valid before proceeding.Example ERD view after a successful schema upload
Commit Changes
Update Environment Variables
.env
file (or your deployment environment), set the DB_URL
to your existing database’s connection string.Copy Migrations Folder
migrations
folder into the prisma
directory of your new Amplication service repository.Run Database Commands