Alembic revision --autogenerate で変更がなくても空のrevisionファイルができるのを避ける

はじめに Alembic revision –autogenerate で変更がなくても空のrevisionファイルができるのを避ける python 3.11, alembic 1.7.7, sqlalchemy 2.0.30, sqlmodel 0.0.18 問題 疑問 変更がなくても空のrevisionファイルが生成されてしまう まとめ 結果 解決方法 以下のような process_revision_directives を設定することで、差分がない場合は空のrevisionファイルを生成しない def run_migrations_online(): : def process_revision_directives(context, revision, directives): if config.cmd_opts.autogenerate: script = directives[0] if script.upgrade_ops.is_empty(): directives[:] = [] print('No changes in schema detected.') : with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata, include_schemas=True, dialect_opts={"paramstyle": "named"}, include_name=include_name, process_revision_directives=process_revision_directives, ) Refs python - How to prevent alembic revision –autogenerate from making revision file if it has not detected any changes?...

2024-07-04 ·  2024-08-02 · 1 分 · 81 文字

Alembic revision --autogenerate で差分のマイグレーションファイルができない

はじめに Alembic revision –autogenerate で差分のマイグレーションファイルができない python 3.11, alembic 1.7.7, sqlalchemy 2.0.30, sqlmodel 0.0.18 問題 毎回テーブル作成のマイグレーションファイルが生成されてしまう 解決方法 以下のような include_name を設定することで、デフォルトスキーマに限定する connection は schema 指定でアクセスしている為、type_=schema で name=None で検出される # exclude system table def include_name(name, type_, parent_names): if type_ == "schema": return name in [None] else: return True def run_migrations_online(): : with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata, dialect_opts={"paramstyle": "named"}, include_schemas=True, include_name=include_name, ) Refs python - Alembic revision –autogenerate always detects a new table, instead of detecting new columns - Stack Overflow

2024-07-04 ·  2024-08-02 · 1 分 · 79 文字

atmoz/sftp コンテナにログインするとハングする問題を解決する

問題 atmoz/sftp イメージを使用して、SFTPサーバを立ち上げた際に、 ログインすると長い間ハングして、放置していたらログインできていた、という事象が発生した 開発者間で、同じ問題が発生していた 考察 色々ググった結果、下記記事にたどり着いた linux - Excessive SFTP CPU usage with chroot enabled when using the official Docker repository - Unix & Linux Stack Exchange Debugging a 12 minute hang after SFTP login どうも コンテナで使用する system の リソース制限の問題のようだったので、 ulimits を設定することで解決した 解決方法 ulimits を設定する ulimits: nproc: 65535 nofile: soft: 26677 hard: 46677 docker compose の sftp コンテナの全体はこんな感じ sftp: platform: linux/x86_64 container_name: $app-sftp image: atmoz/sftp init: true ulimits: nproc: 65535 nofile: soft: 26677 hard: 46677 volumes: - ....

2024-06-24 ·  2024-08-02 · 1 分 · 110 文字

VSCode Remote Container で Hung する問題を解決する

はじめに VSCode の リモートコンテナ や dev container を使って開発したいときに、遭遇したエラーの対処法を少し 問題 疑問 リモートSSH機能で VSCode 開くと、terminal でHungする リモートコンテナにアタッチしたり、dev container を開くと、リモートを開いています から進まない どちらも、M1 Mac上で OrbStack 上で立ち上げた ArchLinux に接続しているときに発生した まとめ 結果 解決方法 VSCode から開く Terminal では Tmux は起動しない 以下設定で、VSCode から起動されているかどうかを判定し、Tmux を起動するかどうかを切り替える is_vscode() { [[ -n $VSCODE_INJECTION ]]; } 拡張機能のシグニチャ検証を無効化、もしくは、ローカルから拡張機能をインストールする設定を有効にする dev container の場合は、拡張機能のシグニチャ検証を無効化 { // Configure tool-specific properties. "customizations": { "vscode": { "settings": { // Workaround for x86_64 containers on aarch64(like M1 Mac) hosts // see: https://zenn....

2024-05-23 ·  2024-08-02 · 1 分 · 141 文字

cordova build 時に GoogleService-Info.plist, google-services.json を自動切替する

はじめに cordova プロジェクト(monaca)でFCMを使う際、開発環境と本番環境で GoogleService-Info.plist, google-services.json を自動で切り替えたい 正確には google-services.json は複数環境入れるが、今回は必要であった 問題 以下ファイルを用意した、ビルド時に自動で切り替えたい 正確には _dev, _prd の無いファイルを作成したい google-services_dev.json google-services_prd.json GoogleService-Info_dev.plist GoogleService-Info_prd.plist 解決方法 cordova hook でビルド時に自動で切り替える 以下スクリプトを作成したので記載. scripts/before_build に配置する #!/usr/bin/env -S bash -e script_dir=$(cd "$(dirname "${BASH_SOURCE:-$0}")" && pwd) && readonly script_dir project_root=$(cd "${script_dir}/.." && pwd) && readonly project_root config_file="${project_root}/config.xml" && readonly config_file get_stage() { grep 'name="STAGE"' "$config_file" | sed -E 's/.*value="([^"]*)".*/\1/' } update_firebase_config() { local append=_prd if [[ $stage == "dev" ]]; then append=_dev fi echo "===> Updating firebase config files" 1>&2 cp -fv "$project_root"/GoogleService-Info${append}....

2024-04-25 ·  2024-04-25 · 1 分 · 121 文字