Skip to content
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

Allow schema update in remote server edition #5612

Closed
Tracked by #3920
ijreilly opened this issue May 27, 2024 · 1 comment
Closed
Tracked by #3920

Allow schema update in remote server edition #5612

ijreilly opened this issue May 27, 2024 · 1 comment
Assignees

Comments

@ijreilly
Copy link
Collaborator

No description provided.

Copy link
Contributor

greptile-apps bot commented May 27, 2024

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :).

To allow schema updates in remote server edition, follow these steps:

  1. Update DTO: Modify UpdateRemoteServerInput in src/modules/remote-server/dto/update-remote-server.input.ts to include the schema field.
@InputType()
export class UpdateRemoteServerInput {
  // existing fields
  @Field(() => String, { nullable: true })
  schema?: string;
}
  1. Service Update: Update updateRemoteServer method in src/modules/remote-server/remote-server.service.ts to handle the schema field.
async updateRemoteServer(id: string, updateRemoteServerInput: UpdateRemoteServerInput): Promise<RemoteServer> {
  const { schema, ...rest } = updateRemoteServerInput;
  const remoteServer = await this.remoteServerRepository.preload({ id, ...rest });
  if (schema) {
    // handle schema update logic
  }
  return this.remoteServerRepository.save(remoteServer);
}
  1. SQL Query Construction: Ensure build-update-remote-server-raw-query in src/modules/remote-server/utils/build-update-remote-server-raw-query.utils.ts constructs the correct SQL query for schema updates.
export function buildUpdateRemoteServerRawQuery(updateRemoteServerInput: UpdateRemoteServerInput): string {
  const { schema, ...rest } = updateRemoteServerInput;
  let query = 'UPDATE remote_servers SET ';
  // existing query construction
  if (schema) {
    query += `schema = '${schema}', `;
  }
  query = query.slice(0, -2); // remove trailing comma
  query += ' WHERE id = $1';
  return query;
}
  1. Handle Table Creation: Update createAvailableTables method in src/modules/distant-table/distant-table.service.ts to handle the creation of available tables from the updated schema.
async createAvailableTables(schema: string): Promise<void> {
  // logic to create tables based on the schema
}

References

@charlesBochet charlesBochet moved this from 🆕 New to 🔖 Planned in 🎯 Roadmap & Sprints May 28, 2024
@ijreilly ijreilly assigned thomtrp and unassigned ijreilly May 28, 2024
@github-project-automation github-project-automation bot moved this from 🔖 Planned to ✅ Done in 🎯 Roadmap & Sprints May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants