Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2d3c85d
Add create table UI
simonw Jun 17, 2026
b40665d
Add alter table JSON API
simonw Jun 17, 2026
fdd1b61
Add alter table modal
simonw Jun 17, 2026
15a3ac5
Ran Prettier
simonw Jun 17, 2026
c9c79fd
Isolate Unix domain socket test server paths
simonw Jun 17, 2026
4115213
Precompute action permissions for table pages
simonw Jun 17, 2026
8cec528
Test against pyodide/v314.0.0
simonw Jun 17, 2026
1972ba8
Split table create and alter views
simonw Jun 17, 2026
9766a9c
Add foreign keys to create table API
simonw Jun 17, 2026
9d9a2d3
Add foreign keys to alter table API
simonw Jun 17, 2026
2900efb
/db/table/-/foreign-key-suggestions API
simonw Jun 17, 2026
a6ef65f
/<database>/-/foreign-key-targets API endpoint
simonw Jun 17, 2026
21c156d
Expose foreign key targets to create table UI
simonw Jun 18, 2026
1f863de
Add foreign key controls to create table dialog
simonw Jun 18, 2026
c77dad9
More robust test_datasette_https_server.sh test
simonw Jun 19, 2026
e834008
Make custom type and foreign key mutually exclusive
simonw Jun 20, 2026
354780a
Drop table button in alter dialog
simonw Jun 20, 2026
a87c4ac
Object not chain of ifs
simonw Jun 22, 2026
b02999b
Fix broken Playwright tests
simonw Jun 22, 2026
17876cc
Keyword arguments for readability
simonw Jun 22, 2026
c4aead6
Ran prettier
simonw Jun 22, 2026
084df1f
Removed the alter table dry run feature
simonw Jun 22, 2026
a2e7596
sqlite-utils>=3.30,<4.0
simonw Jun 22, 2026
87354cf
not_null, default and default_exr support for create table API columns
simonw Jun 22, 2026
4b219be
Alter table API can now rename tables, refs #2788
simonw Jun 22, 2026
dada4de
Fix for Safari select box heights
simonw Jun 22, 2026
063b04a
Expose foreign key data to alter table UI
simonw Jun 22, 2026
fa43aba
Unify create and alter table modal controls
simonw Jun 22, 2026
2ebae5e
Add rename table controls to alter table dialog
simonw Jun 22, 2026
b932d0d
current_unixtime and current_unixtime_ms default_expr options
simonw Jun 22, 2026
b3b5c25
Draft changelog for create/alter table UI, refs #2787, #2788
simonw Jun 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@
from .views.database import (
database_download,
DatabaseView,
TableCreateView,
QueryView,
)
from .views.table_create_alter import (
DatabaseForeignKeyTargetsView,
TableAlterView,
TableCreateView,
TableForeignKeySuggestionsView,
)
from .views.execute_write import ExecuteWriteAnalyzeView, ExecuteWriteView
from .views.stored_queries import (
QueryCreateAnalyzeView,
Expand Down Expand Up @@ -2562,6 +2567,10 @@ def add_route(view, regex):
r"/(?P<database>[^\/\.]+)(\.(?P<format>\w+))?$",
)
add_route(TableCreateView.as_view(self), r"/(?P<database>[^\/\.]+)/-/create$")
add_route(
DatabaseForeignKeyTargetsView.as_view(self),
r"/(?P<database>[^\/\.]+)/-/foreign-key-targets$",
)
add_route(
QueryListView.as_view(self),
r"/(?P<database>[^\/\.]+)/-/queries(\.(?P<format>json))?$",
Expand Down Expand Up @@ -2626,6 +2635,14 @@ def add_route(view, regex):
TableUpsertView.as_view(self),
r"/(?P<database>[^\/\.]+)/(?P<table>[^\/\.]+)/-/upsert$",
)
add_route(
TableAlterView.as_view(self),
r"/(?P<database>[^\/\.]+)/(?P<table>[^\/\.]+)/-/alter$",
)
add_route(
TableForeignKeySuggestionsView.as_view(self),
r"/(?P<database>[^\/\.]+)/(?P<table>[^\/\.]+)/-/foreign-key-suggestions$",
)
add_route(
TableSetColumnTypeView.as_view(self),
r"/(?P<database>[^\/\.]+)/(?P<table>[^\/\.]+)/-/set-column-type$",
Expand Down
29 changes: 29 additions & 0 deletions datasette/default_table_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from datasette import hookimpl
from datasette.resources import TableResource


@hookimpl
def table_actions(datasette, actor, database, table, request):
async def inner():
db = datasette.get_database(database)
if not db.is_mutable:
return []
if not await datasette.allowed(
action="alter-table",
resource=TableResource(database=database, table=table),
actor=actor,
):
return []
return [
{
"type": "button",
"label": "Alter table",
"description": "Change columns and primary key for this table.",
"attrs": {
"aria-label": "Alter table {}".format(table),
"data-table-action": "alter-table",
},
}
]

return inner
1 change: 1 addition & 0 deletions datasette/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"datasette.default_debug_menu",
"datasette.default_jump_items",
"datasette.default_database_actions",
"datasette.default_table_actions",
"datasette.default_query_actions",
"datasette.handle_exception",
"datasette.forbidden",
Expand Down
Loading
Loading