mirror of https://github.com/usememos/memos.git
feat(store): change default storage type to local filesystem
Add migration scripts for existing instances without a storage setting to explicitly preserve DATABASE as their storage type, ensuring backward compatibility. Change the default for new installations to LOCAL to improve out-of-the-box performance.
This commit is contained in:
parent
026ea92f7b
commit
78efa6802e
|
|
@ -169,7 +169,7 @@ func (s *Store) GetInstanceMemoRelatedSetting(ctx context.Context) (*storepb.Ins
|
|||
}
|
||||
|
||||
const (
|
||||
defaultInstanceStorageType = storepb.InstanceStorageSetting_DATABASE
|
||||
defaultInstanceStorageType = storepb.InstanceStorageSetting_LOCAL
|
||||
defaultInstanceUploadSizeLimitMb = 30
|
||||
defaultInstanceFilepathTemplate = "assets/{timestamp}_{filename}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
-- Set storage type to DATABASE for existing instances that have no storage setting configured.
|
||||
-- This preserves backward-compatible behavior before the default was changed to LOCAL.
|
||||
INSERT INTO system_setting (name, value, description)
|
||||
SELECT 'STORAGE', '{"storageType":"DATABASE"}', ''
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM system_setting WHERE name = 'STORAGE');
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- Set storage type to DATABASE for existing instances that have no storage setting configured.
|
||||
-- This preserves backward-compatible behavior before the default was changed to LOCAL.
|
||||
INSERT INTO system_setting (name, value, description)
|
||||
SELECT 'STORAGE', '{"storageType":"DATABASE"}', ''
|
||||
WHERE NOT EXISTS (SELECT 1 FROM system_setting WHERE name = 'STORAGE');
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
-- Set storage type to DATABASE for existing instances that have no storage setting configured.
|
||||
-- This preserves backward-compatible behavior before the default was changed to LOCAL.
|
||||
INSERT INTO system_setting (name, value, description)
|
||||
SELECT 'STORAGE', '{"storageType":"DATABASE"}', ''
|
||||
WHERE NOT EXISTS (SELECT 1 FROM system_setting WHERE name = 'STORAGE');
|
||||
|
|
@ -193,7 +193,7 @@ func TestInstanceSettingStorageSetting(t *testing.T) {
|
|||
storageSetting, err := ts.GetInstanceStorageSetting(ctx)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, storageSetting)
|
||||
require.Equal(t, storepb.InstanceStorageSetting_DATABASE, storageSetting.StorageType)
|
||||
require.Equal(t, storepb.InstanceStorageSetting_LOCAL, storageSetting.StorageType)
|
||||
require.Equal(t, int64(30), storageSetting.UploadSizeLimitMb)
|
||||
require.Equal(t, "assets/{timestamp}_{filename}", storageSetting.FilepathTemplate)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue