Why Goose Postgres Failed to Migrate SQL Command?

1.1k Views Asked by At

In 003_feeds.sql file, the feeds table looks like this:

-- +goose Up
CREATE TABLE feeds (
  id UUID NOT NULL PRIMARY KEY,
  created_at TIMESTAMP NOT NULL,
  updated_at TIMESTAMP NOT NULL,
  name TEXT NOT NULL,
  url TEXT UNIQUE NOT NULL,
  user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE
);

-- +goose Down
DROP TABLE feeds;

This table has been tested with endpoints and it worked just fine.

In my 005_feed_lastfetched.sqlfile, I want to alter the feeds table by specifying the following SQL query:

-- +goose UP
ALTER TABLE feeds ADD COLUMN last_fetched_at TIMESTAMP;

In the terminal, I run:

goose postgres postgres://postgres:password@localhost:5432/blog-aggregator up

The error message:

goose run: ERROR 005_feed_lastfetched.sql: failed to parse SQL migration file: failed to parse migration: unexpected state 0 on line "ALTER TABLE feeds ADD COLUMN last_fetched_at TIMESTAMP;", see https://github.com/pressly/goose#sql-migrations

It is worth noting that my 001 - 004 files SQL queries worked just fine, and I could successfully insert the above column in pgAdmin's query tool. And it is a Go project.

I searched online and could not find useful infos. Can anyone help enlighten a bit on this?

Your help is much appreciated.

0

There are 0 best solutions below