Repository: mathesar-foundation/mathesar

Issue:
Modify page routing to allow for any database name
## Current behavior

- Many of our pages have URLs that begin with the database name.
- We also have routes that begin with things like `administration` and `auth`.
- Those routing rules produce an ambiguous routing grammar making it impossible to use Mathesar with a database named "administration" (for example).

## Desired behavior

We should change `/<db_name>/` to `/db/<db_name>`




Discussion:
To make the routing rules unambiguous, one possible solution would be to add a prefix, such as "/db/", before the database name in the URL. This way, even if the database name is "administration" or "auth", the URLs would still be clear and distinguishable. However, other options could also be considered, like using a different prefix, like "/data/", or using a different structure for the URLs altogether. It ultimately depends on the requirements and goals of the system.

I would like to get assign and help 
@Aadijindal07 this is restricted to maintainers. Please find an issue without a `restricted` label.
@kgodey This has been on my mind as well and I'd like to move this to launch blockers. We are sure to run into some issue from our users because of such restricted routes, and I think the fix should be small enough once we decide on the approach.
@pavish I made the priority high, but I don't think this blocks launch. If we have time before launch, we can do it.
+1 from me. I have expressed my concerns about having a wildcard URL route capture in a few other discussions as well. In addition to the concerns expressed by @seancolsen, 

1. Having a wildcard URL leads to debugging nightmares, for example, if I mistyped a URL or if a particular route is configured incorrectly, we would end up getting a "Database not found" error instead of an incorrect URL error
2. This also leads to us having to be mindful of the order in which the URLs are placed on the backend.
> One possibility would be changing /<db_name>/ to /db/<db_name>, but we may want to consider other options as well

I think this sounds like a good solution. We should handle this issue sooner than later since the url change will affect users who bookmark links.

@seancolsen @silentninja What are your thoughts on this? Can we finalize this behaviour and mark the issue as ready?
Good call, @pavish. I un-drafted it.
I'm adding this as a nice-to-have for `0.1.2` since this seems to be an issue that we can fix quick and has high impact.
> Can we finalize this behaviour and mark the issue as ready?

Yes

Resolving patch:
diff --git a/mathesar/urls.py b/mathesar/urls.py
--- a/mathesar/urls.py
+++ b/mathesar/urls.py
@@ -46,9 +46,10 @@
     path('administration/users/', views.admin_home, name='admin_users_home'),
     path('administration/users/<user_id>/', views.admin_home, name='admin_users_edit'),
     path('administration/update/', views.admin_home, name='admin_update'),
-    path('<db_name>/', views.schemas, name='schemas'),
+    path('db/', views.home, name='db_home'),
+    path('db/<db_name>/', views.schemas, name='schemas'),
     re_path(
-        r'^(?P<db_name>\w+)/(?P<schema_id>\w+)/',
+        r'^db/(?P<db_name>\w+)/(?P<schema_id>\w+)/',
         views.schema_home,
         name='schema_home'
     ),


Test patch: