蜂巢3.0(原 素材管理器)開發筆記

建立遷移

使用包管理控制檯

Add-Migration 遷移名稱

(比如 Add-Migration DatabaseInformation_Extension)

在Program處,服務啓動之前添加調用函數

private static void CreateDbIfNotExists(IHost host)
{
	using var scope = host.Services.CreateScope();
	var services = scope.ServiceProvider;
	using var context = scope.ServiceProvider.GetRequiredService<BeeNetContext>();
	context.Database.Migrate();
}

服務器啓動時候會自動完成遷移。

SQLite - SQLite 侷限性 - 《微軟 EntityFrameworkCore 中文文檔》 - 書棧網 · BookStack
https://www.bookstack.cn/read/Microsoft.EntityFrameworkCore.Docs.zh-Hans/7%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93%E6%8F%90%E4%BE%9B%E7%A8%8B%E5%BA%8F-C%E3%80%81SQLite-B%E3%80%81SQLite%E5%B1%80%E9%99%90%E6%80%A7.md

關於SQLite不支持遷移的問題可以查看一下:

// UNDONE: Not supported by SQLite
//migrationBuilder.AlterColumn<string>(
//    name: "Title",
//    table: "Posts",
//    nullable: false,
//    oldClrType: typeof(string),
//    oldType: "TEXT",
//    oldNullable: true);

// Create a new table with the desired schema
// TODO: Randomize the name to avoid conflicts
migrationBuilder.CreateTable(
    name: "new_Posts",
    columns: table => new
    {
        Id = table.Column<int>(nullable: false)
            .Annotation("Sqlite:Autoincrement", true),
        Title = table.Column<string>(nullable: false)
    },
    constraints: table =>
    {
        table.PrimaryKey("PK_Posts", x => x.Id);
    });

// Copy data from the old table. Use NULLIF to specify a default value for newly
// required columns
migrationBuilder.Sql(@"
    INSERT INTO new_Posts (Id, Title)
    SELECT Id, IFNULL(Title, '')
    FROM Posts;
");

// Suspend foreign key enforcement during the swap
// TODO: Can't do this on SQL Server. Would need to rebuild referencing foreign
// keys there. But do we even need table rebuilds on SQL Server? Changing
// IDENTITY only requires a column rebuild
// NB: This commits the current transaction. We can't rollback the migration if
// anything after this fails. Maybe we can turn this off before the migration
// and somehow use PRAGMA foreign_key_check. Otherwise, we can mitigate it by
// doing rebuilds as late as possible
migrationBuilder.Sql("PRAGMA foreign_keys = 0;", suppressTransaction: true);

// Swap in the new table
migrationBuilder.DropTable(
    name: "Posts");
migrationBuilder.RenameTable(
    name: "new_Posts",
    newName: "Posts");

// TODO: We shouldn't do this if foreign key enforcement was off to begin with.
// There's no way to handle this in SQL, so we probably need a way to configure
// this. Maybe we can do this as a post migration step--the migration wouldn't
// fail, but you'd at least get an error if you compromised referential
// integrity
migrationBuilder.Sql("PRAGMA foreign_keys = 1;", suppressTransaction: true);

// Rebuild any indexes
migrationBuilder.CreateIndex(
    name: "IX_Posts_Title",
    table: "Posts",
    column: "Title");

NAT穿透問題

vue初始化項目一直停在downloading template

網絡上說用GIT Bash。我使用Git CMD也是可以解決這個問題。

使用electron-vue出現問題:

Html Webpack Plugin:

ReferenceError: process is not defined

Experiencing the same issue on Node 12.2.0. Not sure what causes it, and not entirely convinced the issue is in this repo. Probably a dependency. Removing parts from the template will work for npm run dev, but not so much for npm run build or npm run pack.
My temporary solution was to do modify HtmlWebpackPlugin in .electron-vue/webpack.web.config.js and .electron-vue/webpack.renderer.config.js:

new HtmlWebpackPlugin({
      filename: 'index.html',
      template: path.resolve(__dirname, '../src/index.ejs'),
      templateParameters(compilation, assets, options) {
        return {
          compilation: compilation,
          webpack: compilation.getStats().toJson(),
          webpackConfig: compilation.options,
          htmlWebpackPlugin: {
            files: assets,
            options: options
          },
          process,
        };
      },
      minify: {
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        removeComments: true
      },
      nodeModules: false
    }),

解決方案來源:https://github.com/SimulatedGREG/electron-vue/issues/871

Electron卡在building fresh packages過程

我這裏使用的爲yarn工具

在.yarnrc(位置爲C:\Users\{當前用戶名})

添加一下內容

ELECTRON_MIRROR "https://npm.taobao.org/mirrors/electron/"

registry "https://registry.npm.taobao.org"

sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"

結果82s就完成了。

webstorm格式化代碼與eslint不一致

規則衝突,遵循ESLint設置

webstorm 設置頁面->Editor->Code Style
裏面的JavaScript右上有一個set from ,
設置成想要的風格
然後HTML裏面Other選項卡里面有個Do not indent children of ,加一個script,然後保存格式化。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章