How can I run a alembic upgrade in Azure Postgres - postgresql

I'm new into azure and wondering how to use Alembic to create my tables and keep track of modifications. In Heroku I could use the following command
heroku run "alembic upgrade head" --app APP-NAME
How to achieve the same in Azure?

Related

Heroku not automatically deploying changes

I'm having an issue where I can only deploy changes to heroku via a manual command.
I've already followed the guide and set up auto deployment through github https://devcenter.heroku.com/articles/github-integration but it seems like changes are not deployed to heroku unless I explicitly run git push heroku main
Is there anything I can do to check how to automate the push?
Automatic deploy with Heroku and Github is temporary stopped
https://dev.to/lukeecart/herokus-github-integration-has-been-stopped-a7c
Follow the news : https://status.heroku.com/

Prisma migrate dev: Run command while connected to DB?

Context: Our staging and production postgres databases are in a managed SQL service.
Is it recommended to create a local postgres database to run the command the npx prisma migrate dev?
Once the migration files are generated (as a result of running this command), we should then be able to run the npx prisma migrate deploy command on staging and prod environments.
You are correct. You should only be using npx prisma migrate dev in a local/development database. Once you are done with development and migrations have been created, you apply them to your staging/production database using npx prisma migrate deploy.
I would recommend checking out these two articles from the Prisma docs:
Prisma Migrate: Concept Guide
Deploying database changes with Prisma Migrate

How do build an Azure Devops Pipeline with Fluent Migrator task?

I have been using Fluent Migrator (version 3.2.1) for some time and in my Visual Studio environment I use dotnet-fm to migrate or rollback my migrations. This is all great but now I want to automate this and use Azure Devops Pipelines to run the migration commands but I don't know how and where to start.
Has anyone done this and could be kind enough to point me in the right direction, maybe with some examples. I would greatly appreciate it!
How do build an Azure Devops Pipeline with Fluent Migrator task?
Not sure if what I did is exactly what you want. You could check if the information below is helpful.
According to the document Quickstart of fluentmigrator:
Created a .net core library project and add the package FluentMigrator, FluentMigrator.Runner, FluentMigrator.Runner.SQLite, Microsoft.Data.Sqlite.
Create a file called 20180430_AddLogTable.cs.
Build the project.
Open a cmd window, switch path to the project folder, and then execute the command line:
dotnet tool install -g FluentMigrator.DotNet.Cli
After install the FluentMigrator.DotNet.Cli and execute the command line:
dotnet fm migrate -p sqlite -c "Data Source=test.db" -a ".\bin\Debug\netcoreapp2.1\test.dll"
It works fine on my local side.
Then, submit the solution to the Azure devops repo, create a pipeline with following tasks:
NuGet tool installer
NuGet Restore
Dotnet build
Command line task with following scripts:
cd $(Build.SourcesDirectory)/test/test
dotnet tool install -g FluentMigrator.DotNet.Cli
dotnet fm migrate -p sqlite -c "Data Source=test.db" -a ".\bin\Debug\netcoreapp2.1\test.dll"
It works the same:
Hope this helps.

GitLab start but stop right after

I have upgraded my version of GitLab to 5.3 and use Nginx instead of Apache. It worked one time and now I saw that GitLab stopped. So I try to re-start the service with this command sudo service gitlab start and watch what is happening with htop. I noticed that after 1 or 2 minutes the gitlab service stopped and I don't know why ...
I'm using a AWS EC2 micro instance.
How can I retrieve all my repositories on GitLab and import them to BitBucket (or GitHub) ?
Thank you.
Environment information
$ sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
System information
System: Ubuntu 12.04
Current User: git
Using RVM: no
Ruby Version: 1.9.3p327
Gem Version: 1.8.23
Bundler Version:1.2.3
Rake Version: 10.0.4
GitLab information
Version: 5.3.0
Revision: e1c473c
Directory: /home/git/gitlab
DB Adapter: mysql2
URL: https://domaine-name.com
HTTP Clone URL: https://domaine-name.com/some-project.git
SSH Clone URL: git#domaine-name.com:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 1.4.0
Repositories: /home/git/repositories/
Hooks: /home/git/gitlab-shell/hooks/
Git: /usr/bin/git
How can I retrieve all my repositories on GitLab and import them to BitBucket (or GitHub) ?
You can:
log on your AWS EC2 micro instance (like described in the Bitnami stack or following this installation blog post)
go to where the bare repos are stored (as mentioned in the gitlab.yml config file)
make a bundle for each one (see my answer on git bundle): that will generate one file per repo, which is easier to copy around
copy those bundle files on your local pc
clone those repos on your local pc (a bundle is an acceptable remote! git clone mybundle works)
add a remote to a GitHub empty repo you have declared first
push to GitHub

How to deploy heroku app with secret yaml configuration file without committing the file?

In other rails projects, I'd have a local database.yml and in source code repository only commit the database.sample file. When deploying, a capistrano script that would symlink a shared version of database.yml to all the releases.
When deploying to heroku, git is used and they seem to override database.yml altogether and do something internal.
That's all fine and good for database.yml, but what if I have s3 configurations in config/s3.yml. And I'm putting my project on github so I don't want to commit the s3.yml where everyone can see my credentials. It'd rather commit a sample s3.sample which people will override with their own settings, and keep a local s3.yml file uncommitted in my working directory.
what is the best way to handle this?
Heroku have some guidance on this -
http://devcenter.heroku.com/articles/config-vars
An alternative solution is to create a new local-branch where you modify .gitignore so secret-file can be pushed to heroku.
DON'T push this branch to your Github repo.
To push non-master branch to heroku, use:
git push heroku secret-branch:master
More info can be found on:
https://devcenter.heroku.com/articles/multiple-environments#advanced-linking-local-branches-to-remote-apps
Use heroku run bash and then ls to check whether your secret-file have been pushed on to heroku or not
Store the s3 credentials in environment variables.
$ cd myapp
$ heroku config:add S3_KEY=8N029N81 S3_SECRET=9s83109d3+583493190
Adding config vars:
S3_KEY => 8N029N81
S3_SECRET => 9s83109d3+583493190
Restarting app...done.
In your app:
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET']
)
See the Heroku Config Vars documentation which explain development setup etc.
If using Rails 4.1 beta, try the heroku_secrets gem, from https://github.com/alexpeattie/heroku_secrets:
gem 'heroku_secrets', github: 'alexpeattie/heroku_secrets'
This lets you store secret keys in Rails 4.1's config/secrets.yml (which is not checked in to source control) and then just run
rake heroku:secrets RAILS_ENV=production
to make its contents available to heroku (it parses your secrets.yml file and pushes everything in it to heroku as environment variables, per the heroku best practice docs).
You can also check out the Figaro gem.
I solved this by building the credentials from env variables during the build time, and write it to where I need it to be before the slug is created.
Some usecase specific info that you can probably translate to your situation:
I'm deploying a Node project, and in the package.json in the postinstall script I call "bash create-secret.sh". Since postinstall is performed before the slug is created, the file will be added to the slug.
I had to use a bash script because I had some trouble printing strings that contained newlines that had to be printed correctly, and I wasn't able to get it done with Node. Probably just me not being skilled enough, but maybe you run into a similar problem.
Looking into this with Heroku + Build & Deploy-time Secrets. It seems like it's not something Heroku supports. This means for a rails app, there is no way other than committing BUNDLE_GITHUB__COM for example to get from private repo.
I'll try to see if there is a way to have CI bundle private deps before beaming at heroku