Is there a way to simply check if the current schema file matches the DB

I want to perform a check to the effect of "is my schema.ts file exactly the same as what is in my connectionString". What is the best way to do this (via CLI preferably)
3 Replies
jakeleventhal
jakeleventhal13mo ago
@boba.holic i did this and come up with this script, but this is annoying
#!/bin/bash

rm -rf drizzle

# Introspect the current state of the database
npx drizzle-kit introspect:pg > /dev/null 2>&1

# Generate migrations
output=$(npx drizzle-kit generate:pg)

# Check if the output contains "No schema changes"
if [[ $output == *"No schema changes"* ]]; then
echo "No schema changes"
else
echo "Schema changes detected"
fi
#!/bin/bash

rm -rf drizzle

# Introspect the current state of the database
npx drizzle-kit introspect:pg > /dev/null 2>&1

# Generate migrations
output=$(npx drizzle-kit generate:pg)

# Check if the output contains "No schema changes"
if [[ $output == *"No schema changes"* ]]; then
echo "No schema changes"
else
echo "Schema changes detected"
fi
i feel like there ought to be a cli command to do all this @boba.holic moreover, this doesn't detect changes that are breaking, like column renames. i figured check:pg would help out, but seems to not be the case
DiamondDragon
DiamondDragon13mo ago
One thing about introspect, is it will dump the entire scheme in one file right? But if you have your schema broken up into different files , you have to manually cross reference?
Want results from more Discord servers?
Add your server