generated from insum-labs/starter-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_release.sql
147 lines (106 loc) · 3.52 KB
/
_release.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
-- If you want to add ASCII Art: https://asciiartgen.now.sh/?style=standard
-- *** DO NOT MODIFY: HEADER SECTION ***
clear screen
whenever sqlerror exit sql.sqlcode
prompt loading environment variables
@load_env_vars.sql
-- define - Sets the character used to prefix substitution variables
-- Note: if you change this you need to modify every reference of it in this file and any referring files
-- set define '&'
-- verify off prevents the old/new substitution message
set verify off
-- feedback - Displays the number of records returned by a script ON=1
set feedback on
-- timing - Displays the time that commands take to complete
set timing on
-- display dbms_output messages
set serveroutput on
-- disables blank lines in code
set sqlblanklines off;
-- Log output of release
define logname = '' -- Name of the log file
set termout on
column my_logname new_val logname
select 'release_log_'||sys_context( 'userenv', 'service_name' )|| '_' || to_char(sysdate, 'YYYY-MM-DD_HH24-MI-SS')||'.log' my_logname from dual;
-- good to clear column names when done with them
column my_logname clear
set termout on
spool &logname
prompt Log File: &logname
prompt check DB user is expected user
declare
begin
if user != '&env_schema_name' or '&env_schema_name' is null then
raise_application_error(-20001, 'Must be run as &env_schema_name');
end if;
end;
/
-- Disable APEX apps
@../scripts/apex_disable.sql &env_apex_app_ids
-- *** END: HEADER SECTION ***
-- *** Release specific tasks ***
@code/_run_code.sql
-- *** DO NOT MODIFY BELOW ***
-- Views and packages will be automatically referenced in the files below
-- Can generate these files from the build script
-- Search for "list_all_files"
@all_views.sql
@all_packages.sql
prompt Invalid objects
select object_name, object_type
from user_objects
where status != 'VALID'
order by object_name
;
-- *** DATA ****
-- Autogenerated triggers
-- If you have code to automatically generate triggers this is a good place to run in.
-- An example of what it might look like:
-- declare
-- begin
-- pkg_util.gen_triggers()
-- end;
-- /
-- Load any re-runnable data scripts
@all_data.sql
-- This needs to be in place after trigger generation as some triggers follow the generated triggers above
prompt recompile invalid schema objects
begin
dbms_utility.compile_schema(schema => user, compile_all => false);
end;
/
-- *** APEX ***
-- Install all apex applications
@all_apex.sql
-- Control Build Options (optional)
-- In some cases you may want to enable / disable various build options for an application depending on the environment
-- An example is provided below on how to enabled a build option
PROMPT *** APEX Build option ***
-- set serveroutput on size unlimited;
-- declare
-- c_app_id constant apex_applications.application_id%type := CHANGEME_APPLICATION_ID;
-- c_username constant varchar2(30) := user;
-- l_build_option_id apex_application_build_options.build_option_id%type;
-- begin
-- if pkg_environment.is_dev() then
-- select build_option_id
-- into l_build_option_id
-- from apex_application_build_options
-- where 1=1
-- and application_id = c_app_id
-- and build_option_name='DEV_ONLY';
-- -- Session is already active ahead
-- apex_session.create_session (
-- p_app_id => c_app_id,
-- p_page_id => 1,
-- p_username => c_username );
-- apex_util.set_build_option_status(
-- p_application_id => c_app_id,
-- p_id => l_build_option_id,
-- p_build_status=>'INCLUDE');
-- end if;
-- end;
-- /
-- commit;
spool off
exit