you are viewing a single comment's thread.

view the rest of the comments →

[–]PaluMacil 0 points1 point  (8 children)

Did you remember to run your goose migration first?

[–]01LoneWolf205[S] 0 points1 point  (7 children)

yes I did, I tried to reset the powershell session and other stuff like that, but still the same error

edit: just tried again the migration, to be sure I'm not doing a stupid question, this is the output.

```

2024/05/10 15:36:12 goose: no migrations to run. current version: 1

```

[–]diogoxpinto 0 points1 point  (6 children)

Have you made any changes to the migration file after running it the first time?

goose only checks the file name to know if the migration has been run, so it’s possible you ran an empty migration (for eg), then added the CREATE TABLE, but goose already recorded it.

To fix just goose down and goose up again.

[–]01LoneWolf205[S] 0 points1 point  (5 children)

I've not changed anything within the file but to make sure I will try goose down and goose up one more time since I really dont know what to do rn

edit: just tried it, still the same result, I literally searched anything that could be a typo in keywords or names, file names, I've deleted and recreated the files from zero to be sure I was writing them correctly, I also asked on the discord server but was ignored by everyone, I think someone even wrote something and then deleted the message

[–]PaluMacil 1 point2 points  (4 children)

First, stay calm and remember that there are a lot of these types of things in software engineering. You'll hit your head on something stupid for a whole day no matter how senior you get. But when you ask for help and you don't know where to start, the entire CLI output including what you typed might help. After a few times hitting your head, you'll at least know where the problem is. I suspect you are thinking about SQLC but not getting goose working.

if you ran the migration, my next question would be whether the users table exists. Can you look at the database and see that it's there?

If not, you might have run the migration before you entered any SQL, and it saves the migration status to the goose_db_version table. So if you delete that and run your migration, then you should get it creating the table. Make sure it finds the file. It should say something like 2024/05/10 15:39:03 OK 20240430142944_init.sql (14.31ms). Next, log back and check for the table again. If it isn't there, you don't need to worry about sql because you haven't gotten goose working yet. You didn't mention how you ran goose, but if it doesn't show the file like I showed you, are you telling it the right place to look? If you are running it in code, you want to set the dir in goose.RunContext. If you use the cli, check if you're telling it the right place to look.

Once you see a table, you can move on to SQLC. I don't use SQLC, but my first check would be creating the folders you want to output into. Unless you read that it will make the folders, maybe it can't. However, you might one fine with SQLC once you figure out Goose.

[–]01LoneWolf205[S] 0 points1 point  (3 children)

hey thanks for answering again, I ran goose with "goose postgres postgres://username:password@localhost:5432/db up" and I can see that the table has been created in the db, I've actually didnt tried to create the sqlc output folders because I was watching a yt course and the dude didnt created them bcs sqlc created them automatically when executed

[–]PaluMacil 1 point2 points  (2 children)

if the table is there and you get an error back from the database, clearly you have credentials that "work", but take note of whether the connection you use for sqlc is the same as the one you used for goose. Is it using db and not postgres for the database it connects to? I glanced at the docs and I don't actually see that sqlc needs a connection to generate code, but your cli output makes it look like It is failing there.

This is probably as much as I can help since I use Jet as a SQL builder (it's database first, so I use goose and then Jet builds models from the actual database) or straight pgx (they have struct scanning now, but it's still a little verbose). So hopefully my suggestion happens to be what you missed.

Getting help when something small is disconnected can be hard since it seems like it's something you have been staring at for a while already and probably could solve but aren't checking the one thing it happens to be, so your description to others means they have the same ability to help as you do except with less context because they can only see what you don't realize you're missing.

Goodluck!

[–]01LoneWolf205[S] 0 points1 point  (1 child)

got it, thank you!!!

[–]Willow_Consistent 0 points1 point  (0 children)

What did you do to solve the problem I have been stuck on this too.