planetscale_rails 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b6092e8239253b330f4864fa3388c9826c326493d8d585a47e8bcb310e7dce2
4
- data.tar.gz: b7457fdeb6ee47845266c63cd4baf13e80ee76746a121bf9644f3b5b9ad677c1
3
+ metadata.gz: a94c9bffa66e63c43ca885083022c938fd8d36f2b61f221b5a6b55456db04ec2
4
+ data.tar.gz: 48d42fccafd3a78f526e334f3db0579efe2f08dfbb7fb69f6d01dd5a9dfc2197
5
5
  SHA512:
6
- metadata.gz: f104e35e0864e821d6e885d9f0d5b7af5067c5bea40c69440b60c1fc3d7dea6ecd2bcf3aad11dae9a606ca1d7b8d649989bcd4633ec5f805ba68c90d7bbd5bfa
7
- data.tar.gz: 20aba5b8f3f8b9c7f15c0a95bc0f18bbea1a371258e293d1264599e91e015d6a721cb874594c8372cad990f9552dff724810fdaaeb867b0b223b961f1afe39a1
6
+ metadata.gz: b5fadeddff7396b8d6347c07549a24979e5766fc9207b140ed44ee055b1e1d73ed04966892052f440efe5f82d133c7fb7107a0bf7987739e2421d7f9d25fcead
7
+ data.tar.gz: cfe46c69ed1b3366c1ac3a98f8298c9c73e5e8213a6ff1dcc29dc16c4f675965ccd363b4e903342a2a6ee487c4fef18dc74f7746d39704ee75565977c8170f2f
data/README.md CHANGED
@@ -90,6 +90,15 @@ We recommend using GitHub Actions to automate the creation of PlanetScale branch
90
90
 
91
91
  If your application has minimal data and schema changes are a low risk event, then running `psdb:migrate` directly against production is perfectly fine. As your datasize grows and your application becomes busier, the risk of schema changes increase and we highly recommend using the deploy request flow. It's the best way available to safely migrate your schema.
92
92
 
93
+ ## How to safely drop a column
94
+
95
+ Before dropping the column in your database, there are a couple steps to take in your application to safely remove the column without any risk to your production application.
96
+
97
+ 1. Remove all references to the column in your code.
98
+ 2. Add the column name to `self.ignored_columns += %w(column_name)` in the model. [More on ignored_columns](https://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-ignored_columns-3D).
99
+ 3. Deploy this code to production. This ensures your application is no longer making use of the column in production and it's removed from the schema cache.
100
+ 4. Follow the PlanetScale deploy request flow to drop the column.
101
+
93
102
  ## Usage with GitHub Actions
94
103
 
95
104
  See the [GitHub Actions examples](actions-example.md) doc for ways to automate your schema migrations with PlanetScale + Actions.
@@ -7,8 +7,35 @@ require "colorize"
7
7
 
8
8
  databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml
9
9
 
10
+ def find_git_directory
11
+ return ENV["GIT_DIR"] if ENV["GIT_DIR"] && !ENV["GIT_DIR"].empty?
12
+
13
+ # it's not set as an env, so let's try to find it
14
+ current_path = Pathname.new(Dir.pwd)
15
+
16
+ until current_path.root?
17
+ git_dir = current_path.join(".git")
18
+ return current_path.to_s if git_dir.exist? # this can be a directory or a file (worktree)
19
+
20
+ current_path = current_path.parent
21
+ end
22
+
23
+ nil
24
+ end
25
+
26
+ def load_pscale_config
27
+ if File.exist?(".pscale.yml")
28
+ return YAML.load_file(".pscale.yml")
29
+ end
30
+
31
+ # otherwise, look for a git root directory and load it from there
32
+ git_dir = find_git_directory
33
+ pscale_yaml_path = File.join(git_dir, ".pscale.yml")
34
+ YAML.load_file(pscale_yaml_path)
35
+ end
36
+
10
37
  def puts_deploy_request_instructions
11
- ps_config = YAML.load_file(".pscale.yml")
38
+ ps_config = load_pscale_config
12
39
  database = ps_config["database"]
13
40
  branch = ps_config["branch"]
14
41
  org = ps_config["org"]
@@ -25,7 +52,7 @@ def delete_password
25
52
  password_id = ENV["PSCALE_PASSWORD_ID"]
26
53
  return unless password_id
27
54
 
28
- ps_config = YAML.load_file(".pscale.yml")
55
+ ps_config = load_pscale_config
29
56
  database = ps_config["database"]
30
57
  branch = ps_config["branch"]
31
58
 
@@ -56,7 +83,7 @@ namespace :psdb do
56
83
  end
57
84
 
58
85
  def create_connection_string
59
- ps_config = YAML.load_file(".pscale.yml")
86
+ ps_config = load_pscale_config
60
87
  database = ps_config["database"]
61
88
  branch = ps_config["branch"]
62
89
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlanetscaleRails
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: planetscale_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Coutermarsh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-01-15 00:00:00.000000000 Z
12
+ date: 2024-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize