'ERROR: syntax error at or near "INTEGER"

I am using Flyway to migrate PostgreSQL tables for a spring web app and thus, I've written a set of SQL queries which add columns to an existing table, e.g. :

ALTER TABLE table_1 ADD COLUMN table_value_x TYPE INTEGER;
ALTER TABLE table_1 ADD COLUMN table_value_y TYPE VARCHAR(100);

After deploying war file on Tomcat, I get the following error :

ERROR: syntax error at or near "INTEGER"

Since Postgre is not so informative about its errors, I am looking for any kind of advice or suggestions on what this might be, thank you.



Solution 1:[1]

The TYPE keyword is only used when changing (altering) the column datatype. For adding columns, omit the TYPE keyword, as Matt wrote, and as it is shown here in the examples of the documentation (at the end of the page): https://www.postgresql.org/docs/9.4/static/sql-altertable.html

Solution 2:[2]

I suspect it might work if you get rid of the word 'TYPE'.

See example below, from the Postgres site.

ALTER TABLE distributors ADD COLUMN address varchar(30);

Edit: I see a whole bunch of people beat me to it.

Solution 3:[3]

I dont know if you already fixed, but if someone still asking:

I fixed excluding classpath dependency in pom.xml:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <classpathDependencyExcludes>
                    <classpathDependencyExclude>org.flywaydb:flyway-core</classpathDependencyExclude>
                </classpathDependencyExcludes>
            </configuration>
        </plugin>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Florian Albrecht
Solution 2 Riaan Nel
Solution 3