<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roopal Guha Neogi</title>
    <description>The latest articles on DEV Community by Roopal Guha Neogi (@roopalgn).</description>
    <link>https://dev.to/roopalgn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4003765%2Fd29c45a3-c9cf-452e-865f-716b5d29b605.png</url>
      <title>DEV Community: Roopal Guha Neogi</title>
      <link>https://dev.to/roopalgn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roopalgn"/>
    <language>en</language>
    <item>
      <title>Why I Used Aurora DSQL Instead of PostgreSQL for Real-Time Collaborative Schema Design</title>
      <dc:creator>Roopal Guha Neogi</dc:creator>
      <pubDate>Fri, 26 Jun 2026 10:30:28 +0000</pubDate>
      <link>https://dev.to/roopalgn/why-i-used-aurora-dsql-instead-of-postgresql-for-real-time-collaborative-schema-design-3kbh</link>
      <guid>https://dev.to/roopalgn/why-i-used-aurora-dsql-instead-of-postgresql-for-real-time-collaborative-schema-design-3kbh</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;I built this project as my entry for the H0: Hack the Zero Stack hackathon, sponsored by Vercel and AWS. This post covers the core architectural decision behind VersionZero — a real-time collaborative database schema designer built on Next.js, Vercel, Amazon Aurora DSQL, and Amazon DynamoDB. #H0Hackathon&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Problem That Started Everything
&lt;/h2&gt;

&lt;p&gt;Two engineers. Different timezones. Same database schema to design.&lt;/p&gt;

&lt;p&gt;This is the daily reality for most distributed engineering teams today. And the tooling has not caught up. Teams either use Notion docs (not schema-aware, no SQL output), dbdiagram.io (only one person drives at a time), or they get on a Zoom call and share a screen — which means one engineer types while the other watches.&lt;/p&gt;

&lt;p&gt;I wanted to build a tool that solved this at the infrastructure level, not just the UI level. That distinction became everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Is Not Just a UX Problem
&lt;/h2&gt;

&lt;p&gt;When two engineers simultaneously design a shared schema, the backend storing that schema must guarantee both users always see the &lt;strong&gt;same state&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If engineer A in Bengaluru sees that table &lt;code&gt;orders&lt;/code&gt; has a column &lt;code&gt;status&lt;/code&gt;, but engineer B in Berlin hasn't received that update yet, they will design conflicting foreign keys. The schema becomes incoherent. That's not a UI glitch — that's a distributed consistency failure.&lt;/p&gt;

&lt;p&gt;This is what ruled out most databases immediately.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Not Traditional PostgreSQL?
&lt;/h2&gt;

&lt;p&gt;Aurora PostgreSQL is my default choice for 90% of projects. But for this specific use case, it has one hard problem: &lt;strong&gt;a primary region&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;All writes go to the primary. Read replicas are eventually consistent. If engineer B is in Europe and the primary is in &lt;code&gt;us-east-1&lt;/code&gt;, every schema mutation they make goes cross-continent to the primary before it's committed. This adds latency and creates a bottleneck. The "globally fast collaborative tool" narrative breaks the moment you look at where writes actually land.&lt;/p&gt;

&lt;p&gt;I also considered multi-master setups like Patroni, but that requires operational overhead that's completely out of scope for a product built in a hackathon window — and frankly, it's out of scope for most small teams in production too.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Not DynamoDB?
&lt;/h2&gt;

&lt;p&gt;DynamoDB Global Tables give you multi-region writes with sub-millisecond latency. That sounds perfect. But DynamoDB Global Tables use &lt;strong&gt;eventual consistency&lt;/strong&gt; — which means two users in different regions can briefly see different states.&lt;/p&gt;

&lt;p&gt;For presence data (cursor positions, who's online), eventual consistency is completely fine. Seeing a cursor 200ms out of date is not a problem.&lt;/p&gt;

&lt;p&gt;For schema state — the tables, columns, and relationships that form the contract the entire team builds against — eventual consistency is catastrophic. You cannot build a correct design tool on a database that allows two users to momentarily see different schemas.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Aurora DSQL Is the Only Correct Answer
&lt;/h2&gt;

&lt;p&gt;Aurora DSQL is Amazon's serverless distributed SQL database with &lt;strong&gt;multi-region active-active writes and synchronous consistency at commit time&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No primary region. Any region can accept writes.&lt;/li&gt;
&lt;li&gt;All regions see the same logical state.&lt;/li&gt;
&lt;li&gt;Conflicts are detected at commit time using &lt;strong&gt;Optimistic Concurrency Control (OCC)&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is what makes it fundamentally different from a traditional PostgreSQL setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  How OCC Works in DSQL
&lt;/h3&gt;

&lt;p&gt;Traditional databases use &lt;strong&gt;pessimistic locking&lt;/strong&gt;: when you start editing a row, the database locks it. Other writers wait. This prevents conflicts but creates deadlocks and kills throughput.&lt;/p&gt;

&lt;p&gt;DSQL uses &lt;strong&gt;optimistic concurrency&lt;/strong&gt;: no locks are held during transaction execution. Every transaction runs against a consistent snapshot of the database. At commit time, DSQL checks whether any other concurrent transaction modified the same rows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If &lt;strong&gt;no conflict&lt;/strong&gt;: both transactions commit successfully.&lt;/li&gt;
&lt;li&gt;If &lt;strong&gt;conflict&lt;/strong&gt;: one succeeds, the other receives error code &lt;code&gt;40001&lt;/code&gt; (&lt;code&gt;serialization_failure&lt;/code&gt;) and must retry from scratch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a collaborative tool, this model is strictly better. Two engineers editing &lt;strong&gt;different&lt;/strong&gt; tables simultaneously will always both succeed. Only two engineers editing the &lt;strong&gt;exact same column at the exact same millisecond&lt;/strong&gt; conflict — and even then, the retry resolves it in under 100ms.&lt;/p&gt;




&lt;h2&gt;
  
  
  The OCC Retry Wrapper
&lt;/h2&gt;

&lt;p&gt;Every mutation in VersionZero goes through this function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// lib/dsql.ts&lt;/span&gt;
&lt;span class="c1"&gt;// Aurora DSQL uses Optimistic Concurrency Control.&lt;/span&gt;
&lt;span class="c1"&gt;// Concurrent writes to the same rows cause one transaction to fail&lt;/span&gt;
&lt;span class="c1"&gt;// with error code 40001 (serialization_failure) at commit time.&lt;/span&gt;
&lt;span class="c1"&gt;// This wrapper retries automatically with exponential backoff.&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;withDSQLRetry&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PoolClient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;maxRetries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;maxRetries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getPool&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;BEGIN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;COMMIT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ROLLBACK&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="c1"&gt;// 40001 = serialization_failure — safe to retry&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;40001&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;maxRetries&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 50ms, 100ms, 150ms&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;release&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`DSQL: max retries (&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;maxRetries&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;) exceeded`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function is called on every &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PATCH&lt;/code&gt;, and &lt;code&gt;DELETE&lt;/code&gt; route in the API. The schema mutation and its audit log entry are written &lt;strong&gt;in the same transaction&lt;/strong&gt; — they are atomic. Either both succeed or both roll back. The audit trail is correct by construction, not by convention.&lt;/p&gt;




&lt;h2&gt;
  
  
  What DSQL Does Not Support (And Why That's Fine)
&lt;/h2&gt;

&lt;p&gt;DSQL breaks from standard PostgreSQL in a few important ways. Every limitation exists because of the distributed architecture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;REFERENCES&lt;/code&gt; (foreign key constraints):&lt;/strong&gt; Enforcing foreign keys globally requires coordination that undermines OCC. I enforce referential integrity in the API layer instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;JSONB&lt;/code&gt;:&lt;/strong&gt; Use &lt;code&gt;TEXT&lt;/code&gt; with &lt;code&gt;JSON.stringify&lt;/code&gt; / &lt;code&gt;JSON.parse&lt;/code&gt;. Simpler than it sounds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;SERIAL&lt;/code&gt; / &lt;code&gt;BIGSERIAL&lt;/code&gt;:&lt;/strong&gt; Sequences cannot be globally consistent across regions. Use &lt;code&gt;gen_random_uuid()&lt;/code&gt; instead — correct and safe in distributed environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No triggers, views, or PL/pgSQL:&lt;/strong&gt; Server-side compute belongs in the application layer for a distributed database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding &lt;em&gt;why&lt;/em&gt; each constraint exists made me a better distributed systems designer. It is not a list of PostgreSQL features DSQL forgot to implement. It is a list of features that are fundamentally incompatible with synchronous multi-region consensus.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Result
&lt;/h2&gt;

&lt;p&gt;VersionZero is a real-time collaborative database schema designer where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple engineers can simultaneously design tables, define columns, and draw relationships.&lt;/li&gt;
&lt;li&gt;DSQL guarantees they always see the same schema state.&lt;/li&gt;
&lt;li&gt;OCC conflict resolution is visible in the UI as a non-blocking toast.&lt;/li&gt;
&lt;li&gt;Every edit is logged atomically in the same transaction as the mutation itself.&lt;/li&gt;
&lt;li&gt;One button exports production-ready PostgreSQL DDL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The live demo is at &lt;strong&gt;&lt;a href="https://versionzero.vercel.app" rel="noopener noreferrer"&gt;https://versionzero.vercel.app&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full source code is at &lt;strong&gt;&lt;a href="https://github.com/Roopalgn/VercelAWS" rel="noopener noreferrer"&gt;https://github.com/Roopalgn/VercelAWS&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;*Built for the H0: Hack the Zero Stack hackathon by Vercel and AWS. &lt;/p&gt;

</description>
      <category>h0hackathon</category>
      <category>aws</category>
      <category>vercel</category>
      <category>auroradsql</category>
    </item>
  </channel>
</rss>
