Prisma migrate dev: Run command while connected to DB? - postgresql

Context: Our staging and production postgres databases are in a managed SQL service.
Is it recommended to create a local postgres database to run the command the npx prisma migrate dev?
Once the migration files are generated (as a result of running this command), we should then be able to run the npx prisma migrate deploy command on staging and prod environments.

You are correct. You should only be using npx prisma migrate dev in a local/development database. Once you are done with development and migrations have been created, you apply them to your staging/production database using npx prisma migrate deploy.
I would recommend checking out these two articles from the Prisma docs:
Prisma Migrate: Concept Guide
Deploying database changes with Prisma Migrate

Related

How do I permanently delete failed prisma migrations in productions to keep it in sync with my local prisma migrations folder?

I'm experiencing an error while deploying my remix app to fly via github actions.
I recently altered one of my schemas, which led to the failed migration. I have deleted the migrations in the prisma/migrations folder and the local _prisma_migrations table and did a fresh prisma migrate dev. When I push to github I get an error that one of the migrations that I deleted could not be applied. How do I delete it completely in the production environment?

How can I run a alembic upgrade in Azure Postgres

I'm new into azure and wondering how to use Alembic to create my tables and keep track of modifications. In Heroku I could use the following command
heroku run "alembic upgrade head" --app APP-NAME
How to achieve the same in Azure?

Prisma push comand does not update Schema in cloud

I am using Prisma Cloud to quickly prototyping an app. I connected it to Postgres via Heroku.
I have my schema defined in prisma/schema.prisma.
When I modifiy the schema, the docs say to run the command:
npx prisma db push
When I do so, I received this message in terminal:
Your database is now in sync with your schema.
If I go to Prisma Studio, the schema has not change.
However, if I push my code to Github, the schema changes.
I was expecting that npx prisma db push would automatically change the schema in the cloud without the need to push on Github.
Am I wrong?
npx prisma db push just updates your database schema.
To update your schema.prisma file in Prisma Cloud you are supposed to push the code to the GitHub branch with which you have associated your environment. Each environment in Prisma cloud project has one to one relation with a GitHub branch.
Once you push changes to GitHub, Prisma cloud receives a webhook from GitHub and it then updates the schema. You can see the latest schema of your project in schema tab, attached image for reference.
It also shows the last time when schema was updated.

Data Migration Assistant for PostgreSQL to migrate to Azure PostgreSQL (not DMS)

Whenever we migrate on-premises SQL to Azure SQL , we can use Data Migration Assistant (DMA) for assessment (and also Data Migration Service (DMS) for migration)
I know that we have DMS which can help in migrating on-premises PostgreSQL to Azure PostgreSQL
Do we have Data Migration Assistant Tool to migrate Postgres to Azure PostgreSQL PaaS (we want to assess before migration) ? Basically the need is to where the data is compatible to be migrated to Azure , before running the azure DMS
Please help.
At the moment there isn't a Microsoft's tool that execute the assessment for an on-premises PostgreSQL Database for Azure migration.
I think CloudPilot of UnifyCloud can be used.

Is there any way to implement CI/CD for on premises Postgres SQL using Azure Devops Pipelines?

I want to create one click deployment on azure pipelines to move Postgres Sql changes from dev to QA environment,similar to what we implement using SQL Server Database project where a Powershell script deploy the changes to the remote server.
I have tried pg_dump and psql commands which will create dump file and restore it on the remote server. It does not perform diffing ie(comparing database changes on source and destination , and only replicating the missing changes)
You've stumbled upon one of the features lacking in the Postgres ecosystem. One of the more elegant ways to solve migrations using Postgres' own tooling is to package up your migrations as a Postgres Extension. This requires you to generate the deployment scripts yourself, but it is a neat way of applying and packaging up the deployments.
There are a number of commercial tools that will assist in this process, such as Datical, Liquibase, and Flyway. Note, some of these still require you to generate the change statements yourself, some attempt to create them for you.
Generating change statements is a whole different animal and I recommend you look at schema diffing tools for Postgres to find what best suites your needs.