Skip to content

[Bug] Development access token generation fails due to missing 'role' column in 'users' table #1334

@geraldnyeo

Description

@geraldnyeo

Running mix cadet.token <role> results in the following Ecto.QueryError:

** (Ecto.QueryError) lib/mix/tasks/token.ex:65: field `role` in `where` does not exist in schema Cadet.Accounts.User in query:

from u0 in Cadet.Accounts.User,
  where: u0.role == ^"student",
  order_by: [asc: u0.id],
  limit: 1,
  select: u0

Steps to Reproduce

  1. Clone the master branch of the backend repository.
  2. Setup the local development environment, as per the "Setting up your local development environment" section of the README.
  3. Run mix cadet.token <role>

Root Cause
The 20210531155751_multitenant_upgrade.exs migration removes the 'role' column from the 'users' table (it is shifted to the 'courses' table). The User schema has been similarly updated to remove the 'role' field.

Proposed Fix
The query in the test_user function in lib/mix/tasks/token.ex can be updated to include a join clause between the 'users' and 'courses' table.

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingnice-to-haveIssue is a non-critical, non-important

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions