diff --git a/.gitea/issue_template/bug-report.yaml b/.gitea/issue_template/bug-report.yaml index 6edbca886f..6fab61fcdc 100644 --- a/.gitea/issue_template/bug-report.yaml +++ b/.gitea/issue_template/bug-report.yaml @@ -87,4 +87,3 @@ body: - SQLite - PostgreSQL - MySQL - - MSSQL diff --git a/Makefile b/Makefile index b66a998b52..5f3bc29a81 100644 --- a/Makefile +++ b/Makefile @@ -196,10 +196,6 @@ TEST_PGSQL_DBNAME ?= testgitea TEST_PGSQL_USERNAME ?= postgres TEST_PGSQL_PASSWORD ?= postgres TEST_PGSQL_SCHEMA ?= gtestschema -TEST_MSSQL_HOST ?= mssql:1433 -TEST_MSSQL_DBNAME ?= gitea -TEST_MSSQL_USERNAME ?= sa -TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1 .PHONY: all all: build @@ -309,7 +305,7 @@ clean: e2e*.test \ tests/integration/gitea-integration-* \ tests/integration/indexers-* \ - tests/mysql.ini tests/pgsql.ini tests/mssql.ini man/ \ + tests/mysql.ini tests/pgsql.ini man/ \ tests/e2e/gitea-e2e-*/ \ tests/e2e/indexers-*/ \ tests/e2e/reports/ tests/e2e/test-artifacts/ tests/e2e/test-snapshots/ @@ -612,27 +608,6 @@ test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql .PHONY: test-pgsql-migration test-pgsql-migration: migrations.pgsql.test migrations.individual.pgsql.test -generate-ini-mssql: - sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \ - -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \ - -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \ - -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \ - -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ - -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ - -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ - tests/mssql.ini.tmpl > tests/mssql.ini - -.PHONY: test-mssql -test-mssql: integrations.mssql.test generate-ini-mssql - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test - -.PHONY: test-mssql\#% -test-mssql\#%: integrations.mssql.test generate-ini-mssql - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.run $(subst .,/,$*) - -.PHONY: test-mssql-migration -test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test - .PHONY: playwright playwright: deps-frontend npx playwright install $(PLAYWRIGHT_FLAGS) @@ -669,14 +644,6 @@ test-e2e-pgsql: playwright e2e.pgsql.test generate-ini-pgsql test-e2e-pgsql\#%: playwright e2e.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./e2e.pgsql.test -test.run TestE2e/$* -.PHONY: test-e2e-mssql -test-e2e-mssql: playwright e2e.mssql.test generate-ini-mssql - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e - -.PHONY: test-e2e-mssql\#% -test-e2e-mssql\#%: playwright e2e.mssql.test generate-ini-mssql - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./e2e.mssql.test -test.run TestE2e/$* - .PHONY: test-e2e-debugserver test-e2e-debugserver: e2e.sqlite.test generate-ini-sqlite sed -i s/3003/3000/g tests/sqlite.ini @@ -690,10 +657,6 @@ bench-sqlite: integrations.sqlite.test generate-ini-sqlite bench-mysql: integrations.mysql.test generate-ini-mysql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . -.PHONY: bench-mssql -bench-mssql: integrations.mssql.test generate-ini-mssql - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . - .PHONY: bench-pgsql bench-pgsql: integrations.pgsql.test generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench . @@ -712,9 +675,6 @@ integrations.mysql.test: git-check $(GO_SOURCES) integrations.pgsql.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.pgsql.test -integrations.mssql.test: git-check $(GO_SOURCES) - $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.mssql.test - integrations.sqlite.test: git-check $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration -o integrations.sqlite.test -tags '$(TEST_TAGS)' @@ -734,11 +694,6 @@ migrations.pgsql.test: $(GO_SOURCES) generate-ini-pgsql $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.pgsql.test GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini ./migrations.pgsql.test -.PHONY: migrations.mssql.test -migrations.mssql.test: $(GO_SOURCES) generate-ini-mssql - $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.mssql.test - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini ./migrations.mssql.test - .PHONY: migrations.sqlite.test migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/integration/migration-test -o migrations.sqlite.test -tags '$(TEST_TAGS)' @@ -764,17 +719,6 @@ migrations.individual.pgsql.test: $(GO_SOURCES) migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* - -.PHONY: migrations.individual.mssql.test -migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql - for pkg in $(MIGRATION_PACKAGES); do \ - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' -test.failfast $$pkg || exit 1; \ - done - -.PHONY: migrations.individual.mssql.test\#% -migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql - GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$* - .PHONY: migrations.individual.sqlite.test migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite for pkg in $(MIGRATION_PACKAGES); do \ @@ -791,9 +735,6 @@ e2e.mysql.test: $(GO_SOURCES) e2e.pgsql.test: $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.pgsql.test -e2e.mssql.test: $(GO_SOURCES) - $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.mssql.test - e2e.sqlite.test: $(GO_SOURCES) $(GO) test $(GOTESTFLAGS) -c code.gitea.io/gitea/tests/e2e -o e2e.sqlite.test -tags '$(TEST_TAGS)' diff --git a/assets/go-licenses.json b/assets/go-licenses.json index ef4c7b3c00..472fcb495b 100644 --- a/assets/go-licenses.json +++ b/assets/go-licenses.json @@ -294,11 +294,6 @@ "path": "github.com/davecgh/go-spew/spew/LICENSE", "licenseText": "ISC License\n\nCopyright (c) 2012-2016 Dave Collins \u003cdave@davec.name\u003e\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n" }, - { - "name": "github.com/denisenkom/go-mssqldb", - "path": "github.com/denisenkom/go-mssqldb/LICENSE.txt", - "licenseText": "Copyright (c) 2012 The Go Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" - }, { "name": "github.com/dgryski/go-rendezvous", "path": "github.com/dgryski/go-rendezvous/LICENSE", @@ -504,16 +499,6 @@ "path": "github.com/golang-jwt/jwt/v5/LICENSE", "licenseText": "Copyright (c) 2012 Dave Grijalva\nCopyright (c) 2021 golang-jwt maintainers\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n" }, - { - "name": "github.com/golang-sql/civil", - "path": "github.com/golang-sql/civil/LICENSE", - "licenseText": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License." - }, - { - "name": "github.com/golang-sql/sqlexp", - "path": "github.com/golang-sql/sqlexp/LICENSE", - "licenseText": "Copyright (c) 2017 The Go Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" - }, { "name": "github.com/golang/geo", "path": "github.com/golang/geo/LICENSE", diff --git a/cmd/doctor_convert.go b/cmd/doctor_convert.go index 48c835ad0e..190b2fc2ef 100644 --- a/cmd/doctor_convert.go +++ b/cmd/doctor_convert.go @@ -17,7 +17,7 @@ import ( var cmdDoctorConvert = &cli.Command{ Name: "convert", Usage: "Convert the database", - Description: "A command to convert an existing MySQL database from utf8 to utf8mb4 or MSSQL database from varchar to nvarchar", + Description: "A command to convert an existing MySQL database from utf8 to utf8mb4", Action: runDoctorConvert, } @@ -35,21 +35,14 @@ func runDoctorConvert(ctx *cli.Context) error { log.Info("Log path: %s", setting.Log.RootPath) log.Info("Configuration file: %s", setting.CustomConf) - switch { - case setting.Database.Type.IsMySQL(): + if setting.Database.Type.IsMySQL() { if err := db.ConvertDatabaseTable(); err != nil { log.Fatal("Failed to convert database & table: %v", err) return err } fmt.Println("Converted successfully, please confirm your database's character set is now utf8mb4") - case setting.Database.Type.IsMSSQL(): - if err := db.ConvertVarcharToNVarchar(); err != nil { - log.Fatal("Failed to convert database from varchar to nvarchar: %v", err) - return err - } - fmt.Println("Converted successfully, please confirm your database's all columns character is NVARCHAR now") - default: - fmt.Println("This command can only be used with a MySQL or MSSQL database") + } else { + fmt.Println("This command can only be used with a MySQL database") } return nil diff --git a/cmd/dump.go b/cmd/dump.go index 3ea92aa112..0a18adb27d 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -128,7 +128,7 @@ It can be used for backup and capture Forgejo server image to send to maintainer &cli.StringFlag{ Name: "database", Aliases: []string{"d"}, - Usage: "Specify the database SQL syntax: sqlite3, mysql, mssql, postgres", + Usage: "Specify the database SQL syntax: sqlite3, mysql, postgres", }, &cli.BoolFlag{ Name: "skip-repository", diff --git a/go.mod b/go.mod index 7e404372fc..7a7fd8e30f 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,6 @@ require ( github.com/buildkite/terminal-to-html/v3 v3.10.1 github.com/caddyserver/certmagic v0.20.0 github.com/chi-middleware/proxy v1.1.1 - github.com/denisenkom/go-mssqldb v0.12.3 github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21 github.com/djherbis/buffer v1.2.0 github.com/djherbis/nio/v3 v3.0.1 @@ -192,8 +191,6 @@ require ( github.com/go-webauthn/x v0.1.6 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect - github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/geo v0.0.0-20230421003525-6adc56603217 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect diff --git a/go.sum b/go.sum index 5bd7ea67ba..f9b4bb00c9 100644 --- a/go.sum +++ b/go.sum @@ -70,9 +70,6 @@ github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121 h1:r3qt8PCHnfjOv9PN3H github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121/go.mod h1:Ock8XgA7pvULhIaHGAk/cDnRfNrF9Jey81nPcc403iU= github.com/6543/go-version v1.3.1 h1:HvOp+Telns7HWJ2Xo/05YXQSB2bE0WmVgbHqwMPZT4U= github.com/6543/go-version v1.3.1/go.mod h1:oqFAHCwtLVUTLdhQmVZWYvaHXTdsbB4SY85at64SQEo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -236,7 +233,6 @@ github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55k github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= @@ -376,7 +372,6 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -640,7 +635,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mrjones/oauth v0.0.0-20180629183705-f4e24b6d100c/go.mod h1:skjdDftzkFALcuGzYSklqYd8gvat6F1gZJ4YPVbkZpM= github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 h1:j2kD3MT1z4PXCiUllUJF9mWUESr9TWKS7iEKsQ/IipM= @@ -691,7 +685,6 @@ github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -885,7 +878,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -967,7 +959,6 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -1262,7 +1253,6 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/models/activities/user_heatmap.go b/models/activities/user_heatmap.go index 78fcd76d43..080075d793 100644 --- a/models/activities/user_heatmap.go +++ b/models/activities/user_heatmap.go @@ -39,12 +39,8 @@ func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organi // Group by 15 minute intervals which will allow the client to accurately shift the timestamp to their timezone. // The interval is based on the fact that there are timezones such as UTC +5:30 and UTC +12:45. groupBy := "created_unix / 900 * 900" - groupByName := "timestamp" // We need this extra case because mssql doesn't allow grouping by alias - switch { - case setting.Database.Type.IsMySQL(): + if setting.Database.Type.IsMySQL() { groupBy = "created_unix DIV 900 * 900" - case setting.Database.Type.IsMSSQL(): - groupByName = groupBy } cond, err := activityQueryCondition(ctx, GetFeedsOptions{ @@ -67,7 +63,7 @@ func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organi Table("action"). Where(cond). And("created_unix > ?", timeutil.TimeStampNow()-31536000). - GroupBy(groupByName). + GroupBy("timestamp"). OrderBy("timestamp"). Find(&hdata) } diff --git a/models/db/collation.go b/models/db/collation.go index c128cf5029..61260d6d17 100644 --- a/models/db/collation.go +++ b/models/db/collation.go @@ -41,20 +41,6 @@ func findAvailableCollationsMySQL(x *xorm.Engine) (ret container.Set[string], er return ret, nil } -func findAvailableCollationsMSSQL(x *xorm.Engine) (ret container.Set[string], err error) { - var res []struct { - Name string - } - if err = x.SQL("SELECT * FROM sys.fn_helpcollations() WHERE name LIKE '%[_]CS[_]AS%'").Find(&res); err != nil { - return nil, err - } - ret = make(container.Set[string], len(res)) - for _, r := range res { - ret.Add(r.Name) - } - return ret, nil -} - func CheckCollations(x *xorm.Engine) (*CheckCollationsResult, error) { dbTables, err := x.DBMetas() if err != nil { @@ -84,18 +70,6 @@ func CheckCollations(x *xorm.Engine) (*CheckCollationsResult, error) { // At the moment, it's safe to ignore the database difference, just trim the prefix and compare. It could be fixed easily if there is any problem in the future. return a == b || strings.TrimPrefix(a, "utf8mb4_") == strings.TrimPrefix(b, "utf8mb4_") } - } else if x.Dialect().URI().DBType == schemas.MSSQL { - if _, err = x.SQL("SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation')").Get(&res.DatabaseCollation); err != nil { - return nil, err - } - res.IsCollationCaseSensitive = func(s string) bool { - return strings.HasSuffix(s, "_CS_AS") - } - candidateCollations = []string{"Latin1_General_CS_AS"} - res.AvailableCollation, err = findAvailableCollationsMSSQL(x) - if err != nil { - return nil, err - } } else { return nil, nil } @@ -146,10 +120,6 @@ func alterDatabaseCollation(x *xorm.Engine, collation string) error { if x.Dialect().URI().DBType == schemas.MYSQL { _, err := x.Exec("ALTER DATABASE CHARACTER SET utf8mb4 COLLATE " + collation) return err - } else if x.Dialect().URI().DBType == schemas.MSSQL { - // TODO: MSSQL has many limitations on changing database collation, it could fail in many cases. - _, err := x.Exec("ALTER DATABASE CURRENT COLLATE " + collation) - return err } return errors.New("unsupported database type") } @@ -165,12 +135,11 @@ func preprocessDatabaseCollation(x *xorm.Engine) { } // try to alter database collation to expected if the database is empty, it might fail in some cases (and it isn't necessary to succeed) - // at the moment, there is no "altering" solution for MSSQL, site admin should manually change the database collation + // at the moment. if !r.CollationEquals(r.DatabaseCollation, r.ExpectedCollation) && r.ExistingTableNumber == 0 { if err = alterDatabaseCollation(x, r.ExpectedCollation); err != nil { log.Error("Failed to change database collation to %q: %v", r.ExpectedCollation, err) } else { - _, _ = x.Exec("SELECT 1") // after "altering", MSSQL's session becomes invalid, so make a simple query to "refresh" the session if r, err = CheckCollations(x); err != nil { log.Error("Failed to check database collation again after altering: %v", err) // impossible case return diff --git a/models/db/common.go b/models/db/common.go index ea628bf2a0..f3fd3e72ae 100644 --- a/models/db/common.go +++ b/models/db/common.go @@ -47,8 +47,6 @@ func BuilderDialect() string { return builder.SQLITE case setting.Database.Type.IsPostgreSQL(): return builder.POSTGRES - case setting.Database.Type.IsMSSQL(): - return builder.MSSQL default: return "" } diff --git a/models/db/convert.go b/models/db/convert.go index 8c124471ab..b8b15382e7 100644 --- a/models/db/convert.go +++ b/models/db/convert.go @@ -47,33 +47,6 @@ func ConvertDatabaseTable() error { return nil } -// ConvertVarcharToNVarchar converts database and tables from varchar to nvarchar if it's mssql -func ConvertVarcharToNVarchar() error { - if x.Dialect().URI().DBType != schemas.MSSQL { - return nil - } - - sess := x.NewSession() - defer sess.Close() - res, err := sess.QuerySliceString(`SELECT 'ALTER TABLE ' + OBJECT_NAME(SC.object_id) + ' MODIFY SC.name NVARCHAR(' + CONVERT(VARCHAR(5),SC.max_length) + ')' -FROM SYS.columns SC -JOIN SYS.types ST -ON SC.system_type_id = ST.system_type_id -AND SC.user_type_id = ST.user_type_id -WHERE ST.name ='varchar'`) - if err != nil { - return err - } - for _, row := range res { - if len(row) == 1 { - if _, err = sess.Exec(row[0]); err != nil { - return err - } - } - } - return err -} - // Cell2Int64 converts a xorm.Cell type to int64, // and handles possible irregular cases. func Cell2Int64(val xorm.Cell) int64 { diff --git a/models/db/engine.go b/models/db/engine.go index 27e5fb9e1a..09f64b6c8f 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -22,9 +22,8 @@ import ( "xorm.io/xorm/names" "xorm.io/xorm/schemas" - _ "github.com/denisenkom/go-mssqldb" // Needed for the MSSQL driver - _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver - _ "github.com/lib/pq" // Needed for the Postgresql driver + _ "github.com/go-sql-driver/mysql" // Needed for the MySQL driver + _ "github.com/lib/pq" // Needed for the Postgresql driver ) var ( @@ -114,10 +113,8 @@ func newXORMEngine() (*xorm.Engine, error) { if err != nil { return nil, err } - if setting.Database.Type == "mysql" { + if setting.Database.Type.IsMySQL() { engine.Dialect().SetParams(map[string]string{"rowFormat": "DYNAMIC"}) - } else if setting.Database.Type == "mssql" { - engine.Dialect().SetParams(map[string]string{"DEFAULT_VARCHAR": "nvarchar"}) } engine.SetSchema(setting.Database.Schema) return engine, nil diff --git a/models/db/index.go b/models/db/index.go index 29254b1f07..259ddd6ade 100644 --- a/models/db/index.go +++ b/models/db/index.go @@ -89,33 +89,6 @@ func mysqlGetNextResourceIndex(ctx context.Context, tableName string, groupID in return idx, nil } -func mssqlGetNextResourceIndex(ctx context.Context, tableName string, groupID int64) (int64, error) { - if _, err := GetEngine(ctx).Exec(fmt.Sprintf(` -MERGE INTO %s WITH (HOLDLOCK) AS target -USING (SELECT %d AS group_id) AS source -(group_id) -ON target.group_id = source.group_id -WHEN MATCHED - THEN UPDATE - SET max_index = max_index + 1 -WHEN NOT MATCHED - THEN INSERT (group_id, max_index) - VALUES (%d, 1); -`, tableName, groupID, groupID)); err != nil { - return 0, err - } - - var idx int64 - _, err := GetEngine(ctx).SQL(fmt.Sprintf("SELECT max_index FROM %s WHERE group_id = ?", tableName), groupID).Get(&idx) - if err != nil { - return 0, err - } - if idx == 0 { - return 0, errors.New("cannot get the correct index") - } - return idx, nil -} - // GetNextResourceIndex generates a resource index, it must run in the same transaction where the resource is created func GetNextResourceIndex(ctx context.Context, tableName string, groupID int64) (int64, error) { switch { @@ -123,8 +96,6 @@ func GetNextResourceIndex(ctx context.Context, tableName string, groupID int64) return postgresGetNextResourceIndex(ctx, tableName, groupID) case setting.Database.Type.IsMySQL(): return mysqlGetNextResourceIndex(ctx, tableName, groupID) - case setting.Database.Type.IsMSSQL(): - return mssqlGetNextResourceIndex(ctx, tableName, groupID) } e := GetEngine(ctx) diff --git a/models/git/branch.go b/models/git/branch.go index a12cbd4dee..0e2febce3b 100644 --- a/models/git/branch.go +++ b/models/git/branch.go @@ -103,7 +103,7 @@ func (err ErrBranchesEqual) Unwrap() error { type Branch struct { ID int64 RepoID int64 `xorm:"UNIQUE(s)"` - Name string `xorm:"UNIQUE(s) NOT NULL"` // git's ref-name is case-sensitive internally, however, in some databases (mssql, mysql, by default), it's case-insensitive at the moment + Name string `xorm:"UNIQUE(s) NOT NULL"` // git's ref-name is case-sensitive internally, however, in some databases (mysql, by default), it's case-insensitive at the moment CommitID string CommitMessage string `xorm:"TEXT"` // it only stores the message summary (the first line) PusherID int64 diff --git a/models/git/commit_status.go b/models/git/commit_status.go index e44cc98985..bec819348a 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -84,34 +84,6 @@ func mysqlGetCommitStatusIndex(ctx context.Context, repoID int64, sha string) (i return idx, nil } -func mssqlGetCommitStatusIndex(ctx context.Context, repoID int64, sha string) (int64, error) { - if _, err := db.GetEngine(ctx).Exec(` -MERGE INTO commit_status_index WITH (HOLDLOCK) AS target -USING (SELECT ? AS repo_id, ? AS sha) AS source -(repo_id, sha) -ON target.repo_id = source.repo_id AND target.sha = source.sha -WHEN MATCHED - THEN UPDATE - SET max_index = max_index + 1 -WHEN NOT MATCHED - THEN INSERT (repo_id, sha, max_index) - VALUES (?, ?, 1); -`, repoID, sha, repoID, sha); err != nil { - return 0, err - } - - var idx int64 - _, err := db.GetEngine(ctx).SQL("SELECT max_index FROM `commit_status_index` WHERE repo_id = ? AND sha = ?", - repoID, sha).Get(&idx) - if err != nil { - return 0, err - } - if idx == 0 { - return 0, errors.New("cannot get the correct index") - } - return idx, nil -} - // GetNextCommitStatusIndex retried 3 times to generate a resource index func GetNextCommitStatusIndex(ctx context.Context, repoID int64, sha string) (int64, error) { _, err := git.NewIDFromString(sha) @@ -124,8 +96,6 @@ func GetNextCommitStatusIndex(ctx context.Context, repoID int64, sha string) (in return postgresGetCommitStatusIndex(ctx, repoID, sha) case setting.Database.Type.IsMySQL(): return mysqlGetCommitStatusIndex(ctx, repoID, sha) - case setting.Database.Type.IsMSSQL(): - return mssqlGetCommitStatusIndex(ctx, repoID, sha) } e := db.GetEngine(ctx) diff --git a/models/migrations/base/db.go b/models/migrations/base/db.go index 51351cc7d3..a76ce29deb 100644 --- a/models/migrations/base/db.go +++ b/models/migrations/base/db.go @@ -89,13 +89,6 @@ func RecreateTable(sess *xorm.Session, bean any) error { hasID = hasID || (column.IsPrimaryKey && column.IsAutoIncrement) } - if hasID && setting.Database.Type.IsMSSQL() { - if _, err := sess.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` ON", tempTableName)); err != nil { - log.Error("Unable to set identity insert for table %s. Error: %v", tempTableName, err) - return err - } - } - sqlStringBuilder := &strings.Builder{} _, _ = sqlStringBuilder.WriteString("INSERT INTO `") _, _ = sqlStringBuilder.WriteString(tempTableName) @@ -143,13 +136,6 @@ func RecreateTable(sess *xorm.Session, bean any) error { return err } - if hasID && setting.Database.Type.IsMSSQL() { - if _, err := sess.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` OFF", tempTableName)); err != nil { - log.Error("Unable to switch off identity insert for table %s. Error: %v", tempTableName, err) - return err - } - } - switch { case setting.Database.Type.IsSQLite3(): // SQLite will drop all the constraints on the old table @@ -296,19 +282,6 @@ func RecreateTable(sess *xorm.Session, bean any) error { } - case setting.Database.Type.IsMSSQL(): - // MSSQL will drop all the constraints on the old table - if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil { - log.Error("Unable to drop old table %s. Error: %v", tableName, err) - return err - } - - // MSSQL sp_rename will move all the constraints from the temporary table to the new table - if _, err := sess.Exec(fmt.Sprintf("sp_rename `%s`,`%s`", tempTableName, tableName)); err != nil { - log.Error("Unable to rename %s to %s. Error: %v", tempTableName, tableName, err) - return err - } - default: log.Fatal("Unrecognized DB") } @@ -444,40 +417,6 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) } - case setting.Database.Type.IsMSSQL(): - cols := "" - for _, col := range columnNames { - if cols != "" { - cols += ", " - } - cols += "`" + strings.ToLower(col) + "`" - } - sql := fmt.Sprintf("SELECT Name FROM sys.default_constraints WHERE parent_object_id = OBJECT_ID('%[1]s') AND parent_column_id IN (SELECT column_id FROM sys.columns WHERE LOWER(name) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))", - tableName, strings.ReplaceAll(cols, "`", "'")) - constraints := make([]string, 0) - if err := sess.SQL(sql).Find(&constraints); err != nil { - return fmt.Errorf("Find constraints: %v", err) - } - for _, constraint := range constraints { - if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP CONSTRAINT `%s`", tableName, constraint)); err != nil { - return fmt.Errorf("Drop table `%s` default constraint `%s`: %v", tableName, constraint, err) - } - } - sql = fmt.Sprintf("SELECT DISTINCT Name FROM sys.indexes INNER JOIN sys.index_columns ON indexes.index_id = index_columns.index_id AND indexes.object_id = index_columns.object_id WHERE indexes.object_id = OBJECT_ID('%[1]s') AND index_columns.column_id IN (SELECT column_id FROM sys.columns WHERE LOWER(name) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))", - tableName, strings.ReplaceAll(cols, "`", "'")) - constraints = make([]string, 0) - if err := sess.SQL(sql).Find(&constraints); err != nil { - return fmt.Errorf("Find constraints: %v", err) - } - for _, constraint := range constraints { - if _, err := sess.Exec(fmt.Sprintf("DROP INDEX `%[2]s` ON `%[1]s`", tableName, constraint)); err != nil { - return fmt.Errorf("Drop index `%[2]s` on `%[1]s`: %v", tableName, constraint, err) - } - } - - if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP COLUMN %s", tableName, cols)); err != nil { - return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) - } default: log.Fatal("Unrecognized DB") } @@ -489,21 +428,6 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin func ModifyColumn(x *xorm.Engine, tableName string, col *schemas.Column) error { var indexes map[string]*schemas.Index var err error - // MSSQL have to remove index at first, otherwise alter column will fail - // ref. https://sqlzealots.com/2018/05/09/error-message-the-index-is-dependent-on-column-alter-table-alter-column-failed-because-one-or-more-objects-access-this-column/ - if x.Dialect().URI().DBType == schemas.MSSQL { - indexes, err = x.Dialect().GetIndexes(x.DB(), context.Background(), tableName) - if err != nil { - return err - } - - for _, index := range indexes { - _, err = x.Exec(x.Dialect().DropIndexSQL(tableName, index)) - if err != nil { - return err - } - } - } defer func() { for _, index := range indexes { @@ -612,21 +536,6 @@ func deleteDB() error { } return nil } - case setting.Database.Type.IsMSSQL(): - host, port := setting.ParseMSSQLHostPort(setting.Database.Host) - db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", - host, port, "master", setting.Database.User, setting.Database.Passwd)) - if err != nil { - return err - } - defer db.Close() - - if _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS [%s]", setting.Database.Name)); err != nil { - return err - } - if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE [%s]", setting.Database.Name)); err != nil { - return err - } } return nil diff --git a/models/migrations/v1_11/v110.go b/models/migrations/v1_11/v110.go index 81afa1331d..fce9be847e 100644 --- a/models/migrations/v1_11/v110.go +++ b/models/migrations/v1_11/v110.go @@ -16,9 +16,6 @@ func ChangeReviewContentToText(x *xorm.Engine) error { case schemas.ORACLE: _, err := x.Exec("ALTER TABLE review MODIFY content TEXT") return err - case schemas.MSSQL: - _, err := x.Exec("ALTER TABLE review ALTER COLUMN content TEXT") - return err case schemas.POSTGRES: _, err := x.Exec("ALTER TABLE review ALTER COLUMN content TYPE TEXT") return err diff --git a/models/migrations/v1_12/v139.go b/models/migrations/v1_12/v139.go index 279aa7df87..5b6576951d 100644 --- a/models/migrations/v1_12/v139.go +++ b/models/migrations/v1_12/v139.go @@ -12,12 +12,9 @@ import ( func PrependRefsHeadsToIssueRefs(x *xorm.Engine) error { var query string - switch { - case setting.Database.Type.IsMSSQL(): - query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'" - case setting.Database.Type.IsMySQL(): + if setting.Database.Type.IsMySQL() { query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';" - default: + } else { query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'" } diff --git a/models/migrations/v1_13/v145.go b/models/migrations/v1_13/v145.go index 8acb29bf33..5b38f1cd80 100644 --- a/models/migrations/v1_13/v145.go +++ b/models/migrations/v1_13/v145.go @@ -45,32 +45,6 @@ func IncreaseLanguageField(x *xorm.Engine) error { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat MODIFY COLUMN language %s", sqlType)); err != nil { return err } - case setting.Database.Type.IsMSSQL(): - // Yet again MSSQL just has to be awkward. - // Here we have to drop the constraints first and then rebuild them - constraints := make([]string, 0) - if err := sess.SQL(`SELECT i.name AS Name - FROM sys.indexes i INNER JOIN sys.index_columns ic - ON i.index_id = ic.index_id AND i.object_id = ic.object_id - INNER JOIN sys.tables AS t - ON t.object_id = i.object_id - INNER JOIN sys.columns c - ON t.object_id = c.object_id AND ic.column_id = c.column_id - WHERE t.name = 'language_stat' AND c.name = 'language'`).Find(&constraints); err != nil { - return fmt.Errorf("Find constraints: %w", err) - } - for _, constraint := range constraints { - if _, err := sess.Exec(fmt.Sprintf("DROP INDEX [%s] ON `language_stat`", constraint)); err != nil { - return fmt.Errorf("Drop table `language_stat` constraint `%s`: %w", constraint, err) - } - } - if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language %s", sqlType)); err != nil { - return err - } - // Finally restore the constraint - if err := sess.CreateUniques(new(LanguageStat)); err != nil { - return err - } case setting.Database.Type.IsPostgreSQL(): if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language TYPE %s", sqlType)); err != nil { return err diff --git a/models/migrations/v1_13/v151.go b/models/migrations/v1_13/v151.go index 25af1d03ec..ea4a8eae31 100644 --- a/models/migrations/v1_13/v151.go +++ b/models/migrations/v1_13/v151.go @@ -23,36 +23,6 @@ func SetDefaultPasswordToArgon2(x *xorm.Engine) error { case setting.Database.Type.IsPostgreSQL(): _, err := x.Exec("ALTER TABLE `user` ALTER COLUMN passwd_hash_algo SET DEFAULT 'argon2';") return err - case setting.Database.Type.IsMSSQL(): - // need to find the constraint and drop it, then recreate it. - sess := x.NewSession() - defer sess.Close() - if err := sess.Begin(); err != nil { - return err - } - res, err := sess.QueryString("SELECT [name] FROM sys.default_constraints WHERE parent_object_id=OBJECT_ID(?) AND COL_NAME(parent_object_id, parent_column_id)=?;", "user", "passwd_hash_algo") - if err != nil { - return err - } - if len(res) > 0 { - constraintName := res[0]["name"] - log.Error("Results of select constraint: %s", constraintName) - _, err := sess.Exec("ALTER TABLE [user] DROP CONSTRAINT " + constraintName) - if err != nil { - return err - } - _, err = sess.Exec("ALTER TABLE [user] ADD CONSTRAINT " + constraintName + " DEFAULT 'argon2' FOR passwd_hash_algo") - if err != nil { - return err - } - } else { - _, err := sess.Exec("ALTER TABLE [user] ADD DEFAULT('argon2') FOR passwd_hash_algo") - if err != nil { - return err - } - } - return sess.Commit() - case setting.Database.Type.IsSQLite3(): // drop through default: diff --git a/models/migrations/v1_14/v158.go b/models/migrations/v1_14/v158.go index 1094d8abf7..2d688b1706 100644 --- a/models/migrations/v1_14/v158.go +++ b/models/migrations/v1_14/v158.go @@ -62,13 +62,6 @@ func UpdateCodeCommentReplies(x *xorm.Engine) error { return err } - if setting.Database.Type.IsMSSQL() { - if _, err := sess.Exec(sqlSelect + " INTO #temp_comments" + sqlTail); err != nil { - log.Error("unable to create temporary table") - return err - } - } - comments := make([]*Comment, 0, batchSize) switch { @@ -78,9 +71,6 @@ func UpdateCodeCommentReplies(x *xorm.Engine) error { fallthrough case setting.Database.Type.IsSQLite3(): sqlCmd = sqlSelect + sqlTail + " LIMIT " + strconv.Itoa(batchSize) + " OFFSET " + strconv.Itoa(start) - case setting.Database.Type.IsMSSQL(): - sqlCmd = "SELECT TOP " + strconv.Itoa(batchSize) + " * FROM #temp_comments WHERE " + - "(id NOT IN ( SELECT TOP " + strconv.Itoa(start) + " id FROM #temp_comments ORDER BY id )) ORDER BY id" default: return fmt.Errorf("Unsupported database type") } diff --git a/models/migrations/v1_14/v165.go b/models/migrations/v1_14/v165.go index 926350cdf7..5b1a779294 100644 --- a/models/migrations/v1_14/v165.go +++ b/models/migrations/v1_14/v165.go @@ -32,13 +32,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error { return err } - var hookTaskTrimSQL string - if dbType == schemas.MSSQL { - hookTaskTrimSQL = "UPDATE hook_task SET typ = RTRIM(LTRIM(typ))" - } else { - hookTaskTrimSQL = "UPDATE hook_task SET typ = TRIM(typ)" - } - if _, err := x.Exec(hookTaskTrimSQL); err != nil { + if _, err := x.Exec("UPDATE hook_task SET typ = TRIM(typ)"); err != nil { return err } @@ -58,12 +52,6 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error { return err } - var webhookTrimSQL string - if dbType == schemas.MSSQL { - webhookTrimSQL = "UPDATE webhook SET type = RTRIM(LTRIM(type))" - } else { - webhookTrimSQL = "UPDATE webhook SET type = TRIM(type)" - } - _, err := x.Exec(webhookTrimSQL) + _, err := x.Exec("UPDATE webhook SET type = TRIM(type)") return err } diff --git a/models/migrations/v1_15/v184.go b/models/migrations/v1_15/v184.go index 4b3dd1467a..871c9db18a 100644 --- a/models/migrations/v1_15/v184.go +++ b/models/migrations/v1_15/v184.go @@ -53,16 +53,11 @@ func RenameTaskErrorsToMessage(x *xorm.Engine) error { } } - switch { - case setting.Database.Type.IsMySQL(): + if setting.Database.Type.IsMySQL() { if _, err := sess.Exec("ALTER TABLE `task` CHANGE errors message text"); err != nil { return err } - case setting.Database.Type.IsMSSQL(): - if _, err := sess.Exec("sp_rename 'task.errors', 'message', 'COLUMN'"); err != nil { - return err - } - default: + } else { if _, err := sess.Exec("ALTER TABLE `task` RENAME COLUMN errors TO message"); err != nil { return err } diff --git a/models/migrations/v1_16/v210.go b/models/migrations/v1_16/v210.go index d1a22ee87a..f9d1eb5c84 100644 --- a/models/migrations/v1_16/v210.go +++ b/models/migrations/v1_16/v210.go @@ -10,7 +10,6 @@ import ( "fmt" "strings" - "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" "xorm.io/xorm" @@ -74,26 +73,6 @@ func RemigrateU2FCredentials(x *xorm.Engine) error { if err != nil { return err } - case schemas.MSSQL: - // This column has an index on it. I could write all of the code to attempt to change the index OR - // I could just use recreate table. - sess := x.NewSession() - if err := sess.Begin(); err != nil { - _ = sess.Close() - return err - } - - if err := base.RecreateTable(sess, new(webauthnCredential)); err != nil { - _ = sess.Close() - return err - } - if err := sess.Commit(); err != nil { - _ = sess.Close() - return err - } - if err := sess.Close(); err != nil { - return err - } case schemas.POSTGRES: _, err := x.Exec("ALTER TABLE webauthn_credential ALTER COLUMN credential_id TYPE VARCHAR(410)") if err != nil { @@ -137,11 +116,6 @@ func RemigrateU2FCredentials(x *xorm.Engine) error { if err := sess.Begin(); err != nil { return fmt.Errorf("unable to allow start session. Error: %w", err) } - if x.Dialect().URI().DBType == schemas.MSSQL { - if _, err := sess.Exec("SET IDENTITY_INSERT `webauthn_credential` ON"); err != nil { - return fmt.Errorf("unable to allow identity insert on webauthn_credential. Error: %w", err) - } - } for _, reg := range regs { pubKey, keyHandle, err := parseU2FRegistration(reg.Raw) if err != nil { diff --git a/models/migrations/v1_17/v220.go b/models/migrations/v1_17/v220.go index 904ddc5192..d4007163ab 100644 --- a/models/migrations/v1_17/v220.go +++ b/models/migrations/v1_17/v220.go @@ -12,14 +12,10 @@ import ( ) func AddContainerRepositoryProperty(x *xorm.Engine) (err error) { - switch x.Dialect().URI().DBType { - case schemas.SQLITE: + if x.Dialect().URI().DBType == schemas.SQLITE { _, err = x.Exec("INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, u.lower_name || '/' || p.lower_name FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?", packages_model.PropertyTypePackage, container_module.PropertyRepository, packages_model.TypeContainer) - case schemas.MSSQL: - _, err = x.Exec("INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, u.lower_name + '/' + p.lower_name FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?", - packages_model.PropertyTypePackage, container_module.PropertyRepository, packages_model.TypeContainer) - default: + } else { _, err = x.Exec("INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, CONCAT(u.lower_name, '/', p.lower_name) FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?", packages_model.PropertyTypePackage, container_module.PropertyRepository, packages_model.TypeContainer) } diff --git a/models/migrations/v1_17/v223.go b/models/migrations/v1_17/v223.go index 018451ee4c..3592eb1be6 100644 --- a/models/migrations/v1_17/v223.go +++ b/models/migrations/v1_17/v223.go @@ -64,16 +64,11 @@ func RenameCredentialIDBytes(x *xorm.Engine) error { } } - switch { - case setting.Database.Type.IsMySQL(): + if setting.Database.Type.IsMySQL() { if _, err := sess.Exec("ALTER TABLE `webauthn_credential` CHANGE credential_id_bytes credential_id VARBINARY(1024)"); err != nil { return err } - case setting.Database.Type.IsMSSQL(): - if _, err := sess.Exec("sp_rename 'webauthn_credential.credential_id_bytes', 'credential_id', 'COLUMN'"); err != nil { - return err - } - default: + } else { if _, err := sess.Exec("ALTER TABLE `webauthn_credential` RENAME COLUMN credential_id_bytes TO credential_id"); err != nil { return err } diff --git a/models/migrations/v1_20/v245.go b/models/migrations/v1_20/v245.go index ab58d12880..b0d4c21502 100644 --- a/models/migrations/v1_20/v245.go +++ b/models/migrations/v1_20/v245.go @@ -50,8 +50,7 @@ func RenameWebhookOrgToOwner(x *xorm.Engine) error { } } - switch { - case setting.Database.Type.IsMySQL(): + if setting.Database.Type.IsMySQL() { inferredTable, err := x.TableInfo(new(Webhook)) if err != nil { return err @@ -60,11 +59,7 @@ func RenameWebhookOrgToOwner(x *xorm.Engine) error { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `webhook` CHANGE org_id owner_id %s", sqlType)); err != nil { return err } - case setting.Database.Type.IsMSSQL(): - if _, err := sess.Exec("sp_rename 'webhook.org_id', 'owner_id', 'COLUMN'"); err != nil { - return err - } - default: + } else { if _, err := sess.Exec("ALTER TABLE `webhook` RENAME COLUMN org_id TO owner_id"); err != nil { return err } diff --git a/models/migrations/v1_22/v283.go b/models/migrations/v1_22/v283.go index 0a45c51245..86946d1c39 100644 --- a/models/migrations/v1_22/v283.go +++ b/models/migrations/v1_22/v283.go @@ -4,10 +4,7 @@ package v1_22 //nolint import ( - "fmt" - "xorm.io/xorm" - "xorm.io/xorm/schemas" ) func AddCombinedIndexToIssueUser(x *xorm.Engine) error { @@ -23,18 +20,12 @@ func AddCombinedIndexToIssueUser(x *xorm.Engine) error { return err } for _, issueUser := range duplicatedIssueUsers { - if x.Dialect().URI().DBType == schemas.MSSQL { - if _, err := x.Exec(fmt.Sprintf("delete from issue_user where id in (SELECT top %d id FROM issue_user WHERE issue_id = ? and uid = ?)", issueUser.Cnt-1), issueUser.IssueID, issueUser.UID); err != nil { - return err - } - } else { - var ids []int64 - if err := x.SQL("SELECT id FROM issue_user WHERE issue_id = ? and uid = ? limit ?", issueUser.IssueID, issueUser.UID, issueUser.Cnt-1).Find(&ids); err != nil { - return err - } - if _, err := x.Table("issue_user").In("id", ids).Delete(); err != nil { - return err - } + var ids []int64 + if err := x.SQL("SELECT id FROM issue_user WHERE issue_id = ? and uid = ? limit ?", issueUser.IssueID, issueUser.UID, issueUser.Cnt-1).Find(&ids); err != nil { + return err + } + if _, err := x.Table("issue_user").In("id", ids).Delete(); err != nil { + return err } } diff --git a/models/migrations/v1_22/v286.go b/models/migrations/v1_22/v286.go index fbbd87344f..2d62d7788c 100644 --- a/models/migrations/v1_22/v286.go +++ b/models/migrations/v1_22/v286.go @@ -3,7 +3,6 @@ package v1_22 //nolint import ( - "errors" "fmt" "code.gitea.io/gitea/modules/log" @@ -33,27 +32,10 @@ func expandHashReferencesToSha256(x *xorm.Engine) error { } if !setting.Database.Type.IsSQLite3() { - if setting.Database.Type.IsMSSQL() { - // drop indexes that need to be re-created afterwards - droppedIndexes := []string{ - "DROP INDEX IF EXISTS [IDX_commit_status_context_hash] ON [commit_status]", - "DROP INDEX IF EXISTS [UQE_review_state_pull_commit_user] ON [review_state]", - "DROP INDEX IF EXISTS [UQE_repo_archiver_s] ON [repo_archiver]", - } - for _, s := range droppedIndexes { - _, err := db.Exec(s) - if err != nil { - return errors.New(s + " " + err.Error()) - } - } - } - for _, alts := range alteredTables { var err error if setting.Database.Type.IsMySQL() { _, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` MODIFY COLUMN `%s` VARCHAR(64)", alts[0], alts[1])) - } else if setting.Database.Type.IsMSSQL() { - _, err = db.Exec(fmt.Sprintf("ALTER TABLE [%s] ALTER COLUMN [%s] VARCHAR(64)", alts[0], alts[1])) } else { _, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` TYPE VARCHAR(64)", alts[0], alts[1])) } @@ -61,20 +43,6 @@ func expandHashReferencesToSha256(x *xorm.Engine) error { return fmt.Errorf("alter column '%s' of table '%s' failed: %w", alts[1], alts[0], err) } } - - if setting.Database.Type.IsMSSQL() { - recreateIndexes := []string{ - "CREATE INDEX IDX_commit_status_context_hash ON commit_status(context_hash)", - "CREATE UNIQUE INDEX UQE_review_state_pull_commit_user ON review_state(user_id, pull_id, commit_sha)", - "CREATE UNIQUE INDEX UQE_repo_archiver_s ON repo_archiver(repo_id, type, commit_id)", - } - for _, s := range recreateIndexes { - _, err := db.Exec(s) - if err != nil { - return errors.New(s + " " + err.Error()) - } - } - } } log.Debug("Updated database tables to hold SHA256 git hash references") diff --git a/models/migrations/v1_8/v81.go b/models/migrations/v1_8/v81.go index a100dc1ef7..734fc24641 100644 --- a/models/migrations/v1_8/v81.go +++ b/models/migrations/v1_8/v81.go @@ -18,8 +18,6 @@ func ChangeU2FCounterType(x *xorm.Engine) error { _, err = x.Exec("ALTER TABLE `u2f_registration` MODIFY `counter` BIGINT") case schemas.POSTGRES: _, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` SET DATA TYPE bigint") - case schemas.MSSQL: - _, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` BIGINT") } if err != nil { diff --git a/models/unittest/fixtures.go b/models/unittest/fixtures.go index 9ce0909589..63b26a0af7 100644 --- a/models/unittest/fixtures.go +++ b/models/unittest/fixtures.go @@ -60,8 +60,6 @@ func InitFixtures(opts FixturesOptions, engine ...*xorm.Engine) (err error) { dialect = "postgres" case schemas.MYSQL: dialect = "mysql" - case schemas.MSSQL: - dialect = "mssql" case schemas.SQLITE: dialect = "sqlite3" default: diff --git a/modules/setting/database.go b/modules/setting/database.go index 47d79d0de9..6abef42cba 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -16,9 +16,9 @@ import ( var ( // SupportedDatabaseTypes includes all XORM supported databases type, sqlite3 maybe added by `database_sqlite3.go` - SupportedDatabaseTypes = []string{"mysql", "postgres", "mssql"} + SupportedDatabaseTypes = []string{"mysql", "postgres"} // DatabaseTypeNames contains the friendly names for all database types - DatabaseTypeNames = map[string]string{"mysql": "MySQL", "postgres": "PostgreSQL", "mssql": "MSSQL", "sqlite3": "SQLite3"} + DatabaseTypeNames = map[string]string{"mysql": "MySQL", "postgres": "PostgreSQL", "sqlite3": "SQLite3"} // EnableSQLite3 use SQLite3, set by build flag EnableSQLite3 bool @@ -120,9 +120,6 @@ func DBConnStr() (string, error) { Database.User, Database.Passwd, connType, Database.Host, Database.Name, paramSep, tls) case "postgres": connStr = getPostgreSQLConnectionString(Database.Host, Database.User, Database.Passwd, Database.Name, Database.SSLMode) - case "mssql": - host, port := ParseMSSQLHostPort(Database.Host) - connStr = fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", host, port, Database.Name, Database.User, Database.Passwd) case "sqlite3": if !EnableSQLite3 { return "", errors.New("this Gitea binary was not built with SQLite3 support") @@ -188,28 +185,6 @@ func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbsslMode s return connURL.String() } -// ParseMSSQLHostPort splits the host into host and port -func ParseMSSQLHostPort(info string) (string, string) { - // the default port "0" might be related to MSSQL's dynamic port, maybe it should be double-confirmed in the future - host, port := "127.0.0.1", "0" - if strings.Contains(info, ":") { - host = strings.Split(info, ":")[0] - port = strings.Split(info, ":")[1] - } else if strings.Contains(info, ",") { - host = strings.Split(info, ",")[0] - port = strings.TrimSpace(strings.Split(info, ",")[1]) - } else if len(info) > 0 { - host = info - } - if host == "" { - host = "127.0.0.1" - } - if port == "" { - port = "0" - } - return host, port -} - type DatabaseType string func (t DatabaseType) String() string { @@ -224,10 +199,6 @@ func (t DatabaseType) IsMySQL() bool { return t == "mysql" } -func (t DatabaseType) IsMSSQL() bool { - return t == "mssql" -} - func (t DatabaseType) IsPostgreSQL() bool { return t == "postgres" } diff --git a/options/locale/locale_ar.ini b/options/locale/locale_ar.ini index da60b73291..e58f7dfdf7 100644 --- a/options/locale/locale_ar.ini +++ b/options/locale/locale_ar.ini @@ -137,7 +137,7 @@ reinstall_confirm_message = إعادة التثبيت باستخدام قاعد db_schema = مخطط reinstall_error = أنت تحاول التثبيت في قاعدة بيانات فورجيو موجودة sqlite_helper = مسار المِلَفّ لقاعدة بيانات SQLite3.
أدخل المسار المطلق إذا شغلت فورجيو كخدمة. -require_db_desc = فورجيو يحتاج MySQL أو PostgreSQL أو MSSQL أو SQLite3 أو TiDB. +require_db_desc = فورجيو يحتاج MySQL أو PostgreSQL أو SQLite3 أو TiDB. password = كلمة المرور host = المضيف docker_helper = إذا كنت تستخدم فورجيو داخل دوكر، يرجي قراءة المستندات قبل تغيير أي إعدادات. @@ -1547,7 +1547,6 @@ dashboard.sync_tag.started = بدأ تزامن الوسوم dashboard.sync_repo_tags = زامن الوسوم من بيانات جِت إلى قاعدة البيانات self_check = فحص ذاتي self_check.database_collation_case_insensitive = تستخدم قاعدة البيانات تجميع %s ، وهو تجميع غير حساس. على الرغم من أن فورجيو يمكن أن يعمل معها قد تكون هناك حالات نادرة لا تعمل كما هو متوقع. -self_check.database_fix_mssql = بالنسبة لمستخدمي الـإم إس سيكول، يمكنك إصلاح المشكلة بتعديل السيكول يدوياً فقط في الوقت الراهن. monitor.process.cancel_desc = قد يسبب إلغاء العملية فقدانًا للبيانات monitor.queue.type = النوع monitor.process.cancel_notices = أتريد إلغاء: %s؟ diff --git a/options/locale/locale_bg.ini b/options/locale/locale_bg.ini index 2c302ed822..ca1598fb1b 100644 --- a/options/locale/locale_bg.ini +++ b/options/locale/locale_bg.ini @@ -1217,7 +1217,7 @@ admin_name = Потреб. име за администратор confirm_password = Потвърдете паролата title = Първоначална конфигурация domain = Домейн на сървъра -require_db_desc = Forgejo изисква MySQL, PostgreSQL, MSSQL, SQLite3 или TiDB (MySQL протокол). +require_db_desc = Forgejo изисква MySQL, PostgreSQL, SQLite3 или TiDB (MySQL протокол). general_title = Общи настройки email_title = Настройки на ел. поща db_schema = Схема diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/locale_cs-CZ.ini index 6e57a9dd59..fd7d8b03fb 100644 --- a/options/locale/locale_cs-CZ.ini +++ b/options/locale/locale_cs-CZ.ini @@ -219,7 +219,7 @@ license_desc=Vše je na dokumentaci, než budete měnit jakákoliv nastavení. -require_db_desc=Forgejo vyžaduje MySQL, PostgreSQL, MSSQL, SQLite3 nebo TiDB (protokol MySQL). +require_db_desc=Forgejo vyžaduje MySQL, PostgreSQL, SQLite3 nebo TiDB (protokol MySQL). db_title=Nastavení databáze db_type=Typ databáze host=Hostitel @@ -3396,7 +3396,6 @@ self_check = Vlastní kontrola dashboard.sync_tag.started = Synchronizace značek spuštěna dashboard.rebuild_issue_indexer = Přestavit indexer vydání self_check.database_collation_case_insensitive = Databáze používá collation %s. Jedná se o intenzivní collation. Ačkoli s ní Forgejo nejspíše bude pracovat, mohou nastat určité vzácné případy, kdy nebude pracovat tak, jak má. -self_check.database_fix_mssql = Uživatelé MSSQL mohou tento problém vyřešit pouze ručními SQL příkazy „ALTER ... COLLATE ...“. auths.oauth2_map_group_to_team = Zmapovat zabrané skupiny u týmů organizací (volitelné - vyžaduje název claimu výše) monitor.queue.settings.desc = Pooly dynamicky rostou podle blokování fronty jejich workerů. @@ -3405,7 +3404,6 @@ self_check.database_collation_mismatch=Očekávejte, že databáze použije coll self_check.database_collation_case_insensitive=Databáze používá collation %s, což je collation nerozlišující velká a malá písmena. Ačkoli s ní Gitea může pracovat, mohou se vyskytnout vzácné případy, kdy nebude fungovat podle očekávání. self_check.database_inconsistent_collation_columns=Databáze používá collation %s, ale tyto sloupce používají chybné collation. To může způsobit neočekávané problémy. self_check.database_fix_mysql=Pro uživatele MySQL/MariaDB můžete použít příkaz "gitea doctor convert", který opraví problémy s collation, nebo můžete také problém vyřešit příkazem "ALTER ... COLLATE ..." SQL ručně. -self_check.database_fix_mssql=Uživatelé MSSQL mohou problém vyřešit pouze pomocí příkazu "ALTER ... COLLATE ..." SQL ručně. auths.tips.gmail_settings = Nastavení služby Gmail: config_summary = Souhrn config.open_with_editor_app_help = Editory v nabídce „Otevřít pomocí“ v nabídce klonování. Ponechte prázdné pro použití výchozího editoru (zobrazíte jej rozšířením). diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index ccb45b5d49..77dd23a785 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -217,7 +217,7 @@ license_desc=Hole dir Dokumentation, bevor du irgendwelche Einstellungen veränderst. -require_db_desc=Forgejo benötigt MySQL, PostgreSQL, MSSQL, SQLite3 oder TiDB (MySQL-Protokoll). +require_db_desc=Forgejo benötigt MySQL, PostgreSQL, SQLite3 oder TiDB (MySQL-Protokoll). db_title=Datenbankeinstellungen db_type=Datenbanktyp host=Host @@ -3368,7 +3368,6 @@ self_check = Selbstprüfung dashboard.sync_repo_tags = Tags aus Git-Daten zu Datenbank synchronisieren emails.change_email_text = Bist du dir sicher, dass du diese E-Mail-Addresse aktualisieren möchtest? packages.cleanup.success = Abgelaufene Daten erfolgreich gesäubert -self_check.database_fix_mssql = Für MSSQL-Benutzer: Du kannst das Problem im Moment nur mit „ALTER … COLLATE …“-SQLs beheben. self_check.no_problem_found = Noch kein Problem gefunden. self_check.database_inconsistent_collation_columns = Datenbank benutzt Collation %s, aber diese Spalten benutzen Collations, die nicht zusammenpassen. Das könnte ein paar unerwartete Probleme verursachen. self_check.database_collation_mismatch = Erwarte von Datenbank, folgende Collation zu verwenden: %s diff --git a/options/locale/locale_el-GR.ini b/options/locale/locale_el-GR.ini index 7feea5269e..5116f6b2e4 100644 --- a/options/locale/locale_el-GR.ini +++ b/options/locale/locale_el-GR.ini @@ -211,7 +211,7 @@ license_desc=Κατέβασε το εγχειρίδιο πριν αλλάξετε τις ρυθμίσεις. -require_db_desc=Το Forgejo απαιτεί MySQL, PostgreSQL, MSSQL, SQLite3 ή TiDB (με πρωτόκολλο MySQL). +require_db_desc=Το Forgejo απαιτεί MySQL, PostgreSQL, SQLite3 ή TiDB (με πρωτόκολλο MySQL). db_title=Ρυθμίσεις βάσης δεδομένων db_type=Είδος βάσης δεδομένων host=Διακομιστής @@ -3322,7 +3322,6 @@ notices.desc=Περιγραφή notices.op=Λειτ. notices.delete_success=Οι ειδοποιήσεις του συστήματος έχουν διαγραφεί. self_check.no_problem_found = Μέχρι τώρα, δεν έχει βρεθεί κάποιο πρόβλημα. -self_check.database_fix_mssql = Προς το παρόν, οι χρήστες του MSSQL μπορούν να διορθώσουν το πρόβλημα αυτό χειροκίνητα χρησιμοποιώντας τις εντολές SQL «ALTER ... COLLATE ...». self_check = Αυτοέλεγχος dashboard.sync_repo_tags = Συγχρονισμός tag από δεδομένα git στην βάση δεδομένων dashboard.sync_tag.started = Ο συγχρονισμός tag έχει ξεκινήσει diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 293b834330..fad1e820bc 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -239,7 +239,7 @@ license_desc = Go get documentation before changing any settings. -require_db_desc = Forgejo requires MySQL, PostgreSQL, MSSQL, SQLite3 or TiDB (MySQL protocol). +require_db_desc = Forgejo requires MySQL, PostgreSQL, SQLite3 or TiDB (MySQL protocol). db_title = Database settings db_type = Database type host = Host @@ -3381,7 +3381,6 @@ self_check.database_collation_mismatch = Expect database to use collation: %s self_check.database_collation_case_insensitive = Database is using a collation %s, which is an insensitive collation. Although Forgejo could work with it, there might be some rare cases which don't work as expected. self_check.database_inconsistent_collation_columns = Database is using collation %s, but these columns are using mismatched collations. It might cause some unexpected problems. self_check.database_fix_mysql = For MySQL/MariaDB users, you could use the "gitea doctor convert" command to fix the collation problems, or you could also fix the problem by "ALTER ... COLLATE ..." SQLs manually. -self_check.database_fix_mssql = For MSSQL users, you could only fix the problem by "ALTER ... COLLATE ..." SQLs manually at the moment. [action] create_repo = created repository %s diff --git a/options/locale/locale_eo.ini b/options/locale/locale_eo.ini index 6527d0d42e..88bbb958bd 100644 --- a/options/locale/locale_eo.ini +++ b/options/locale/locale_eo.ini @@ -226,7 +226,7 @@ disable_gravatar = Malŝalti profilbildojn per Gravatar repo_path_helper = Foraj Git-deponejoj konserviĝos al tiu ĉi dosierujo. sqlite_helper = Dosiervojo por la datumbazo SQLite3.
Enigu absolutan vojon se vi rulas Forgejon kiel servo. enable_captcha = Ŝalti dumregistriĝan teston de homeco -require_db_desc = Forgejo bezonas kiel datumbazo MySQL, PostgreSQL, MSSQL, SQLite3, aŭ TiDB (MySQL komunikformo). +require_db_desc = Forgejo bezonas kiel datumbazo MySQL, PostgreSQL, SQLite3, aŭ TiDB (MySQL komunikformo). smtp_from = Sendu retleterojn kiel general_title = Ĝeneralaj agordoj password = Pasvorto diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini index 2965de5f35..5ac709e875 100644 --- a/options/locale/locale_es-ES.ini +++ b/options/locale/locale_es-ES.ini @@ -210,7 +210,7 @@ license_desc=¡Está todo en < documentación antes de realizar cambios en la configuración. -require_db_desc=Forgejo requiere una base de datos MySQL, PostgreSQL, MSSQL, SQLite3 o TiDB (usar el protocolo MySQL). +require_db_desc=Forgejo requiere una base de datos MySQL, PostgreSQL, SQLite3 o TiDB (usar el protocolo MySQL). db_title=Configuración de base de datos db_type=Tipo de base de datos host=Servidor diff --git a/options/locale/locale_fi-FI.ini b/options/locale/locale_fi-FI.ini index 0d55fff150..b56d9c8967 100644 --- a/options/locale/locale_fi-FI.ini +++ b/options/locale/locale_fi-FI.ini @@ -144,7 +144,7 @@ license_desc=Mene osoitteeseen ohjeet ennen minkään asetuksen muuttamista. -require_db_desc=Forgejo tarvitsee toimiakseen MySQL, PostgreSQL, MSSQL, SQLite3 tai TiDB (MySQL protokolla) tietokannan. +require_db_desc=Forgejo tarvitsee toimiakseen MySQL, PostgreSQL, SQLite3 tai TiDB (MySQL protokolla) tietokannan. db_title=Tietokanta asetukset db_type=Tietokanta tyyppi host=Isäntä diff --git a/options/locale/locale_fil.ini b/options/locale/locale_fil.ini index b50143444c..a6421b26ec 100644 --- a/options/locale/locale_fil.ini +++ b/options/locale/locale_fil.ini @@ -211,7 +211,7 @@ reinstall_error = Sinusubukan mong mag-install sa umiiral na Forgejo database install = Pag-install title = Paunang pagsasaayos docker_helper = Kapag tinatakbo mo ang Forgejo sa loob ng Docker, mangyaring basahin ang dokumentasyon bago baguhin ang anumang mga setting. -require_db_desc = Kinakailangan ng Forgejo ang MySQL, PostgreSQL, MSSQL, SQLite3 o TiDB (MySQL protocol). +require_db_desc = Kinakailangan ng Forgejo ang MySQL, PostgreSQL, SQLite3 o TiDB (MySQL protocol). db_title = Mga setting ng database db_type = Uri ng database host = Host diff --git a/options/locale/locale_fr-FR.ini b/options/locale/locale_fr-FR.ini index 3e5e1a3ffd..4840f1e478 100644 --- a/options/locale/locale_fr-FR.ini +++ b/options/locale/locale_fr-FR.ini @@ -218,7 +218,7 @@ license_desc=Toutes les sources sont sur documentation avant de modifier les paramètres. -require_db_desc=Forgejo nécessite MySQL, PostgreSQL, MSSQL, SQLite3 ou TiDB (avec le protocole MySQL). +require_db_desc=Forgejo nécessite MySQL, PostgreSQL, SQLite3 ou TiDB (avec le protocole MySQL). db_title=Paramètres de la base de données db_type=Type de base de données host=Hôte @@ -3388,14 +3388,12 @@ self_check.database_collation_mismatch = La base de donnée devrait utiliser la self_check.database_collation_case_insensitive = La base de donnée utilise la collation %s qui n'est pas sensible à la casse. Bien que Forgejo puisse fonctionner de cette façon, il est possible que certains cas limite d'utilisation de la casse ne fonctionne pas comme attendu. self_check.database_inconsistent_collation_columns = La base de donnée utilise la collation %s, mais ces colonnes utilisent des collations incohérentes. Cela peut causer des problèmes inattendus. self_check.database_fix_mysql = Les utilisateurs de MySQL/MariaDB peuvent utiliser la commande "forgejo doctor convert" pour corriger les problèmes de collation, ou bien manuellement avec la commande SQL "ALTER ... COLLATE ...". -self_check.database_fix_mssql = Les utilisateurs de MSSQL sont pour l'instant contraint d'utiliser la commande SQL "ALTER ... COLLATE ..." pour corriger ce problème. self_check.no_problem_found=Aucun problème trouvé pour l’instant. self_check.database_collation_mismatch=Exige que la base de données utilise la collation %s. self_check.database_collation_case_insensitive=La base de données utilise la collation %s, insensible à la casse. Bien que Gitea soit compatible, il peut y avoir quelques rares cas qui ne fonctionnent pas comme prévu. self_check.database_inconsistent_collation_columns=La base de données utilise la collation %s, mais ces colonnes utilisent des collations différentes. Cela peut causer des problèmes imprévus. self_check.database_fix_mysql=Pour les utilisateurs de MySQL ou MariaDB, vous pouvez utiliser la commande « gitea doctor convert » dans un terminal ou exécuter une requête du type « ALTER … COLLATE ... » pour résoudre les problèmes de collation. -self_check.database_fix_mssql=Pour les utilisateurs de MSSQL, vous ne pouvez résoudre le problème qu’en exécutant une requête SQL du type « ALTER … COLLATE … ». [action] create_repo=a créé le dépôt %s diff --git a/options/locale/locale_is-IS.ini b/options/locale/locale_is-IS.ini index 3948015902..e448ee4568 100644 --- a/options/locale/locale_is-IS.ini +++ b/options/locale/locale_is-IS.ini @@ -141,7 +141,7 @@ license_desc=Sæktu leiðbeiningaritið áður en þú breytir stillingum. -require_db_desc=Forgejo krefst MySQL, PostgreSQL, MSSQL, SQLite3 eða TiDB (MySQL samskiptareglur). +require_db_desc=Forgejo krefst MySQL, PostgreSQL, SQLite3 eða TiDB (MySQL samskiptareglur). db_title=Gagnagrunnsstillingar db_type=Tegund Gagnagrunns host=Hýsill diff --git a/options/locale/locale_it-IT.ini b/options/locale/locale_it-IT.ini index 9332fbf49b..ee367101a3 100644 --- a/options/locale/locale_it-IT.ini +++ b/options/locale/locale_it-IT.ini @@ -215,7 +215,7 @@ install_desc = Semplicemente la documentazione prima di cambiare qualsiasi impostazione. -require_db_desc=Forgejo requires MySQL, PostgreSQL, MSSQL, SQLite3 or TiDB (MySQL protocol). +require_db_desc=Forgejo requires MySQL, PostgreSQL, SQLite3 or TiDB (MySQL protocol). db_title=Impostazioni database db_type=Tipo di database host=Host @@ -3351,7 +3351,6 @@ monitor.queue.settings.remove_all_items_done = Tutti gli elementi in coda sono s self_check.database_collation_mismatch = Pretendi che la base di dati usi la collazione: %s self_check.database_fix_mysql = Per utenti MySQL/MariaDB, potresti usare il comando "gitea doctor convert" per risolvere problemi di collazione, o potresti risolvere il problema manualmente tramite SQL con "ALTER ... COLLATE ...". self_check.database_collation_case_insensitive = La base di dati sta usando la collazione %s, che è una collazione insensibile. Nonostante Forgejo potrebbe lavorarci, ci potrebbero essere rari casi che non vanno come previsto. -self_check.database_fix_mssql = Gli utenti MSSQL possono provare a risolvere il problema tramite SQL con "ALTER ... COLLATE ..." manualmente, per il momento. [action] diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index c5f940b4c3..3a4f414a9b 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -214,7 +214,7 @@ license_desc=Go get ドキュメントを読んでください。 -require_db_desc=Forgejoには、MySQL、PostgreSQL、MSSQL、SQLite3、またはTiDB(MySQL プロトコル) が必要です。 +require_db_desc=Forgejoには、MySQL、PostgreSQL、SQLite3、またはTiDB(MySQL プロトコル) が必要です。 db_title=データベース設定 db_type=データベースのタイプ host=ホスト diff --git a/options/locale/locale_lv-LV.ini b/options/locale/locale_lv-LV.ini index f4d6eee2b1..3ccc1054c8 100644 --- a/options/locale/locale_lv-LV.ini +++ b/options/locale/locale_lv-LV.ini @@ -197,7 +197,7 @@ license_desc=Iegūsti vadlīninas pirms maināt iestatījumus. -require_db_desc=Forgejo nepieciešams MySQL, PostgreSQL, MSSQL, SQLite3 vai TiDB (izmantojot MySQL protokolu). +require_db_desc=Forgejo nepieciešams MySQL, PostgreSQL, SQLite3 vai TiDB (izmantojot MySQL protokolu). db_title=Datu bāzes iestatījumi db_type=Datu bāzes veids host=Resursdators diff --git a/options/locale/locale_nl-NL.ini b/options/locale/locale_nl-NL.ini index 74f008cd78..52ff71c90d 100644 --- a/options/locale/locale_nl-NL.ini +++ b/options/locale/locale_nl-NL.ini @@ -217,7 +217,7 @@ install_desc = Draai gewoon documentatie voordat je een instelling aanpast. -require_db_desc=Forgejo vereist MySQL, PostgreSQL, MSSQL, SQLite3 of TiDB (MySQL protocol). +require_db_desc=Forgejo vereist MySQL, PostgreSQL, SQLite3 of TiDB (MySQL protocol). db_title=Database-instellingen db_type=Database-type host=Server @@ -3323,7 +3323,6 @@ dashboard.sync_repo_branches = Synchroniseren gemiste branches van git data naar monitor.processes_count = %d Processen monitor.process.children = Kinderen self_check.database_inconsistent_collation_columns = Database gebruikt collatie %s, maar deze kolommen gebruiken onjuiste collaties. Dit kan onverwachte problemen veroorzaken. -self_check.database_fix_mssql = Voor MSSQL gebruikers kan je het probleem alleen oplossen door "ALTER ... COLLATE ..." SQL's handmatig op te lossen. monitor.stacktrace = Stacktrace monitor.download_diagnosis_report = Diagnoserapport downloaden self_check.database_collation_case_insensitive = Database gebruikt collatie %s, wat een ongevoelige collatie is. Hoewel Forgejo ermee kan werken, kunnen er enkele zeldzame gevallen zijn die niet werken zoals verwacht. diff --git a/options/locale/locale_pl-PL.ini b/options/locale/locale_pl-PL.ini index 9a035cd088..ba9f6765a8 100644 --- a/options/locale/locale_pl-PL.ini +++ b/options/locale/locale_pl-PL.ini @@ -160,7 +160,7 @@ license_desc=Pobierz na dokumentację przed wprowadzeniem jakichkolwiek zmian. -require_db_desc=Forgejo wymaga MySQL, PostgreSQL, MSSQL, SQLite3 lub TiDB (protokół MySQL). +require_db_desc=Forgejo wymaga MySQL, PostgreSQL, SQLite3 lub TiDB (protokół MySQL). db_title=Ustawienia bazy danych db_type=Typ bazy danych host=Serwer diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index 303ee10b46..e70fa9df57 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -205,7 +205,7 @@ install_desc = Apenas documentação cuidadosamente antes de alterar qualquer coisa nesta página. -require_db_desc=Forgejo requer MySQL, PostgreSQL, MSSQL, SQLite3 ou TiDB (protocolo MySQL). +require_db_desc=Forgejo requer MySQL, PostgreSQL, SQLite3 ou TiDB (protocolo MySQL). db_title=Configurações de banco de dados db_type=Tipo de banco de dados host=Servidor diff --git a/options/locale/locale_pt-PT.ini b/options/locale/locale_pt-PT.ini index 4562d29fd8..1f05e3e50a 100644 --- a/options/locale/locale_pt-PT.ini +++ b/options/locale/locale_pt-PT.ini @@ -198,7 +198,7 @@ license_desc=Vá buscá-lo em documentação antes de alterar quaisquer configurações. -require_db_desc=Forgejo requer MySQL, PostgreSQL, MSSQL, SQLite3 ou TiDB (protocolo MySQL). +require_db_desc=Forgejo requer MySQL, PostgreSQL, SQLite3 ou TiDB (protocolo MySQL). db_title=Configurações da base de dados db_type=Tipo de base de dados host=Servidor @@ -3256,7 +3256,6 @@ self_check.database_collation_mismatch=Supor que a base de dados usa a colação self_check.database_collation_case_insensitive=A base de dados está a usar a colação %s, que é insensível à diferença entre maiúsculas e minúsculas. Embora o Gitea possa trabalhar com ela, pode haver alguns casos raros que não funcionem como esperado. self_check.database_inconsistent_collation_columns=A base de dados está a usar a colação %s, mas estas colunas estão a usar colações diferentes. Isso poderá causar alguns problemas inesperados. self_check.database_fix_mysql=Para utilizadores do MySQL/MariaDB, pode usar o comando "gitea doctor convert" para resolver os problemas de colação. Também pode resolver o problema com comandos SQL "ALTER ... COLLATE ..." aplicados manualmente. -self_check.database_fix_mssql=Para utilizadores do MSSQL só pode resolver o problema aplicando comandos SQL "ALTER ... COLLATE ..." manualmente, por enquanto. [action] create_repo=criou o repositório %s diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index b1c330b27b..102eea9d13 100644 --- a/options/locale/locale_ru-RU.ini +++ b/options/locale/locale_ru-RU.ini @@ -217,7 +217,7 @@ license_desc=Всё это на документацией, прежде чем изменять любые настройки. -require_db_desc=Forgejo требует MySQL, PostgreSQL, MSSQL, SQLite3 или TiDB (по протоколу MySQL). +require_db_desc=Forgejo требует MySQL, PostgreSQL, SQLite3 или TiDB (по протоколу MySQL). db_title=Настройки базы данных db_type=Тип базы данных host=Хост @@ -3349,7 +3349,6 @@ notices.delete_success=Уведомления системы были удале self_check.no_problem_found = Пока проблем не обнаружено. auths.tip.gitea = Зарегистрируйте новое приложение OAuth2. Доступна инструкция: https://forgejo.org/docs/latest/user/oauth2-provider auths.tips.oauth2.general.tip = При регистрации нового приложения OAuth2 ссылка обратного перенаправления должна быть: -self_check.database_fix_mssql = В настоящий момент пользователи MSSQL могут исправить проблемы с сопоставлением только ручным прописыванием "ALTER ... COLLATE ..." в SQL. self_check.database_fix_mysql = Пользователи MySQL и MariaDB могут исправить проблемы с сопоставлением командой "gitea doctor convert". Также можно вручную вписать "ALTER ... COLLATE ..." в SQL. dashboard.cleanup_actions = Очистить устаревшие журналы и артефакты Действий dashboard.sync_repo_branches = Синхронизировать ветки из Git в базу данных diff --git a/options/locale/locale_sk-SK.ini b/options/locale/locale_sk-SK.ini index f6e44b085d..28c3c3cc21 100644 --- a/options/locale/locale_sk-SK.ini +++ b/options/locale/locale_sk-SK.ini @@ -196,7 +196,7 @@ license_desc=Získajte dokumentáciu pred zmenou akýchkoľvek nastavení. -require_db_desc=Forgejo vyžaduje MySQL, PostgreSQL, MSSQL, SQLite3 alebo TiDB (MySQL protokol). +require_db_desc=Forgejo vyžaduje MySQL, PostgreSQL, SQLite3 alebo TiDB (MySQL protokol). db_title=Nastavenie databázy db_type=Typ databázy host=Host diff --git a/options/locale/locale_sl.ini b/options/locale/locale_sl.ini index aba84b9352..cda98d17a4 100644 --- a/options/locale/locale_sl.ini +++ b/options/locale/locale_sl.ini @@ -133,7 +133,7 @@ pull_requests = Zahteve za umik [install] reinstall_confirm_check_3 = Potrjujete, da ste popolnoma prepričani, da se ta program Forgejo izvaja s pravilno lokacijo app.ini, in da ste prepričani, da ga morate znova namestiti. Potrjujete, da se zavedate zgoraj navedenih tveganj. -require_db_desc = Forgejo zahteva MySQL, PostgreSQL, MSSQL, SQLite3 ali TiDB (protokol MySQL). +require_db_desc = Forgejo zahteva MySQL, PostgreSQL, SQLite3 ali TiDB (protokol MySQL). password_algorithm_helper = Nastavite algoritem za stiskanje gesla. Algoritmi imajo različne zahteve in moč. Algoritem argon2 je precej varen, vendar porabi veliko pomnilnika in je lahko neprimeren za majhne sisteme. reinstall_confirm_message = Ponovna namestitev z obstoječo zbirko podatkov Forgejo lahko povzroči več težav. V večini primerov morate za zagon programa Forgejo uporabiti obstoječi "app.ini". Če veste, kaj počnete, potrdite naslednje: err_admin_name_is_reserved = Administrator Uporabniško ime je neveljavno, uporabniško ime je rezervirano diff --git a/options/locale/locale_tr-TR.ini b/options/locale/locale_tr-TR.ini index 54596b3278..0c9aa521c6 100644 --- a/options/locale/locale_tr-TR.ini +++ b/options/locale/locale_tr-TR.ini @@ -197,7 +197,7 @@ license_desc=Gidin ve belgeleri okuyun. -require_db_desc=Forgejo MySQL, PostgreSQL, MSSQL, SQLite3 veya TiDB (MySQL protokolü) gerektirir. +require_db_desc=Forgejo MySQL, PostgreSQL, SQLite3 veya TiDB (MySQL protokolü) gerektirir. db_title=Veritabanı Ayarları db_type=Veritabanı Türü host=Sunucu diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 7a15774140..f30759686e 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -215,7 +215,7 @@ license_desc=所有的代码都开源在 官方文档 后再对本页面进行填写。 -require_db_desc=Forgejo 需要使用 MySQL、PostgreSQL、MSSQL、SQLite3 或 TiDB (MySQL协议) 等数据库 +require_db_desc=Forgejo 需要使用 MySQL、PostgreSQL、SQLite3 或 TiDB (MySQL协议) 等数据库 db_title=数据库设置 db_type=数据库类型 host=数据库主机 @@ -3377,14 +3377,12 @@ self_check.database_collation_mismatch = 期望数据库使用排序规则:%s self_check.database_collation_case_insensitive = 数据库正在使用 %s 排序规则,这是一种不敏感的排序规则。 尽管 Forgejo 可以使用它,但在极少数情况下可能无法按照预期工作。 self_check.database_inconsistent_collation_columns = 数据库正在使用 %s 排序规则,但与这些列使用的排序规则不匹配。 这可能会导致一些意想不到的问题。 self_check.database_fix_mysql = 对于 MySQL/MariaDB 用户,您可以使用 "gitea doctor convert" 命令来修复排序规则问题,也可以通过SQL命令 "ALTER ... COLLATE ..." 来手动修复问题。 -self_check.database_fix_mssql = 对于 MSSQL 用户,目前您只能通过SQL命令 "ALTER ... COLLATE ..." 来手动修复问题。 self_check.no_problem_found=尚未发现问题。 self_check.database_collation_mismatch=期望数据库使用的校验方式:%s self_check.database_collation_case_insensitive=数据库正在使用一个校验 %s, 这是一个不敏感的校验. 虽然Gitea可以与它合作,但可能有一些罕见的情况不如预期的那样起作用。 self_check.database_inconsistent_collation_columns=数据库正在使用%s的排序规则,但是这些列使用了不匹配的排序规则。这可能会造成一些意外问题。 self_check.database_fix_mysql=对于MySQL/MariaDB用户,您可以使用“gitea doctor convert”命令来解决校验问题。 或者您也可以通过 "ALTER ... COLLATE ..." 这样的SQL 来手动解决这个问题。 -self_check.database_fix_mssql=对于MSSQL用户,您现在只能通过"ALTER ... COLLATE ..."SQLs手动解决这个问题。 auths.tips.gmail_settings = Gmail 设置: auths.tip.gitlab_new = 在 https://gitlab.com/-/profile/applications 上注册新应用 config_settings = 设置 diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini index 871fb11568..1faabf9b99 100644 --- a/options/locale/locale_zh-TW.ini +++ b/options/locale/locale_zh-TW.ini @@ -211,7 +211,7 @@ license_desc=取得 安裝指南再來調整設定。 -require_db_desc=Forgejo 需要 MySQL、PostgreSQL、SQLite3、MSSQL、TiDB (MySQL 協定) 等其中一項。 +require_db_desc=Forgejo 需要 MySQL、PostgreSQL、SQLite3、TiDB (MySQL 協定) 等其中一項。 db_title=資料庫設定 db_type=資料庫類型 host=主機 diff --git a/routers/web/web.go b/routers/web/web.go index 40f4ffc018..71d5efef2c 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -654,7 +654,7 @@ func registerRoutes(m *web.Route) { m.Get("/system_status", admin.SystemStatus) m.Post("", web.Bind(forms.AdminDashboardForm{}), admin.DashboardPost) - if setting.Database.Type.IsMySQL() || setting.Database.Type.IsMSSQL() { + if setting.Database.Type.IsMySQL() { m.Get("/self_check", admin.SelfCheck) } diff --git a/templates/admin/navbar.tmpl b/templates/admin/navbar.tmpl index 16ec1b4b5b..1ec703b296 100644 --- a/templates/admin/navbar.tmpl +++ b/templates/admin/navbar.tmpl @@ -4,7 +4,7 @@ {{ctx.Locale.Tr "admin.dashboard"}} - {{if or .DatabaseType.IsMySQL .DatabaseType.IsMSSQL}} + {{if .DatabaseType.IsMySQL}} {{ctx.Locale.Tr "admin.self_check"}} diff --git a/templates/admin/self_check.tmpl b/templates/admin/self_check.tmpl index 94c4673a49..5c154ac0d5 100644 --- a/templates/admin/self_check.tmpl +++ b/templates/admin/self_check.tmpl @@ -8,8 +8,6 @@ {{if .DatabaseCheckHasProblems}} {{if .DatabaseType.IsMySQL}}
{{ctx.Locale.Tr "admin.self_check.database_fix_mysql"}}
- {{else if .DatabaseType.IsMSSQL}} -
{{ctx.Locale.Tr "admin.self_check.database_fix_mssql"}}
{{end}} {{if .DatabaseCheckCollationMismatch}}
{{ctx.Locale.Tr "admin.self_check.database_collation_mismatch" .DatabaseCheckResult.ExpectedCollation}}
diff --git a/tests/e2e/README.md b/tests/e2e/README.md index e5fd1ca6c0..a0a9fc9ec9 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -7,7 +7,6 @@ They can be run with make commands for the appropriate backends, namely: make test-sqlite make test-pgsql make test-mysql -make test-mssql ``` Make sure to perform a clean front-end build before running tests: @@ -53,16 +52,6 @@ Start tests based on the database container TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-e2e-pgsql ``` -## Run mssql e2e tests -Setup a mssql database inside docker -``` -docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container) -``` -Start tests based on the database container -``` -TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-e2e-mssql -``` - ## Running individual tests Example command to run `example.test.e2e.js` test file: @@ -75,10 +64,10 @@ For SQLite: make test-e2e-sqlite#example ``` -For other databases(replace `mssql` to `mysql` or `pgsql`): +For PostgreSQL databases(replace `mysql` to `pgsql`): ``` -TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-e2e-mssql#example +TEST_MYSQL_HOST=localhost:1433 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=sa TEST_MYSQL_PASSWORD=MwantsaSecurePassword1 make test-e2e-mysql#example ``` ## Visual testing diff --git a/tests/integration/README.md b/tests/integration/README.md index f6f74ca21f..d659d51b20 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -6,7 +6,6 @@ appropriate backends, namely: make test-sqlite make test-pgsql make test-mysql -make test-mssql ``` Make sure to perform a clean build before running tests: @@ -63,16 +62,6 @@ Start tests based on the database container TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql ``` -## Run mssql integration tests -Setup a mssql database inside docker -``` -docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container) -``` -Start tests based on the database container -``` -TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql -``` - ## Running individual tests Example command to run GPG test: @@ -83,10 +72,10 @@ For SQLite: make test-sqlite#GPG ``` -For other databases(replace `mssql` to `mysql`, or `pgsql`): +For other databases (replace `mysql` to `pgsql`): ``` -TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql#GPG +TEST_MYSQL_HOST=localhost:1433 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=sa TEST_MYSQL_PASSWORD=MwantsaSecurePassword1 make test-mysql#GPG ``` ## Setting timeouts for declaring long-tests and long-flushes diff --git a/tests/integration/README_ZH.md b/tests/integration/README_ZH.md index 6aea4ab212..d0debf2fd6 100644 --- a/tests/integration/README_ZH.md +++ b/tests/integration/README_ZH.md @@ -59,16 +59,6 @@ docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:14 #(ju TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql ``` -## Run mssql integration tests -同上,首先在 docker 容器里部署一个 mssql 数据库 -``` -docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container) -``` -之后便可以基于这个数据库进行集成测试 -``` -TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql -``` - ## 如何进行自定义的集成测试 下面的示例展示了怎样在集成测试中只进行 GPG 测试: @@ -79,9 +69,9 @@ sqlite 数据库: make test-sqlite#GPG ``` -其它数据库(把 MSSQL 替换为 MYSQL, PGSQL): +其它数据库 (用 PGSQL 取代 MYSQL): ``` -TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql#GPG +TEST_MYSQL_HOST=localhost:1433 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=sa TEST_MYSQL_PASSWORD=MwantsaSecurePassword1 make test-mysql#GPG ``` diff --git a/tests/integration/db_collation_test.go b/tests/integration/db_collation_test.go index eee26d1ed1..4d822c45a6 100644 --- a/tests/integration/db_collation_test.go +++ b/tests/integration/db_collation_test.go @@ -39,7 +39,7 @@ func TestDatabaseCollationSelfCheckUI(t *testing.T) { htmlDoc.AssertElement(t, "a.item[href*='/admin/self_check']", exists) } - if setting.Database.Type.IsMySQL() || setting.Database.Type.IsMSSQL() { + if setting.Database.Type.IsMySQL() { assertSelfCheckExists(true) } else { assertSelfCheckExists(false) @@ -61,10 +61,9 @@ func TestDatabaseCollation(t *testing.T) { assert.EqualValues(t, 2, cnt) _, _ = x.Exec("DROP TABLE IF EXISTS test_collation_tbl") - // by default, SQLite3 and PostgreSQL are using case-sensitive collations, but MySQL and MSSQL are not - // the following tests are only for MySQL and MSSQL - if !setting.Database.Type.IsMySQL() && !setting.Database.Type.IsMSSQL() { - t.Skip("only MySQL and MSSQL requires the case-sensitive collation check at the moment") + // by default, SQLite3 and PostgreSQL are using case-sensitive collations, but MySQL is not. + if !setting.Database.Type.IsMySQL() { + t.Skip("only MySQL requires the case-sensitive collation check at the moment") return } @@ -86,20 +85,11 @@ func TestDatabaseCollation(t *testing.T) { assert.True(t, r.CollationEquals("abc", "abc")) assert.True(t, r.CollationEquals("abc", "utf8mb4_abc")) assert.False(t, r.CollationEquals("utf8mb4_general_ci", "utf8mb4_unicode_ci")) - } else if setting.Database.Type.IsMSSQL() { - assert.True(t, r.IsCollationCaseSensitive("Latin1_General_CS_AS")) - assert.False(t, r.IsCollationCaseSensitive("Latin1_General_CI_AS")) - assert.True(t, r.CollationEquals("abc", "abc")) - assert.False(t, r.CollationEquals("Latin1_General_CS_AS", "SQL_Latin1_General_CP1_CS_AS")) } else { assert.Fail(t, "unexpected database type") } }) - if setting.Database.Type.IsMSSQL() { - return // skip table converting tests because MSSQL doesn't have a simple solution at the moment - } - t.Run("Convert tables to utf8mb4_bin", func(t *testing.T) { defer tests.PrintCurrentTest(t)() diff --git a/tests/integration/migration-test/gitea-v1.6.4.mssql.sql.gz b/tests/integration/migration-test/gitea-v1.6.4.mssql.sql.gz deleted file mode 100644 index 1b676feda1..0000000000 Binary files a/tests/integration/migration-test/gitea-v1.6.4.mssql.sql.gz and /dev/null differ diff --git a/tests/integration/migration-test/gitea-v1.7.0.mssql.sql.gz b/tests/integration/migration-test/gitea-v1.7.0.mssql.sql.gz deleted file mode 100644 index bd869cfa58..0000000000 Binary files a/tests/integration/migration-test/gitea-v1.7.0.mssql.sql.gz and /dev/null differ diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index d1aa3f3eb8..e0e5620cd2 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -14,7 +14,6 @@ import ( "path/filepath" "regexp" "sort" - "strings" "testing" "code.gitea.io/gitea/models/db" @@ -258,31 +257,6 @@ func restoreOldDB(t *testing.T, version string) bool { _, err = db.Exec(data) assert.NoError(t, err) db.Close() - - case setting.Database.Type.IsMSSQL(): - host, port := setting.ParseMSSQLHostPort(setting.Database.Host) - db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", - host, port, "master", setting.Database.User, setting.Database.Passwd)) - assert.NoError(t, err) - defer db.Close() - - _, err = db.Exec("DROP DATABASE IF EXISTS [gitea]") - assert.NoError(t, err) - - statements := strings.Split(data, "\nGO\n") - for _, statement := range statements { - if len(statement) > 5 && statement[:5] == "USE [" { - dbname := statement[5 : len(statement)-1] - db.Close() - db, err = sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", - host, port, dbname, setting.Database.User, setting.Database.Passwd)) - assert.NoError(t, err) - defer db.Close() - } - _, err = db.Exec(statement) - assert.NoError(t, err, "Failure whilst running: %s\nError: %v", statement, err) - } - db.Close() } return true } diff --git a/tests/mssql.ini.tmpl b/tests/mssql.ini.tmpl deleted file mode 100644 index 9346f75874..0000000000 --- a/tests/mssql.ini.tmpl +++ /dev/null @@ -1,107 +0,0 @@ -APP_NAME = Gitea: Git with a cup of tea -RUN_MODE = prod - -[database] -DB_TYPE = mssql -HOST = {{TEST_MSSQL_HOST}} -NAME = {{TEST_MSSQL_DBNAME}} -USER = {{TEST_MSSQL_USERNAME}} -PASSWD = {{TEST_MSSQL_PASSWORD}} -SSL_MODE = disable - -[indexer] -REPO_INDEXER_ENABLED = true -REPO_INDEXER_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/indexers/repos.bleve - -[queue.issue_indexer] -TYPE = level -DATADIR = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/indexers/issues.queue - -[queue] -TYPE = immediate - -[repository] -ROOT = {{REPO_TEST_DIR}}tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/gitea-repositories - -[repository.local] -LOCAL_COPY_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/tmp/local-repo - -[repository.upload] -TEMP_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/tmp/uploads - -[repository.signing] -SIGNING_KEY = none - -[server] -SSH_DOMAIN = localhost -HTTP_PORT = 3003 -ROOT_URL = http://localhost:3003/ -DISABLE_SSH = false -SSH_LISTEN_HOST = localhost -SSH_PORT = 2201 -START_SSH_SERVER = true -LFS_START_SERVER = true -OFFLINE_MODE = false -LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w -APP_DATA_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data -BUILTIN_SSH_SERVER_USER = git -SSH_TRUSTED_USER_CA_KEYS = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCb4DC1dMFnJ6pXWo7GMxTchtzmJHYzfN6sZ9FAPFR4ijMLfGki+olvOMO5Fql1/yGnGfbELQa1S6y4shSvj/5K+zUFScmEXYf3Gcr87RqilLkyk16RS+cHNB1u87xTHbETaa3nyCJeGQRpd4IQ4NKob745mwDZ7jQBH8AZEng50Oh8y8fi8skBBBzaYp1ilgvzG740L7uex6fHV62myq0SXeCa+oJUjq326FU8y+Vsa32H8A3e7tOgXZPdt2TVNltx2S9H2WO8RMi7LfaSwARNfy1zu+bfR50r6ef8Yx5YKCMz4wWb1SHU1GS800mjOjlInLQORYRNMlSwR1+vLlVDciOqFapDSbj+YOVOawR0R1aqlSKpZkt33DuOBPx9qe6CVnIi7Z+Px/KqM+OLCzlLY/RS+LbxQpDWcfTVRiP+S5qRTcE3M3UioN/e0BE/1+MpX90IGpvVkA63ILYbKEa4bM3ASL7ChTCr6xN5XT+GpVJveFKK1cfNx9ExHI4rzYE= - -[attachment] -PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/attachments - -[mailer] -ENABLED = true -PROTOCOL = dummy -FROM = mssql-{{TEST_TYPE}}-test@gitea.io - -[service] -REGISTER_EMAIL_CONFIRM = false -REGISTER_MANUAL_CONFIRM = false -DISABLE_REGISTRATION = false -ENABLE_CAPTCHA = false -REQUIRE_SIGNIN_VIEW = false -DEFAULT_KEEP_EMAIL_PRIVATE = false -DEFAULT_ALLOW_CREATE_ORGANIZATION = true -NO_REPLY_ADDRESS = noreply.example.org -ENABLE_NOTIFY_MAIL = true - -[picture] -DISABLE_GRAVATAR = false -ENABLE_FEDERATED_AVATAR = false -AVATAR_UPLOAD_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/avatars -REPOSITORY_AVATAR_UPLOAD_PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/repo-avatars - -[session] -PROVIDER = file -PROVIDER_CONFIG = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/sessions - -[log] -MODE = {{TEST_LOGGER}} -ROOT_PATH = {{REPO_TEST_DIR}}mssql-log -ENABLE_SSH_LOG = true -logger.xorm.MODE = file - -[log.test] -LEVEL = Info -COLORIZE = true - -[log.file] -LEVEL = Debug - -[security] -PASSWORD_HASH_ALGO = argon2 -DISABLE_GIT_HOOKS = false -INSTALL_LOCK = true -SECRET_KEY = 9pCviYTWSb -INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ -DISABLE_QUERY_AUTH_TOKEN = true - -[lfs] -PATH = tests/{{TEST_TYPE}}/gitea-{{TEST_TYPE}}-mssql/data/lfs - -[packages] -ENABLED = true - -[actions] -ENABLED = true diff --git a/tests/test_utils.go b/tests/test_utils.go index 85d7462d73..af83f9027d 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -162,18 +162,6 @@ func InitTest(requireGitea bool) { log.Fatal("db.Exec: CREATE SCHEMA: %v", err) } } - - case setting.Database.Type.IsMSSQL(): - host, port := setting.ParseMSSQLHostPort(setting.Database.Host) - db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", - host, port, "master", setting.Database.User, setting.Database.Passwd)) - if err != nil { - log.Fatal("sql.Open: %v", err) - } - if _, err := db.Exec(fmt.Sprintf("If(db_id(N'%s') IS NULL) BEGIN CREATE DATABASE %s; END;", setting.Database.Name, setting.Database.Name)); err != nil { - log.Fatal("db.Exec: %v", err) - } - defer db.Close() } routers.InitWebInstalled(graceful.GetManager().HammerContext()) diff --git a/web_src/js/features/install.js b/web_src/js/features/install.js index 0c2246b933..897f5fb442 100644 --- a/web_src/js/features/install.js +++ b/web_src/js/features/install.js @@ -19,7 +19,6 @@ function initPreInstall() { const defaultDbHosts = { mysql: '127.0.0.1:3306', postgres: '127.0.0.1:5432', - mssql: '127.0.0.1:1433', }; const dbHost = document.getElementById('db_host');