{"id":12455,"date":"2025-10-24T11:29:48","date_gmt":"2025-10-24T02:29:48","guid":{"rendered":"https:\/\/sreake.com\/?p=12138"},"modified":"2026-02-10T16:15:09","modified_gmt":"2026-02-10T07:15:09","slug":"gemini-code-assist-prisma-review-2","status":"publish","type":"post","link":"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/","title":{"rendered":"Review your Prisma schemas with Gemini Code Assist for GitHub"},"content":{"rendered":"\n<p><em>This blog post is a translation of&nbsp;<a href=\"https:\/\/sreake.com\/blog\/gemini-code-assist-prisma-review\/\">a Japanese article<\/a>&nbsp;posted on June 30th, 2025. It has been changed as needed to reflect Gemini Code Assist for GitHub going from preview to GA.<\/em><\/p>\n\n\n\n<p>In general, database changes have a bigger impact than application code changes, and we naturally tend to be more prudent when applying them. A simple example of things going wrong is forgetting to change default value settings for columns like <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">createdAt<\/span><\/span><\/code> , losing the original data in the process. Considering this, it is important to minimize the amount of database changes going to production.<\/p>\n\n\n\n<p>One of the ways to do that is to simply be stricter with database-related code reviews! But review quality highly varies depending on the person conducting them, and they require someone with database domain knowledge, which often becomes a time bottleneck.<\/p>\n\n\n\n<p>To counter that, you would traditionally impose code review guidelines, coach reviewers, or increase the number of code reviewers. In fact, that was probably the only thing you could do\u2026 until GenAI, that is! We now have a way to automate reviews and save us some trouble.<\/p>\n\n\n\n<p>In this article, we are going to look at Google Cloud\u2019s <strong>Gemini Code Assist for Github<\/strong>, and put it to the test by implementing a review process for <a href=\"https:\/\/github.com\/prisma\/prisma\">Prisma<\/a> data modeling. Strap in!<\/p>\n\n\n\n<p><em>The code and style guides shown in this article are purely meant as examples. Exercise caution when using them in production.<\/em><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_75 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#What_is_Gemini_Code_Assist_for_GitHub\" >What is Gemini Code Assist for GitHub?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Customize_settings_with_configyaml\" >Customize settings with config.yaml<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#An_overview_of_configuration_settings\" >An overview of configuration settings<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Provide_a_style_guide_with_styleguidemd\" >Provide a style guide with styleguide.md<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#A_Practical_Example_Review_Prisma_Code_using_Gemini_Code_Assist_for_GitHub\" >A Practical Example: Review Prisma Code using Gemini Code Assist for GitHub<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#The_Prisma_schema_file_up_for_review\" >The Prisma schema file up for review<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Using_Gemini_Code_Assist_without_a_style_guide\" >Using Gemini Code Assist without a style guide<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Result_not_good_enough\" >Result: not good enough<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Enhancing_Gemini_Code_Assist_with_a_style_guide\" >Enhancing Gemini Code Assist with a style guide<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#The_styleguidemd_overview\" >The styleguide.md overview<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Result_way_better\" >Result: way better!<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Beyond_code_fixes_Adding_advanced_rules_to_the_style_guide\" >Beyond code fixes: Adding advanced rules to the style guide<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#The_styleguidemd_overview-2\" >The styleguide.md overview<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Result_great_But_not_perfect\" >Result: great! But not perfect<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/sreake.com\/en\/blog\/gemini-code-assist-prisma-review-2\/#References\" >References<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_Gemini_Code_Assist_for_GitHub\"><\/span>What is Gemini Code Assist for GitHub?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Gemini Code Assist for GitHub<\/strong>, <a href=\"https:\/\/developers.google.com\/gemini-code-assist\/docs\/review-github-code\">per Google<\/a>, \u201cbrings the power of Gemini to the pull request process by acting as a code reviewer.\u201d It can automatically review GitHub pull requests, find bugs and style problems, and even suggest code fixes.<\/p>\n\n\n\n<p>Gemini Code Assist uses the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">config.yaml<\/span><\/span><\/code> and <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code> files in your <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">.gemini\/<\/span><\/span><\/code> directory to apply settings at the repository or directory level.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Customize_settings_with_configyaml\"><\/span>Customize settings with <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">config.yaml<\/span><\/span><\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can customize Gemini Code Assist\u2019s behavior using the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">config.yaml<\/span><\/span><\/code> file. This includes choosing files to include or exclude during code review using <a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/glob-patterns\">glob patterns<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"An_overview_of_configuration_settings\"><\/span>An overview of configuration settings<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Be sure to check <a href=\"https:\/\/developers.google.com\/gemini-code-assist\/docs\/customize-gemini-behavior-github#add_configuration_files\">the documentation<\/a> for any updates to the configuration settings!<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">have_fun<\/span><\/span><\/code> : Enables fun features such as a poem in the initial pull request summary. <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Default: false<\/span><\/span><\/code><\/li><li><code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">ignore_patterns<\/span><\/span><\/code> : A list of <a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/glob-patterns\">glob patterns<\/a> for files and directories that Gemini Code Assist should ignore. Files matching any pattern in this list will be skipped during interactions. <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">Default: []<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">code_review<\/span><\/span><\/code> : Configuration for code reviews.<ul><li><code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">disable<\/span><\/span><\/code> : Disables Gemini from acting on pull requests. <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">Default: false<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">comment_severity_threshold<\/span><\/span><\/code> : The minimum severity of review comments to consider. Can choose from <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">LOW<\/span><\/span><\/code>, <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">MEDIUM<\/span><\/span><\/code>, <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">HIGH<\/span><\/span><\/code>, and <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">CRITICAL<\/span><\/span><\/code>. <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">Default: MEDIUM<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">max_review_comments<\/span><\/span><\/code> : the maximum number of review comments to consider. Use -1 for unlimited. <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">Default: -1<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">pull_request_opened<\/span><\/span><\/code> : Configuration for pull request opened events.<ul><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">help<\/span><\/span><\/code> : Posts a help message on pull request open. <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Default: false<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">summary<\/span><\/span><\/code> : Posts a pull request summary on the pull request open. <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Default: true<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">code_review<\/span><\/span><\/code> : Posts a code review on pull request open. <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Default: true<\/span><\/span><\/code><\/li><li><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">include_drafts<\/span><\/span><\/code> : Enables agent functionality on draft pull requests. <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Default: true<\/span><\/span><\/code><\/li><\/ul><\/li><\/ul><\/li><\/ul>\n\n\n\n<p>If you don\u2019t include any particular settings, Gemini Code Assist defaults to the following:<\/p>\n\n\n\n<pre class=\"wp-block-code code-block\"><code>have_fun: false\ncode_review:\n  disable: false\n  comment_severity_threshold: MEDIUM\n  max_review_comments: -1\n  pull_request_opened:\n    help: false\n    summary: true\n    code_review: true\n    include_drafts: true\nignore_patterns: &#91;]<\/code><\/pre>\n\n\n\n<p>As another point of reference, you can also look at <a href=\"https:\/\/github.com\/google-gemini\/gemini-cli\/blob\/1a6e4a119ed2684e740816d49072f328209dd9ca\/.gemini\/config.yaml\">Gemini CLI\u2019s own configuration file<\/a>. It mostly adheres to the default settings, except for <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">comment_severity_threshold<\/span><\/span><\/code> which is set to <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">HIGH<\/span><\/span><\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Provide_a_style_guide_with_styleguidemd\"><\/span>Provide a style guide with <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code> is a Markdown file used to specify information and rules you would like Gemini Code Assist to follow during code reviews. This is typically a chance to put your project\u2019s code guidelines, architecture style, and more in writing.<\/p>\n\n\n\n<p>In this article, we will showcase how, by using <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">styleguide.md<\/span><\/span><\/code>, your Gemini Code Assist-powered code review can improve significantly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"A_Practical_Example_Review_Prisma_Code_using_Gemini_Code_Assist_for_GitHub\"><\/span>A Practical Example: Review Prisma Code using Gemini Code Assist for GitHub<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let\u2019s actually put <strong>Gemini Code Assist for GitHub<\/strong> to the test! We\u2019ll see how it handles reviewing a data modeling PR for <a href=\"https:\/\/github.com\/prisma\/prisma\">Prisma<\/a>.<\/p>\n\n\n\n<p>We\u2019ll first look at how Gemini Code Assist manages without any style guide. We\u2019ll then add a style guide with basic code guidelines that Gemini Code Assist can reference in its review. Finally, we\u2019ll upgrade the style guide with specific data modeling rules to get an even better review!<\/p>\n\n\n\n<p>All the code covered in this article, as well as reviews performed by Gemini Code Assist, will be available in this Github repository:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\">https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_Prisma_schema_file_up_for_review\"><\/span><strong>The Prisma schema file up for review<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here\u2019s the Prisma schema file (<code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">prisma.schema<\/span><\/span><\/code>) we want to review.<\/p>\n\n\n\n<pre class=\"wp-block-code code-block\"><code>\/\/ This is your Prisma schema file,\n\/\/ learn more about it in the docs: &lt;https:\/\/pris.ly\/d\/prisma-schema>\n\n\/\/ Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?\n\/\/ Try Prisma Accelerate: &lt;https:\/\/pris.ly\/cli\/accelerate-init>\n\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n\nmodel User {\n  id        Int       @id @default(autoincrement())\n  email     String    @unique\n  name      String?\n  posts     Post&#91;]\n  profile   Profile?\n  createdAt DateTime\n  updatedAt DateTime\n  deletedAt DateTime?\n}\n\nmodel Profile {\n  id     Int     @id @default(autoincrement())\n  bio    String?\n  userId Int     @unique\n  user   User    @relation(fields: &#91;userId], references: &#91;id])\n}\n\nmodel Post {\n  id         Int        @id @default(autoincrement())\n  title      String\n  content    String?\n  published  Boolean    @default(false)\n  authorId   Int\n  author     User       @relation(fields: &#91;authorId], references: &#91;id])\n  categories Category&#91;]\n  createdAt  DateTime   @default(now())\n  updatedAt  DateTime   @updatedAt\n}\n\nmodel Category {\n  id    Int    @id @default(autoincrement())\n  name  String @unique\n  posts Post&#91;]\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_Gemini_Code_Assist_without_a_style_guide\"><\/span>Using Gemini Code Assist without a style guide<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let\u2019s first look at what <strong>Gemini Code Assist for GitHub<\/strong> does when it doesn\u2019t have any style guide to reference:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/pull\/5#discussion_r2173642355\">https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/pull\/5#discussion_r2173642355<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Result_not_good_enough\"><\/span>Result: not good enough<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Here, Gemini Code Assist points out a problem with the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">createdAt<\/span><\/span><\/code> and <code>updatedAt<\/code> columns. They do not have any default values set, so a <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">CREATE<\/span><\/span><\/code> operation will fail if they are not provided manually.<\/p>\n\n\n\n<p>On the other hand, Gemini Code Assist is not taking into account the overall application structure, such as all other tables having a <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">createdAt<\/span><\/span><\/code> and <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">updatedAt<\/span><\/span><\/code> columns that we could reference, or that other tables should implement Row-Level Security based on our User model. This is domain-specific context that cannot be easily inferred without a style guide.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Enhancing_Gemini_Code_Assist_with_a_style_guide\"><\/span>Enhancing Gemini Code Assist with a style guide<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Next, let\u2019s write a style guide to let <strong>Gemini Code Assist for GitHub<\/strong> know about our code guidelines.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_styleguidemd_overview\"><\/span>The <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code> overview<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>You can take a look at <a href=\"https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/blob\/f0a4562badcbf432875286645afb93370758eac4\/prisma-typescript\/prisma\/.gemini\/styleguide.md\">the complete style guide on GitHub<\/a>, but it essentially covers the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Putting naming conventions in place for model and column names<\/li><li>Providing primary key rules and data types for ID columns<\/li><li>Forbidding implicit many-to-many relations<\/li><li>Adding <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">createdAt<\/span><\/span><\/code>\/<code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">updatedAt<\/span><\/span><\/code> columns to all tables and setting them to auto-update<\/li><li>Enforcing explicit referential integrity for constrained fields on update and delete<\/li><li>Prefixing boolean columns with <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">is<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">has<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">can<\/span><\/span><\/code><\/li><li>Setting rules for model field ordering<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Result_way_better\"><\/span>Result: way better!<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Here\u2019s how Gemini Code Assist reviewed the code, this time with our style guide to go off of:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/pull\/8\">https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/pull\/8<\/a><\/p>\n\n\n\n<p>Gemini Code Assist pointed out the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>For the <code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">User<\/span><\/span><\/code> model:<ul><li>Use <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">uuid<\/span><\/span><\/code> for the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">id<\/span><\/span><\/code> column.<\/li><li>Add default value and auto-update settings to the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">createdAt<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">updatedAt<\/span><\/span><\/code> columns.<\/li><li>Order the fields correctly according to the style guide.<\/li><\/ul><\/li><li>For the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Profile<\/span><\/span><\/code> model:<ul><li>Use <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">uuid<\/span><\/span><\/code> for the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">id<\/span><\/span><\/code> column.<\/li><li>Create a primary key with <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">userId<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">id<\/span><\/span><\/code> columns for Row-Level Security.<\/li><li>Add <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">createdAt<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">updatedAt<\/span><\/span><\/code> columns.<\/li><li>Enforce referential integrity with the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">User<\/span><\/span><\/code> model.<\/li><li>Order the fields correctly according to the style guide.<\/li><\/ul><\/li><li>For the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Post<\/span><\/span><\/code> model:<ul><li>Use <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">uuid<\/span><\/span><\/code> for the <code>id<\/code> column.<\/li><li>Create a primary key with <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">userId<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">id<\/span><\/span><\/code> columns for Row-Level Security.<\/li><li>Avoid creating an implicit many-to-many relation with the <code><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Category<\/span><\/span><\/code><\/code> model.<\/li><li>Change the boolean <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">published<\/span><\/span><\/code> field\u2019s name to <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">isPublished<\/span><\/span><\/code>.<\/li><li>Enforce referential integrity with the <code><code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">User<\/span><\/span><\/code><\/code> model.<\/li><li>Order the fields correctly according to the style guide.<\/li><\/ul><\/li><li>For the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Category<\/span><\/span><\/code> model:<ul><li>Use <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">uuid<\/span><\/span><\/code> for the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">id<\/span><\/span><\/code> column.<\/li><li>Add default value and auto-update settings to the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">createdAt<\/span><\/span><\/code>\/<code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">updatedAt<\/span><\/span><\/code> columns.<\/li><li>Avoid creating an implicit many-to-many relation with the <code><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">Post<\/span><\/span><\/code><\/code> model.<\/li><\/ul><\/li><\/ul>\n\n\n\n<p>That is a lot! And it is proof that adding a style guide allows Gemini Code Assist to take into account the project\u2019s code guidelines. It is especially impressive that it is able to detect implicit many-to-many relations, something that is not easily doable by simply grepping the codebase.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Beyond_code_fixes_Adding_advanced_rules_to_the_style_guide\"><\/span>Beyond code fixes: Adding advanced rules to the style guide<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Finally, let\u2019s add data modeling rules to the style guide and see how different <strong>Gemini Code Assist for GitHub<\/strong> reviews our Prisma schema.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_styleguidemd_overview-2\"><\/span>The <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code> overview<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>You can find <a href=\"https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/blob\/bd49a4b67654a16c8c34ffdf3e318ad777f81f00\/prisma-typescript\/prisma\/.gemini\/styleguide.md?plain=1#L188-L300\">the updated style guide on GitHub<\/a>, but here\u2019s what we are adding:<\/p>\n\n\n\n<pre class=\"wp-block-code code-block\"><code>## 8. Deletion Strategy\n### 8.1. Deleted Tables\nInstead of soft deletion with a `deletedAt` field, we use separate deleted tables with database triggers to maintain a complete audit trail of deleted records.\n\nFor each main table that requires deletion tracking, create a corresponding deleted table with:\n- The same structure as the original table\n- An additional `deletedAt` timestamp field\n- An additional `deletedBy` field to track who deleted the record\n\n(Skipping example model for brevity)\n\n### 8.2. Deletion Triggers\nDatabase triggers MUST be created to automatically copy records to the deleted table before deletion. These triggers are managed in version-controlled .sql files as they are not part of the Prisma schema.\n\n(Skipping example trigger for brevity)\n\n### 8.3. Naming Convention for Deleted Tables\n- Deleted table names MUST follow the pattern: `Deleted{OriginalModelName}`\n- Example: `User` \u2192 `DeletedUser`, `Post` \u2192 `DeletedPost`\n\n### 8.4. Gemini Code Assist Implementation Notes\nWhen implementing deletion functionality, Gemini Code Assist should suggest the following changes:\n\n(Skipping for brevity)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Result_great_But_not_perfect\"><\/span>Result: great! But not perfect<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Here\u2019s our final Gemini Code review:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/pull\/9\">https:\/\/github.com\/nnaka2992\/gemini_code_assist_with_database\/pull\/9<\/a><\/p>\n\n\n\n<p>The gist of it is similar to the previous review, with one exception: Gemini Code Assist now points out that the <code><code><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\"><span style=\"color:#ef7133\" class=\"tadv-color\">User<\/span><\/span><\/code><\/code> model contains a <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">deletedAt<\/span><\/span><\/code> column, and suggests to instead archive deleted user records in a separate <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">DeletedUser<\/span><\/span><\/code> model.<\/p>\n\n\n\n<p>This demonstrates how Gemini Code Assist can make suggestions based on an updated style guide. However, it does fall short of actually providing code for the <code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">DeletedUser<\/span><\/span><\/code> model. This could be solved by just rerunning Gemini Code Assist, but it does illustrate one of the potential limitations of current coding agents.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This blog post introduced a method for partially automating database-related reviews using Gemini Code Assist for GitHub, a generative AI tool.<\/p>\n\n\n\n<p>The accuracy of the reviews changed significantly before and after providing coding standards, and it also became possible to generate change suggestions for rules that delve into data modeling. This indicates the potential to greatly simplify data modeling reviews by saving SQL anti-patterns and data modeling anti-patterns as a <code><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code><\/code>.<\/p>\n\n\n\n<p>This will enable safer database changes even in organizations without a database engineer. In organizations that do have a database engineer, it will reduce the engineer&#8217;s review burden, allowing them to focus on more advanced and essential tasks.<\/p>\n\n\n\n<p>At the same time, it can be said that for anti-patterns and rules that are specific to an organization and difficult to generalize, a database engineer will need to periodically organize the context and cultivate the <code><code><span style=\"color:#ef7133\" class=\"tadv-color\"><span style=\"background-color:#e9edf1\" class=\"tadv-background-color\">styleguide.md<\/span><\/span><\/code><\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"References\"><\/span>References<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/prisma\/prisma\">prisma\/prisma<\/a><\/li><li><a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/glob-patterns\">Glob Patterns Reference<\/a><\/li><li><a href=\"https:\/\/developers.google.com\/gemini-code-assist\/docs\/customize-gemini-behavior-github\">Customize Gemini Code Assist behavior in GitHub<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Hello from the Sreake team! Here, you&#8217;ll learn what Gemini Code Assist for GitHub is, and how you can use it to review Prisma database schemas. Hop in!<\/p>\n","protected":false},"author":45,"featured_media":12139,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_locale":"en_US","_original_post":"https:\/\/sreake.com\/?p=11427","footnotes":""},"categories":[17],"tags":[48,23],"class_list":["post-12455","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-google-cloud","tag-enginner-blog","en-US"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/posts\/12455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/comments?post=12455"}],"version-history":[{"count":1,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/posts\/12455\/revisions"}],"predecessor-version":[{"id":13525,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/posts\/12455\/revisions\/13525"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/media\/12139"}],"wp:attachment":[{"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/media?parent=12455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/categories?post=12455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sreake.com\/wp-json\/wp\/v2\/tags?post=12455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}