Flask-Tenants / flask-tenants

Multitenancy solution using Flask, SQLAlchemy, and PostgreSQL. Please join our Discord server at https://discord.gg/3AV2GkcB2Q.
MIT License
5 stars 4 forks source link

Tenant-scoped requests have a caching issue #17

Closed therealwokewok closed 2 months ago

therealwokewok commented 2 months ago

terminal >curl -X POST http://local.test:5000/create_tenant -H "Content-Type: application/json" -d "{\"name\": \"canary\", \"domain_name\": \"canary.local.test\", \"phone_number\": \"123-456-7890\", \"address\": \"123 Example St\"}" { "message": "Tenant canary created successfully", "tenant": { "address": "123 Example St", "domain_name": "canary.local.test", "id": 1, "name": "canary", "phone_number": "123-456-7890" } }

terminal >curl -X POST http://canary.local.test:5000/posts -H "Content-Type: application/json" -d "{\"title\": \"First Blog Post\", \"author\": \"Author A\", \"body\": \"This is the content of the first blog post.\"}" { "message": "Post created successfully" }

terminal >curl -X POST http://local.test:5000/create_tenant -H "Content-Type: application/json" -d "{\"name\": \"tenant2\", \"domain_name\": \"tenant2.local.test\", \"phone_number\": \"987-654-3210\", \"address\": \"456 Updated St\"}" { "message": "Tenant tenant2 created successfully", "tenant": { "address": "456 Updated St", "domain_name": "tenant2.local.test", "id": 2, "name": "tenant2", "phone_number": "987-654-3210" } }

terminal >curl -X POST http://tenant2.local.test:5000/posts -H "Content-Type: application/json" -d "{\"title\": \"Second Blog Post\", \"author\": \"Author B\", \"body\": \"This is the content of the second blog post.\"}" { "message": "Post created successfully" }

terminal >curl -X DELETE http://local.test:5000/delete_tenant/canary -H "Content-Type: application/json" { "message": "Tenant and its schema deleted successfully" }

terminal >curl -X POST http://tenant2.local.test:5000/posts -H "Content-Type: application/json" -d "{\"title\": \"Second Blog Post\", \"author\": \"Author B\", \"body\": \"This is the content of the third blog post.\"}" <!doctype html>

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "canary.posts" does not exist LINE 1: INSERT INTO canary.posts (title, body, author) VALUES ('Seco... Oberve that at the end, creating a tenant-scoped Post t otenant2 tries to create it in the canary schema. </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>