Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

Re : Unable to (view not found)

$
0
0
For some reason, this problem went away: I ran into a lot of issues when trying to run the new changesets on PostgreSQL and after correcting all of the issues I was able to add the offending <dropView> without any issues.
What I did
  1. The error message came when I was trying to drop the userid column. Liquibase failed, because the userid colum was used by something else
  2. I had already dropped the fk constraints from the column to userid in the users table
  3. I dropped the index on the userid colum, then I got complaints from two other views using the column
  4. I dropped the views (I was no longer using them anyway)
    1.     <changeSet author="sb" id="drop-views-linking-to-account-user_id">
    2.         <dropView viewName="wage_payments_view" />
    3.         <dropView viewName="work_done_view" />
    4.     </changeSet>
  5. I now got an error message saying that the accounts_view was still using the column
  6. I put in the <dropView> that had failed earlier, and expected it to fail, except it didn't
    1.     <changeSet author="sb" id="drop-accounts-view">
    2.         <dropView viewName="accounts_view" />
    3.     </changeSet>
  7. Now I could run the changelog on PostgreSQL without errors (including dropping the userid column from the accounts table), so I tried running it on derby, and this time removing the view didn't fail
  8. So I put in a new and updated view without the userid column and this worked fine
    1.     <changeSet author="sb" id="create-new-accountsview">
    2.         <createView fullDefinition="false" viewName="accounts_view">
    3.             select accounts.account_id, accounts.username, first_name, last_name, SUM(transaction_amount) as balance
    4.             from users
    5.             join accounts on accounts.username=users.username
    6.             join transactions on transactions.account_id=accounts.account_id
    7.             group by accounts.account_id, accounts.username, first_name, last_name
    8.         </createView>
    9.     </changeSet>
  9. Now I'm trying to remove the view completely and I'm again told the view doesn't exist
    1.     <changeSet author="sb" id="drop-accounts-view-for-good">
    2.         <dropView viewName="accounts_view" />
    3.     </changeSet>
  10. The accounts_view, with the new username column in the accounts table, obviously exists when code is running, if not, the code would have failed at an early stage
  11. I thought it might have something to do with transactions used by the liquibase setup (when running in derby in memory, in test situations, I always set the database up from scratch) so I tried running the <dropView> from a separate <databaseChangelog> in a different file, but I still got the accounts_view not found
  12. I added a conditional to the <changeSet> removing the accounts_view
    1.     <changeSet author="sb" id="drop-accounts-view-for-good">
    2.         <preConditions onFail="CONTINUE" >
    3.             <not>
    4.                 <viewExists viewName="accounts_view" />
    5.             </not>
    6.         </preConditions>

    7.         <dropView viewName="accounts_view" />
    8.     </changeSet>
  13. Now I didn't get any errors when running the <changeLog> in derby, but the count of sucessful changeSets stayed the same
  14. I tried running the changelog in PostgreSQL again and here also it didn't fail, but I found the following in the log
    1. 2019-03-29T23:48:39,634 | INFO  | features-1-thread-1 | liquibase                        | 134 - org.liquibase.core - 3.5.3 | db-changelog/db-changelog-1.0.0.xml: db-changelog/db-changelog-1.0.0.xml::drop-accounts-view-for-good::sb: Continuing past: db-changelog/db-changelog-1.0.0.xml::drop-accounts-view-for-good::sb despite precondition failure due to onFail='CONTINUE': 
    2.           db-changelog/db-changelog-1.0.0.xml : Not precondition failed
  15. I thought it might have been the other blockers for removing userid that masked <dropView> of accounts the first time I  tried, but now I don't know what would be the candidates for such a masking? (I don't know why the index on the userid column and the other two views would mask accounts_view in the first place)
Ideas?

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>