Issue: TestFKMigrationRegression fails with error in view notes_public: no such table: main.note
Author: vkrizan
State: closed
Created: 2022-03-07 17:04:43

TestFKMigrationRegression test_fk_migration is failing during build in Fedora 37.
https://koji.fedoraproject.org/koji/taskinfo?taskID=83790023
```
======================================================================
ERROR: test_fk_migration (tests.regressions.TestFKMigrationRegression)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3160, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: error in view notes_public: no such table: main.note
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/builddir/build/BUILD/peewee-3.14.9/tests/regressions.py", line 1364, in test_fk_migration
    migrate(migrator.drop_column(
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 886, in migrate
    operation.run()
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 164, in run
    self._handle_result(method(*self.args, **kwargs))
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 155, in _handle_result
    result.run()
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 164, in run
    self._handle_result(method(*self.args, **kwargs))
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 158, in _handle_result
    self._handle_result(item)
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 155, in _handle_result
    result.run()
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 164, in run
    self._handle_result(method(*self.args, **kwargs))
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 153, in _handle_result
    self.execute(result)
  File "/builddir/build/BUILD/peewee-3.14.9/playhouse/migrate.py", line 149, in execute
    self.migrator.database.execute(node)
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3173, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3157, in execute_sql
    with __exception_wrapper__:
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 2933, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 191, in reraise
    raise value.with_traceback(tb)
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3160, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: error in view notes_public: no such table: main.note
======================================================================
Unable to import sqlite C extension tests, skipping.
Unable to import mysql-connector, skipping mysql_ext tests.
Postgresql test database "peewee_test" not found, skipping the postgres_ext tests.
Unable to import SQLCipher extension tests, skipping.
Unable to import sqlite extension tests, skipping.
ERROR: test_get_views (tests.db_tests.TestIntrospection)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3160, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: table notes_public already exists
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/builddir/build/BUILD/peewee-3.14.9/tests/base.py", line 260, in inner
    method(self)
  File "/builddir/build/BUILD/peewee-3.14.9/tests/db_tests.py", line 604, in test_get_views
    assertViews([
  File "/builddir/build/BUILD/peewee-3.14.9/tests/db_tests.py", line 580, in assertViews
    self.database.execute_sql('CREATE VIEW notes_public AS '
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3157, in execute_sql
    with __exception_wrapper__:
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 2933, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 191, in reraise
    raise value.with_traceback(tb)
  File "/builddir/build/BUILD/peewee-3.14.9/peewee.py", line 3160, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: table notes_public already exists
----------------------------------------------------------------------
Ran 923 tests in 6.697s
FAILED (errors=2, skipped=96)
```
([full build.log](https://github.com/coleifer/peewee/files/8199480/build.log))

Could it be racing?

Env:
```
python3                                 x86_64  3.10.2-3.fc36
sqlcipher                               x86_64  4.4.3-4.fc36
sqlite                                  x86_64  3.36.0-5.fc36 
```

Thank you.

CI is green: https://github.com/coleifer/peewee/actions/runs/1847421994

However by reordering the tests I was able to reproduce a similar traceback. Let me put together a fix. Thanks for the report.

Uploaded a new release, 3.14.10, which contains the fix. Thanks again.

Thank you as well.
I'm gonna package the new version...