Locations 0.5.0: Locations owned by a person or an organization
Locations 0.5.0 lets a location belong to a person or an organization account in the PhoenixKit locations module, so users can manage their own sites while admins keep the full list. It also ships the module’s own migrations.
Owned and global locations
A location can now have an owner: a user or an organization account. Without an owner it is global. On the location form an owner picker (Search users by email or name…) sets it, with No owner (global) and Remove owner, and a note explains that a location with an owner is private to that account and that the change applies on save. The locations list gets an Owner column and an All / Global / Owned filter.
A person who belongs to an organization account sees and manages that organization’s locations, and the locations they create belong to the organization, so the whole team shares them. Deleting a user also deletes the locations they own, with an activity log entry for each.
Two levels of permission
The locations permission now covers only the locations a user or their organization owns: the list, create, edit, delete and the Structure page. A new sub-permission, Manage all locations, adds every location, setting owners, internal notes, attachments and the Types pages. Admin receives it automatically when the app starts, and Owner holds every permission. The same /admin/locations pages serve both kinds of user, and every action is checked on the server, not only hidden. The place picker that other modules use can be limited to an owner too.
Security fixes
- The Structure page could rename or delete a space from a forged request even when the space belonged to another location. Space actions now accept only spaces of the loaded location, and each Structure change checks access to the location first.
- A files folder or featured image id sent by the browser could be stored and point later file actions at another folder. These now come only from the server.
- A malformed id in a Structure page or place picker event no longer crashes the page, and the type badges on the location form accept only the types the form offered.
Upgrading
This release is breaking for apps with custom roles. A role that holds locations now sees only its own locations: grant it Manage all locations if it should manage every location.
Run mix phoenix_kit.update after updating the dependency. The module now has its own migration chain: V1 takes over the four tables core already created, with nothing changed except a version marker, and V2 adds the owner_uuid column and its index. No migration drops a table. Deploy the new version only after the migration has run: every location query needs the new column and fails until it exists. Existing locations have no owner, so they stay global.
Full release notes: Locations 0.5.0
0.5.0 · 15 September 2026
⚠️ Breaking for hosts with custom roles: the locations permission now
covers only the locations a user (or their organization) owns. Grant the new
locations.manage_all sub-permission to roles that should manage every
location. Admin receives it automatically at boot; Owner holds every key.
Run mix phoenix_kit.update after upgrading: this release ships its own
migrations. Deploy the new version only after that migration has run:
Location now reads owner_uuid, and every location query fails until the
column exists.
Added
- Module-owned migrations (
PhoenixKitLocations.Migrations, returned frommigration_module/0; version tracked as apkloc_schema:<N>comment onphoenix_kit_locations).mix phoenix_kit.updatediscovers the chain and generates the host migration.- V1 adopts the four tables core’s V135 baseline creates, with identical DDL and object names. On existing installs only the version marker is new; no core release is required.
- V2 adds a nullable
owner_uuidtophoenix_kit_locations(foreign key tophoenix_kit_users,ON DELETE CASCADE) and its index. down/1never drops a table.
- Location ownership. A location can belong to a person or an organization
account; without an owner it is global.
- Set the owner with
create_location(attrs, owner_uuid: uuid)or change it withset_location_owner/3(logslocation.owner_changed). Anowner_uuidinsideattrsis ignored, so forms can’t reassign ownership. list_locations/1,count_locations/1andfind_similar_addresses/5take anowner_uuid:filter: a uuid, a list of uuids,nil(global only) or:any(every owned location). Omitting it keeps returning everything.get_location_for_owner/2resolves a location only for its owner(s).- Deleting a user deletes the locations they own;
before_user_delete/1logs alocation.deletedentry for each first.
- Set the owner with
- Owner-scoped access (
PhoenixKitLocations.Policy, the bookings pattern): the same/admin/locationspages serve both kinds of user.- Base
locations: list, create, edit, delete and Structure for locations owned by the user or by the user’s organization. - Sub-permission
locations.manage_all: every location, assigning owners, internal notes, attachments and the Types pages.
- Base
- Organization sharing. A person who belongs to an organization account
sees and manages its locations, and locations they create belong to the
organization (
Policy.owner_uuids/1,Policy.new_owner_uuid/1). - Admin owner controls: an Owner column and All / Global / Owned filter on the list, and an owner picker on the location form.
PlacePicker:owner_uuidattr (uuid, list,nilor:any), enforced on selection as well as search.
Fixed
- The Structure page renamed or deleted a space from a forged event even when the space belonged to a different location. Space actions now accept only spaces in the loaded location, and every Structure write re-checks access to the location first.
- A client-sent
files_folder_uuid/featured_image_uuidin a location’s or space’sdatacould be stored and aim later file actions at another folder. Attachment pointers now come only from server-side state. - A malformed uuid in a Structure page or
PlacePickerevent no longer crashes the LiveView. toggle_typeaccepts only types the form offered (or that are already linked).
Locations 0.5.0. Install or update: {:phoenix_kit_locations, "~> 0.5"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.