Comments (4)
There are a few ways to workaround this issue. Understand and interpreting DO
functions is going to be pretty far off. Instead of having sqlc rely on your migrations directory, you could output a dump of your SQL database after your migrations have been run.
The other option is to create another, sqlc-specific, migrations directory where you have the CREATE TYPE
outside the DO
function.
I understand both of these options aren't ideal, but I'd like to get you unblocked.
from sqlc.
These are great alternatives. Thank you, I was about to unblock myself.
If understanding the DO block is out of band, would a structured comment be more achievable ?
from sqlc.
If understanding the DO block is out of band, would a structured comment be more achievable ?
We have a few "structured comment" proposals in the works. Are you suggesting something like:
-- @sqlc-ddl "CREATE TYPE status AS ENUM ('pending', 'cancelled', 'completed', 'failed', 'reversed');"
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'status') THEN
CREATE TYPE status AS ENUM ('pending', 'cancelled', 'completed', 'failed', 'reversed');
END IF;
END
$$;
from sqlc.
Yes, something along those lines.
from sqlc.
Related Issues (20)
- Temp table created using schema.sql is not insertable. HOT 3
- Incorrect code gen without
- Basic usage - relation "x" does not exist HOT 2
- underscore is not properly supported HOT 1
- Fails if structure is mysqldump containing rocksdb_has_p_s_session_variables
- Missing columns not being detected
- Error "not enough args to execute query" on complex select query.
- Does it support logging of executed SQL? HOT 1
- Generate in-memory mocked implementation of the Querier interface HOT 2
- Renaming a materialized view causes `sqlc generate` to fail
- sql\queries\users.sql:1:1: relation "users" does not exist HOT 2
- NULL JSON field fails to Scan into json.RawMessage
- Views models do not get updated when base tables are altered HOT 1
- sqlite ALTER TABLE ADD COLUMN without type name panics HOT 2
- wrong type for params in tuple
- COALESCE doesn't appear to work within a CTE
- SQLite: interface{} instead of time.Time for json extracted queries
- Multiple schemas support
- varchar2 support HOT 1
- copyfrom not respecting `query_parameter_limit`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlc.