8000 fix!: update WorkspaceOwnerName to use user.name instead of user.username by BrunoQuaresma · Pull Request #18025 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix!: update WorkspaceOwnerName to use user.name instead of user.username #18025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 27, 2025
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Fix migration down
  • Loading branch information
BrunoQuaresma committed May 25, 2025
commit aba62bf53507eb1ff4ffa853d76432c1ccbc3d1f
10000
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
-- Recreate `template_version_with_user` as described in dump.sql
DROP VIEW template_version_with_user;

CREATE VIEW template_version_with_user AS
SELECT
template_versions.id,
template_versions.template_id,
template_versions.organization_id,
template_versions.created_at,
template_versions.updated_at,
template_versions.name,
template_versions.readme,
template_versions.job_id,
template_versions.created_by,
template_versions.external_auth_providers,
template_versions.message,
template_versions.archived,
template_versions.source_example_id,
COALESCE(
visible_users.avatar_url,
''::text
) AS created_by_avatar_url,
COALESCE(
visible_users.username,
''::text
) AS created_by_username
FROM (
template_versions
LEFT JOIN visible_users ON (
template_versions.created_by = visible_users.id
)
);
DROP VIEW workspace_build_with_user;

COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';
DROP VIEW template_with_names;

DROP VIEW workspaces_expanded;

DROP VIEW visible_users;

-- Recreate `visible_users` as described in dump.sql

CREATE VIEW visible_users AS
SELECT users.id, users.username, users.avatar_url
FROM users;

COMMENT ON VIEW visible_users IS 'Visible fields of users are allowed to be joined with other tables for including context of other resources.';

-- Recreate `workspace_build_with_user` as described in dump.sql
DROP VIEW workspace_build_with_user;

CREATE VIEW workspace_build_with_user AS
SELECT
Expand Down Expand Up @@ -72,64 +54,7 @@ FROM (

COMMENT ON VIEW workspace_build_with_user IS 'Joins in the username + avatar url of the initiated by user.';

-- Recreate `workspaces_expanded` as described in dump.sql
DROP VIEW workspaces_expanded;

CREATE VIEW workspaces_expanded AS
SELECT
workspaces.id,
workspaces.created_at,
workspaces.updated_at,
workspaces.owner_id,
workspaces.organization_id,
workspaces.template_id,
workspaces.deleted,
workspaces.name,
workspaces.autostart_schedule,
workspaces.ttl,
workspaces.last_used_at,
workspaces.dormant_at,
workspaces.deleting_at,
workspaces.automatic_updates,
workspaces.favorite,
workspaces.next_start_at,
visible_users.avatar_url AS owner_avatar_url,
visible_users.username AS owner_username,
organizations.name AS organization_name,
organizations.display_name AS organization_display_name,
organizations.icon AS organization_icon,
organizations.description AS organization_description,
templates.name AS template_name,
templates.display_name AS template_display_name,
templates.icon AS template_icon,
templates.description AS template_description
FROM (
(
(
workspaces
JOIN visible_users ON (
(
workspaces.owner_id = visible_users.id
)
)
)
JOIN organizations ON (
(
workspaces.organization_id = organizations.id
)
)
)
JOIN templates ON (
(
workspaces.template_id = templates.id
)
)
);

COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.';

-- Recreate `template_with_names` as described in dump.sql
DROP VIEW template_with_names;

CREATE VIEW template_with_names AS
SELECT
Expand Down Expand Up @@ -195,7 +120,6 @@ FROM (
COMMENT ON VIEW template_with_names IS 'Joins in the display name information such as username, avatar, and organization name.';

-- Recreate `template_version_with_user` as described in dump.sql
DROP VIEW template_version_with_user;

CREATE VIEW template_version_with_user AS
SELECT
Expand Down Expand Up @@ -223,19 +147,63 @@ SELECT
FROM (
template_versions
LEFT JOIN visible_users ON (
(
template_versions.created_by = visible_users.id
)
template_versions.created_by = visible_users.id
)
);

COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.';

-- Recreate `visible_users` as described in dump.sql
DROP VIEW visible_users;
-- Recreate `workspaces_expanded` as described in dump.sql

CREATE VIEW visible_users AS
SELECT users.id, users.username, users.avatar_url
FROM users;
CREATE VIEW workspaces_expanded AS
SELECT
workspaces.id,
workspaces.created_at,
workspaces.updated_at,
workspaces.owner_id,
workspaces.organization_id,
workspaces.template_id,
workspaces.deleted,
workspaces.name,
workspaces.autostart_schedule,
workspaces.ttl,
workspaces.last_used_at,
workspaces.dormant_at,
workspaces.deleting_at,
workspaces.automatic_updates,
workspaces.favorite,
workspaces.next_start_at,
visible_users.avatar_url AS owner_avatar_url,
visible_users.username AS owner_username,
organizations.name AS organization_name,
organizations.display_name AS organization_display_name,
organizations.icon AS organization_icon,
organizations.description AS organization_description,
templates.name AS template_name,
templates.display_name AS template_display_name,
templates.icon AS template_icon,
templates.description AS template_description
FROM (
(
(
workspaces
JOIN visible_users ON (
(
workspaces.owner_id = visible_users.id
)
)
)
JOIN organizations ON (
(
workspaces.organization_id = organizations.id
)
)
)
JOIN templates ON (
(
workspaces.template_id = templates.id
)
)
);

COMMENT ON VIEW visible_users IS 'Visible fields of users are allowed to be joined with other tables for including context of other resources.';
COMMENT ON VIEW workspaces_expanded IS 'Joins in the display name information such as username, avatar, and organization name.';
Loading
0