Error when after upgrading to 1,3,5

Since I upgraded to 1.3.5 version I got an error when tI try to get a token with the url http://localhost:8080/oauth/token

Error
2022-10-22 00:10:28.833 ERROR 5886 — [nio-8080-exec-6] o.s.s.o.provider.endpoint.TokenEndpoint : Handling error: BadSqlGrammarException, PreparedStatementCallback; bad SQL grammar [select token_id, token from oauth_access_token where authentication_id = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: relation “oauth_access_token” does not exist
Position : 29

Hi,

  1. What database do you use?
  2. Which Jmix Studio plugin version did you use for migration to 1.3.5?
  3. In the src/main/resources/<you_package>/liquibase/changelog do you see any changelog that removes the oauth_access_token database table?

Hello,
1-PostegreSQL
2-I don’t recall. I update as soon possible I don’t know if i did it before or after
3 yes the last changelog

<

databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.11.xsd"
        objectQuotingStrategy="QUOTE_ONLY_RESERVED_WORDS">
    <changeSet id="1" author="stickup">
        <dropTable cascadeConstraints="true" tableName="oauth_access_token"/>
    </changeSet>
    <changeSet id="2" author="stickup">
        <dropTable cascadeConstraints="true" tableName="oauth_refresh_token"/>
    </changeSet>
    <changeSet id="3" author="stickup">
        <dropTable cascadeConstraints="true" tableName="persistent_logins"/>
    </changeSet>
</databaseChangeLog>

How to recreate those 3 tables?

It seems that this changeset was generated because of this issue. It is a good practice to always review changesets generated by Studio before applying them on your database, especially the ones that remove tables.

Here are instructions that initially created these tables in jmix modules. You may try to create a new changeset in your app and insert these instructions there:

        <createTable tableName="oauth_access_token">
            <column name="authentication_id" type="varchar(255)">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="token_id" type="varchar(255)">
                <constraints  nullable="false"/>
            </column>
            <column name="token" type="${byte[].type}"/>
            <column name="user_name" type="varchar(255)"/>
            <column name="client_id" type="varchar(255)"/>
            <column name="authentication" type="${byte[].type}"/>
            <column name="refresh_token" type="varchar(255)"/>
        </createTable>

        <createTable tableName="oauth_refresh_token">
            <column name="token_id" type="varchar(255)">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="token" type="${byte[].type}"/>
            <column name="authentication" type="${byte[].type}"/>
        </createTable>

        <createTable tableName="persistent_logins">
            <column name="series" type="varchar(64)">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="username" type="varchar(64)">
                <constraints nullable="false"/>
            </column>
            <column name="token" type="varchar(64)">
                <constraints nullable="false"/>
            </column>
            <column name="last_used" type="timestamp">
                <constraints nullable="false"/>
            </column>
        </createTable>
1 Like

it works Thanks