Datasette plugin for modifying table schemas
- Add new columns to a table
- Rename columns in a table
- Modify the type of columns in a table
- Re-order the columns in a table
- Rename a table
- Delete a table
- Change the primary key of a table to another column containing unique values
- Update the foreign key constraints on a table
- Add an index (or unique index) to a column on a table
- Drop an index from a table
Install this plugin in the same environment as Datasette.
pip install datasette-edit-schema
Navigate to /-/edit-schema/dbname/tablename
on your Datasette instance to edit a specific table.
Use /-/edit-schema/dbname
to create a new table in a specific database.
By default only the root actor can access the page - so you'll need to run Datasette with the --root
option and click on the link shown in the terminal to sign in and access the page.
The edit-schema
permission governs access. You can use permission plugins such as datasette-permissions-sql to grant additional access to the write interface.
These permission checks will call the permission_allowed()
plugin hook with three arguments:
action
will be the string"edit-schema"
actor
will be the currently authenticated actor - usually a dictionaryresource
will be the string name of the database
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-edit-schema
python3 -mvenv venv
source venv/bin/activate
Or if you are using pipenv
:
pipenv shell
Now install the dependencies and tests:
pip install -e '.[test]'
To run the tests:
pytest