Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for SQLite #3984

Open
wants to merge 17 commits into
base: 2.x
Choose a base branch
from
Open

feat: add support for SQLite #3984

wants to merge 17 commits into from

Conversation

SychO9
Copy link
Member

@SychO9 SychO9 commented May 3, 2024

Part of the roadmap

Changes proposed in this pull request:
Adds support for installing and using Flarum with SQLite 3.8.8+

While it is trivial to support it from core (apart from a couple exceptions where queries needed to be adapted), whether third party extensions will work with sqlite is a different matter. So I've added a warning about that on the installation page.

Screenshot
image
image

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)
  • Related core extension PRs: (Remove if irrelevant)

@SychO9 SychO9 requested a review from a team as a code owner May 3, 2024 11:02
@SychO9 SychO9 added this to the 2.0 milestone May 3, 2024
@SychO9 SychO9 self-assigned this May 3, 2024
@SychO9 SychO9 changed the title feat: add support for sqlite feat: add support for SQLite May 3, 2024
Copy link
Sponsor Member

@askvortsov1 askvortsov1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still a bit worried that people using sqlite will disregard the warning, and worry why their queries are erroring. Is it possible to catch syntax errors, and in the error message, flag use of sqllite as a possible culprit?

throw new InvalidArgumentException('Only MySQL connections are supported');
$doctrine = $connection->getDoctrineConnection()->getDatabasePlatform();

if (! Type::hasType('timestamp')) {
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member Author

@SychO9 SychO9 May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes timestamp columns on sqlite migrations. (fails with an error otherwise)

$pdo = (new MySqlConnector)->connect($config);

$version = $pdo->query('SELECT VERSION()')->fetchColumn();

if (Str::contains($version, 'MariaDB')) {
if (version_compare($version, '10.0.5', '<')) {
if (version_compare($version, '10.10.0', '<')) {
throw new RangeException('MariaDB version too low. You need at least MariaDB 10.0.5');
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this message be adjusted to match the code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in the pgsql branch

@SychO9
Copy link
Member Author

SychO9 commented May 9, 2024

is it possible to catch syntax errors, and in the error message, flag use of sqllite as a possible culprit?

Done in the pgsql branch

image

Copy link

@jaggy jaggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work on the PR!

In regards to extensions, I wonder if we can add some sort of support for database support in the composer.json in extra.flarum-extension or some config so it's easier to show extension compatibility. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants