Repository: ariga/atlas
Pull request #3010 (2024-07-30 15:23:37)

doc/website: modernize use case


Patch:
diff --git a/doc/website/package-lock.json b/doc/website/package-lock.json
index d78b0de5..8e2b8ad0 100644
--- a/doc/website/package-lock.json
+++ b/doc/website/package-lock.json
@@ -8,7 +8,7 @@
       "name": "website",
       "version": "0.0.0",
       "dependencies": {
-        "@ariga/atlas-website": "^0.0.54",
+        "@ariga/atlas-website": "^0.0.56",
         "@docusaurus/core": "^2.0.0-rc.1",
         "@docusaurus/plugin-client-redirects": "^2.4.1",
         "@docusaurus/plugin-ideal-image": "^2.4.1",
@@ -341,9 +341,9 @@
       }
     },
     "node_modules/@ariga/atlas-website": {
-      "version": "0.0.54",
-      "resolved": "https://registry.npmjs.org/@ariga/atlas-website/-/atlas-website-0.0.54.tgz",
-      "integrity": "sha512-fieHBl3Gf9AP068/olHrNQHXioPFsAt7NnRiWf9BXd0grnl/MdXa+8TTIMyS9CSSVXPlAgbWw+USRN1wacmlKQ==",
+      "version": "0.0.56",
+      "resolved": "https://registry.npmjs.org/@ariga/atlas-website/-/atlas-website-0.0.56.tgz",
+      "integrity": "sha512-TLJTY2fqIdehHwmE9rDskR2lrAhaEYq5IRYEShOxl5+NlWjmFUnzHk+dXU50sNIxKAij7ZH602fKKIUqXlfYKQ==",
       "dependencies": {
         "@amplitude/analytics-browser": "^1.9.4",
         "@types/amplitude-js": "^8.16.2",
@@ -362,7 +362,6 @@
         "react": "^17.0.1",
         "react-dom": "^17.0.1",
         "react-ga4": "^2.1.0",
-        "react-responsive": "^10.0.0",
         "react-router-dom": "^6.9.0",
         "react-scroll": "^1.8.9",
         "react-scroll-parallax": "^3.3.2",
@@ -9047,11 +9046,6 @@
         }
       }
     },
-    "node_modules/css-mediaquery": {
-      "version": "0.1.2",
-      "resolved": "https://registry.npmjs.org/css-mediaquery/-/css-mediaquery-0.1.2.tgz",
-      "integrity": "sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q=="
-    },
     "node_modules/css-minimizer-webpack-plugin": {
       "version": "4.2.2",
       "resolved": "https://registry.npmjs.org/css-minimizer-webpack-plugin/-/css-minimizer-webpack-plugin-4.2.2.tgz",
@@ -14742,11 +14736,6 @@
         "node": ">=10.17.0"
       }
     },
-    "node_modules/hyphenate-style-name": {
-      "version": "1.1.0",
-      "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.1.0.tgz",
-      "integrity": "sha512-WDC/ui2VVRrz3jOVi+XtjqkDjiVjTtFaAGiW37k6b+ohyQ5wYDOGkvCZa8+H0nx3gyvv0+BST9xuOgIyGQ00gw=="
-    },
     "node_modules/iconv-lite": {
       "version": "0.4.24",
       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
@@ -16736,14 +16725,6 @@
         "node": ">= 0.10.0"
       }
     },
-    "node_modules/matchmediaquery": {
-      "version": "0.4.2",
-      "resolved": "https://registry.npmjs.org/matchmediaquery/-/matchmediaquery-0.4.2.tgz",
-      "integrity": "sha512-wrZpoT50ehYOudhDjt/YvUJc6eUzcdFPdmbizfgvswCKNHD1/OBOHYJpHie+HXpu6bSkEGieFMYk6VuutaiRfA==",
-      "dependencies": {
-        "css-mediaquery": "^0.1.2"
-      }
-    },
     "node_modules/math-random": {
       "version": "1.0.4",
       "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.4.tgz",
@@ -21223,23 +21204,6 @@
         "webpack": ">=4.41.1 || 5.x"
       }
     },
-    "node_modules/react-responsive": {
-      "version": "10.0.0",
-      "resolved": "https://registry.npmjs.org/react-responsive/-/react-responsive-10.0.0.tgz",
-      "integrity": "sha512-N6/UiRLGQyGUqrarhBZmrSmHi2FXSD++N5VbSKsBBvWfG0ZV7asvUBluSv5lSzdMyEVjzZ6Y8DL4OHABiztDOg==",
-      "dependencies": {
-        "hyphenate-style-name": "^1.0.0",
-        "matchmediaquery": "^0.4.2",
-        "prop-types": "^15.6.1",
-        "shallow-equal": "^3.1.0"
-      },
-      "engines": {
-        "node": ">=14"
-      },
-      "peerDependencies": {
-        "react": ">=16.8.0"
-      }
-    },
     "node_modules/react-router": {
       "version": "5.3.4",
       "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.3.4.tgz",
@@ -23099,11 +23063,6 @@
         "node": ">=8"
       }
     },
-    "node_modules/shallow-equal": {
-      "version": "3.1.0",
-      "resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-3.1.0.tgz",
-      "integrity": "sha512-pfVOw8QZIXpMbhBWvzBISicvToTiM5WBF1EeAUZDDSb5Dt29yl4AYbyywbJFSEsRUMr7gJaxqCdr4L3tQf9wVg=="
-    },
     "node_modules/shallowequal": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
diff --git a/doc/website/package.json b/doc/website/package.json
index 1a1e6d5a..a2a8ce79 100644
--- a/doc/website/package.json
+++ b/doc/website/package.json
@@ -16,7 +16,7 @@
     "invalidate-cdn": "aws cloudfront create-invalidation --distribution-id E3VOJYSV9YO33D --paths \"/*\""
   },
   "dependencies": {
-    "@ariga/atlas-website": "^0.0.54",
+    "@ariga/atlas-website": "^0.0.56",
     "@docusaurus/core": "^2.0.0-rc.1",
     "@docusaurus/plugin-client-redirects": "^2.4.1",
     "@docusaurus/plugin-ideal-image": "^2.4.1",
diff --git a/doc/website/src/pages/use-cases/modernize-database-migrations.js b/doc/website/src/pages/use-cases/modernize-database-migrations.js
new file mode 100644
index 00000000..6f83af3b
--- /dev/null
+++ b/doc/website/src/pages/use-cases/modernize-database-migrations.js
@@ -0,0 +1,13 @@
+import React from "react";
+import Layout from "@theme/Layout";
+import { ModernizeSchemaMigrations } from "@ariga/atlas-website";
+
+import "@ariga/atlas-website/style.css";
+
+export default function () {
+  return (
+    <Layout>
+      <ModernizeSchemaMigrations />
+    </Layout>
+  );
+}
diff --git a/sql/postgres/migrate.go b/sql/postgres/migrate.go
index ee994085..bc051914 100644
--- a/sql/postgres/migrate.go
+++ b/sql/postgres/migrate.go
@@ -427,8 +427,8 @@ func (s *state) modifyTable(modify *schema.ModifyTable) error {
 			changes = append(changes, &migrate.Change{
 				Source:  change,
 				Comment: fmt.Sprintf("rename an index from %q to %q", change.From.Name, change.To.Name),
-				Cmd:     s.Build("ALTER INDEX").Ident(change.From.Name).P("RENAME TO").Ident(change.To.Name).String(),
-				Reverse: s.Build("ALTER INDEX").Ident(change.To.Name).P("RENAME TO").Ident(change.From.Name).String(),
+				Cmd:     s.Build("ALTER INDEX").SchemaResource(modify.T.Schema, change.From.Name).P("RENAME TO").Ident(change.To.Name).String(),
+				Reverse: s.Build("ALTER INDEX").SchemaResource(modify.T.Schema, change.To.Name).P("RENAME TO").Ident(change.From.Name).String(),
 			})
 		case *schema.ModifyForeignKey:
 			// Foreign-key modification is translated into 2 steps.


Test patch:
diff --git a/sql/postgres/migrate_test.go b/sql/postgres/migrate_test.go
index 1f5d9df9..3cde8a36 100644
--- a/sql/postgres/migrate_test.go
+++ b/sql/postgres/migrate_test.go
@@ -1489,6 +1489,9 @@ func TestPlanChanges(t *testing.T) {
 					},
 				},
 			},
+			options: []migrate.PlanOption{
+				func(o *migrate.PlanOptions) { o.SchemaQualifier = new(string) },
+			},
 			wantPlan: &migrate.Plan{
 				Reversible:    true,
 				Transactional: true,
@@ -1500,6 +1503,29 @@ func TestPlanChanges(t *testing.T) {
 				},
 			},
 		},
+		{
+			changes: []schema.Change{
+				&schema.ModifyTable{
+					T: schema.NewTable("t1").SetSchema(schema.New("s1")),
+					Changes: []schema.Change{
+						&schema.RenameIndex{
+							From: schema.NewIndex("a"),
+							To:   schema.NewIndex("b"),
+						},
+					},
+				},
+			},
+			wantPlan: &migrate.Plan{
+				Reversible:    true,
+				Transactional: true,
+				Changes: []*migrate.Change{
+					{
+						Cmd:     `ALTER INDEX "s1"."a" RENAME TO "b"`,
+						Reverse: `ALTER INDEX "s1"."b" RENAME TO "a"`,
+					},
+				},
+			},
+		},
 		// Invalid serial type.
 		{
 			changes: []schema.Change{