UrlHum icon indicating copy to clipboard operation
UrlHum copied to clipboard

[Bug] SQLite Database Type no longer supported

Open michaellindahl opened this issue 3 years ago • 0 comments

Describe the bug Prior to the release that added the 2021_08_23_082401_increase_long_url_length migration, UrlHum worked great on installations that used SQLite. I've used this so that when deploying on shared hosting, the application doesn't have to make a network request to an external MySQL server and instead can just make a filesystem request. I understand under high loads this may be sub optional. It would be great if SQLite and MySQL could both be supported.

To Reproduce Run php artisan migrate. See:

Migrating: 2021_08_23_082401_increase_long_url_length

   Illuminate\Database\QueryException 

  SQLSTATE[HY000]: General error: 1 near "DROP": syntax error (SQL: ALTER TABLE `urls` DROP INDEX `urls_long_url_unique`;)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

  1   [internal]:0
      Illuminate\Database\Schema\Blueprint::__construct("urls", Object(Closure), "")

      +7 vendor frames 
  9   database/migrations/2021_08_23_082401_increase_long_url_length.php:17
      Illuminate\Support\Facades\Facade::__callStatic("statement")

Removing this line corrects it:

DB::statement('ALTER TABLE `urls` DROP INDEX `urls_long_url_unique`;');

But there is still this issue when visiting a page:

Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1 near "`short_url`": syntax error (SQL: select "urls".*, (select count(*) from "clicks" where "urls"."short_url" = "clicks"."short_url") as "clicks_count", (select count(*) from "clicks" where "urls"."short_url" = "clicks"."short_url" and "real_click" = 1) as "real_clicks_count", (select count(*) from "clicks" where "urls"."short_url" = "clicks"."short_url" and "created_at" >= 2022-06-12 05:52:15) as "today_clicks_count" from "urls" where BINARY `short_url` = wholesale limit 1)

michaellindahl avatar Jun 13 '22 05:06 michaellindahl