Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bobgen-sql not working #336

Open
vwochnik opened this issue Jan 6, 2025 · 3 comments
Open

bobgen-sql not working #336

vwochnik opened this issue Jan 6, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@vwochnik
Copy link

vwochnik commented Jan 6, 2025

I have a test schema in ./schema.sql taken from the docs:

CREATE TABLE jets (
    id serial PRIMARY KEY NOT NULL,
    pilot_id integer NOT NULL,
    airport_id integer NOT NULL,
    name text NOT NULL,
    color text,
    uuid text NOT NULL,
    identifier text NOT NULL,
    cargo bytea NOT NULL,
    manifest bytea NOT NULL
);

Then I run following command in the same directory:

> SQL_DIALECT=psql bobgen-sql
The files belonging to this database system will be owned by user "vincent".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /tmp/bobgen_sql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Berlin
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    /tmp/bobgen_sql/bin/pg_ctl -D /tmp/bobgen_sql/data -l logfile start

waiting for server to start....2025-01-06 20:06:58.108 CET [1197041] LOG:  starting PostgreSQL 16.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit
2025-01-06 20:06:58.108 CET [1197041] LOG:  listening on IPv4 address "127.0.0.1", port 39803
2025-01-06 20:06:58.110 CET [1197041] LOG:  listening on Unix socket "/tmp/.s.PGSQL.39803"
2025-01-06 20:06:58.113 CET [1197044] LOG:  database system was shut down at 2025-01-06 20:06:58 CET
2025-01-06 20:06:58.118 CET [1197041] LOG:  database system is ready to accept connections
 done
server started
waiting for server to shut down....2025-01-06 20:06:58.203 CET [1197041] LOG:  received fast shutdown request
2025-01-06 20:06:58.205 CET [1197041] LOG:  aborting any active transactions
2025-01-06 20:06:58.205 CET [1197048] FATAL:  terminating connection due to administrator command
2025-01-06 20:06:58.206 CET [1197041] LOG:  background worker "logical replication launcher" (PID 1197047) exited with exit code 1
2025-01-06 20:06:58.206 CET [1197042] LOG:  shutting down
2025-01-06 20:06:58.208 CET [1197042] LOG:  checkpoint starting: shutdown immediate
2025-01-06 20:06:58.215 CET [1197042] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.003 s, sync=0.001 s, total=0.009 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/14E3508, redo lsn=0/14E3508
2025-01-06 20:06:58.217 CET [1197041] LOG:  database system is shut down
 done
server stopped
2025/01/06 20:06:58 getting psql driver: migrating: stat .: os: DirFS with empty root

Command is exiting with code 1. I do not understand the error I am getting. All I want is generate models from the schema.

Thank you.

@stephenafamo
Copy link
Owner

stephenafamo commented Jan 6, 2025

You have to add the directory where the migration files are

# bobgen.yaml
sql:
  dir: "."
  dialect: "psql"

I'll make an update so the current directory is used by default.

@stephenafamo stephenafamo added the enhancement New feature or request label Jan 6, 2025
@vwochnik
Copy link
Author

vwochnik commented Jan 7, 2025

Thank you very much! It worked.

However, the documentation is a bit confusing.
https://bob.stephenafamo.com/docs/code-generation/sql/

It specifies that . is the default directory.

@stephenafamo
Copy link
Owner

Yes... I'll fix this so that it works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants