mirror of
https://github.com/czhu12/canine.git
synced 2025-12-19 17:59:53 -06:00
merged
This commit is contained in:
20
db/migrate/20251102192149_create_build_packs.rb
Normal file
20
db/migrate/20251102192149_create_build_packs.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class CreateBuildPacks < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
create_table :build_packs do |t|
|
||||
t.references :build_configuration, null: false, foreign_key: true
|
||||
t.integer :reference_type, null: false # registry, docker, git, url, path
|
||||
t.string :namespace # for registry buildpacks
|
||||
t.string :name # for registry buildpacks
|
||||
t.string :version
|
||||
t.integer :build_order, null: false
|
||||
t.text :uri # for git, url, path, or docker references
|
||||
t.jsonb :details, default: {}
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :build_packs, [ :build_configuration_id, :reference_type, :namespace, :name ], name: 'index_build_packs_on_config_type_namespace_name'
|
||||
add_index :build_packs, [ :build_configuration_id, :uri ], name: 'index_build_packs_on_config_uri'
|
||||
add_column :build_configurations, :buildpack_base_builder, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,49 @@
|
||||
class MoveDockerFieldsFromProjectToBuildConfiguration < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
# Add build fields to build_configurations (excluding docker_command which is used at runtime)
|
||||
add_column :build_configurations, :context_directory, :string, default: "./", null: false
|
||||
add_column :build_configurations, :dockerfile_path, :string, default: "./Dockerfile", null: false
|
||||
add_column :build_configurations, :build_type, :integer
|
||||
|
||||
# Backfill data from projects to build_configurations
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
Project.reset_column_information
|
||||
BuildConfiguration.reset_column_information
|
||||
|
||||
Project.find_each do |project|
|
||||
# Create build_configuration if it doesn't exist
|
||||
if project.build_configuration.nil?
|
||||
# Skip projects that don't have the required associations
|
||||
next unless project.project_credential_provider.present?
|
||||
|
||||
BuildConfiguration.create!(
|
||||
project: project,
|
||||
provider: project.project_credential_provider.provider,
|
||||
driver: BuildConfiguration::DEFAULT_BUILDER,
|
||||
image_repository: project.repository_url,
|
||||
context_directory: project.docker_build_context_directory,
|
||||
dockerfile_path: project.dockerfile_path,
|
||||
build_type: :dockerfile,
|
||||
)
|
||||
else
|
||||
# Update existing build_configuration
|
||||
project.build_configuration.update!(
|
||||
context_directory: project.docker_build_context_directory,
|
||||
dockerfile_path: project.dockerfile_path,
|
||||
build_type: :dockerfile,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
change_column_null :build_configurations, :build_type, false
|
||||
end
|
||||
|
||||
def down
|
||||
# Remove build fields from build_configurations
|
||||
remove_column :build_configurations, :context_directory
|
||||
remove_column :build_configurations, :dockerfile_path
|
||||
remove_column :build_configurations, :build_type
|
||||
end
|
||||
end
|
||||
4
db/schema.rb
generated
4
db/schema.rb
generated
@@ -10,7 +10,11 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
<<<<<<< HEAD
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_11_10_152921) do
|
||||
=======
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_11_03_000229) do
|
||||
>>>>>>> main
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user