mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-20 08:46:22 +00:00
feat: asociar rol con deploy nos permite acceder al token
This commit is contained in:
parent
6841945b39
commit
cdf0685c67
4 changed files with 25 additions and 2 deletions
|
@ -10,6 +10,8 @@ require 'open3'
|
||||||
# :attributes`.
|
# :attributes`.
|
||||||
class Deploy < ApplicationRecord
|
class Deploy < ApplicationRecord
|
||||||
belongs_to :site
|
belongs_to :site
|
||||||
|
belongs_to :rol
|
||||||
|
|
||||||
has_many :build_stats, dependent: :destroy
|
has_many :build_stats, dependent: :destroy
|
||||||
|
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Rol < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :usuarie
|
belongs_to :usuarie
|
||||||
belongs_to :site
|
belongs_to :site
|
||||||
|
has_many :deploys
|
||||||
|
|
||||||
validates_inclusion_of :rol, in: ROLES
|
validates_inclusion_of :rol, in: ROLES
|
||||||
|
|
||||||
|
|
18
db/migrate/20240216170202_add_rol_to_deploys.rb
Normal file
18
db/migrate/20240216170202_add_rol_to_deploys.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Establece una relación entre roles y deploys
|
||||||
|
class AddRolToDeploys < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
add_column :deploys, :rol_id, :integer, index: true
|
||||||
|
|
||||||
|
Deploy.find_each do |deploy|
|
||||||
|
rol_id = deploy.site.roles.find_by(rol: 'usuarie', temporal: false).id
|
||||||
|
|
||||||
|
deploy.update_column(:rol_id, rol_id) if rol_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :deploys, :rol_id
|
||||||
|
end
|
||||||
|
end
|
|
@ -759,7 +759,8 @@ CREATE TABLE public.deploys (
|
||||||
updated_at timestamp without time zone NOT NULL,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
site_id integer,
|
site_id integer,
|
||||||
type character varying,
|
type character varying,
|
||||||
"values" text
|
"values" text,
|
||||||
|
rol_id integer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2318,6 +2319,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20230731195050'),
|
('20230731195050'),
|
||||||
('20230829204127'),
|
('20230829204127'),
|
||||||
('20230921155401'),
|
('20230921155401'),
|
||||||
('20230927153926');
|
('20230927153926'),
|
||||||
|
('20240216170202');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue