Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions .github/workflows/schema-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,34 @@ jobs:
chmod +x dbmate
sudo mv dbmate /usr/local/bin/

- name: Validate schema is in sync with migrations
run: |
# Apply migrations, dumps schema
dbmate up
# Currently skipping since pg_dump doesn't produce consistent output anymore
# - name: Validate schema is in sync with migrations
# run: |
# # Apply migrations, dumps schema
# dbmate up

# Check if the schema file has changed
if git diff --exit-code database.sql; then
echo "✅ Schema validation passed - database.sql is in sync with migrations"
else
echo "::error::Schema file is out of sync with migrations!"
echo ""
echo "The database.sql file does not match what the migrations produce."
echo ""
echo "To fix this, run a postgres instance locally."
echo "Then apply the migrations to a clean database:"
echo " dbmate up"
echo ""
echo "Then include the updated schema in your commit:"
echo " git add database.sql && git commit -m 'Update schema'"
exit 1
fi
# # Check if the schema file has changed
# if git diff --exit-code database.sql; then
# echo "✅ Schema validation passed - database.sql is in sync with migrations"
# else
# echo "::error::Schema file is out of sync with migrations!"
# echo ""
# echo "The database.sql file does not match what the migrations produce."
# echo ""
# echo "To fix this, run a postgres instance locally."
# echo "Then apply the migrations to a clean database:"
# echo " dbmate up"
# echo ""
# echo "Then include the updated schema in your commit:"
# echo " git add database.sql && git commit -m 'Update schema'"
# exit 1
# fi

- name: Test that down migrations work
run: |
# Apply migrations, dumps schema
dbmate up

# Drop db from previous test
dbmate drop
# Apply migrations
Expand Down
5 changes: 3 additions & 2 deletions database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ ALTER TABLE ONLY public.compiled_contracts
--

ALTER TABLE ONLY public.compiled_contracts
ADD CONSTRAINT compiled_contracts_pseudo_pkey UNIQUE (compiler, language, creation_code_hash, runtime_code_hash);
ADD CONSTRAINT compiled_contracts_pseudo_pkey UNIQUE (compiler, version, language, creation_code_hash, runtime_code_hash);


--
Expand Down Expand Up @@ -1634,4 +1634,5 @@ ALTER TABLE ONLY public.verified_contracts

INSERT INTO public.schema_migrations (version) VALUES
('20250717103432'),
('20250723145429');
('20250723145429'),
('20251023134207');
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- migrate:up
ALTER TABLE compiled_contracts
DROP CONSTRAINT compiled_contracts_pseudo_pkey;

ALTER TABLE compiled_contracts
ADD CONSTRAINT compiled_contracts_pseudo_pkey UNIQUE (compiler, version, language, creation_code_hash, runtime_code_hash);

-- migrate:down
ALTER TABLE compiled_contracts
DROP CONSTRAINT compiled_contracts_pseudo_pkey;

ALTER TABLE compiled_contracts
ADD CONSTRAINT compiled_contracts_pseudo_pkey UNIQUE (compiler, language, creation_code_hash, runtime_code_hash);