Skip to content

Commit

Permalink
Renamed column from user -> username …
Browse files Browse the repository at this point in the history
Renamed column from user -> username since it's a keyword in H2 v2
  • Loading branch information
skavanagh committed Jan 8, 2022
1 parent 4092346 commit 9532334
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 37 deletions.
79 changes: 51 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.bastillion</groupId>
<artifactId>bastillion-ec2</artifactId>
<version>1.75.03-SNAPSHOT</version>
<version>1.76.00</version>
<packaging>war</packaging>
<name>Bastillion for EC2</name>
<properties>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/bastillion/common/db/DBInitServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void init(ServletConfig config) throws ServletException {
statement.executeUpdate("create table if not exists user_theme (user_id INTEGER PRIMARY KEY, bg varchar(7), fg varchar(7), d1 varchar(7), d2 varchar(7), d3 varchar(7), d4 varchar(7), d5 varchar(7), d6 varchar(7), d7 varchar(7), d8 varchar(7), b1 varchar(7), b2 varchar(7), b3 varchar(7), b4 varchar(7), b5 varchar(7), b6 varchar(7), b7 varchar(7), b8 varchar(7), foreign key (user_id) references users(id) on delete cascade) ");
statement.executeUpdate("create table if not exists default_region (id INTEGER PRIMARY KEY AUTO_INCREMENT, region varchar not null)");
statement.executeUpdate("create table if not exists iam_role (id INTEGER PRIMARY KEY AUTO_INCREMENT, arn varchar not null)");
statement.executeUpdate("create table if not exists system (id INTEGER PRIMARY KEY AUTO_INCREMENT, display_nm varchar, instance_id varchar not null, \"user\" varchar not null, host varchar, port INTEGER not null, region varchar not null, state varchar, instance_status varchar, system_status varchar, m_alarm INTEGER default 0, m_insufficient_data INTEGER default 0, m_ok INTEGER default 0)");
statement.executeUpdate("create table if not exists system (id INTEGER PRIMARY KEY AUTO_INCREMENT, display_nm varchar, instance_id varchar not null, username varchar not null, host varchar, port INTEGER not null, region varchar not null, state varchar, instance_status varchar, system_status varchar, m_alarm INTEGER default 0, m_insufficient_data INTEGER default 0, m_ok INTEGER default 0)");
statement.executeUpdate("create table if not exists profiles (id INTEGER PRIMARY KEY AUTO_INCREMENT, nm varchar not null, tag varchar not null)");
statement.executeUpdate("create table if not exists user_map (user_id INTEGER, profile_id INTEGER, foreign key (user_id) references users(id) on delete cascade, foreign key (profile_id) references profiles(id) on delete cascade, primary key (user_id, profile_id))");
statement.executeUpdate("create table if not exists application_key (id INTEGER PRIMARY KEY AUTO_INCREMENT, public_key varchar not null, private_key varchar not null, passphrase varchar)");
Expand All @@ -105,7 +105,7 @@ public void init(ServletConfig config) throws ServletException {
statement.executeUpdate("create table if not exists scripts (id INTEGER PRIMARY KEY AUTO_INCREMENT, user_id INTEGER, display_nm varchar not null, script varchar not null, foreign key (user_id) references users(id) on delete cascade)");

statement.executeUpdate("create table if not exists session_log (id BIGINT PRIMARY KEY AUTO_INCREMENT, session_tm timestamp default CURRENT_TIMESTAMP, first_nm varchar, last_nm varchar, username varchar not null, ip_address varchar)");
statement.executeUpdate("create table if not exists terminal_log (session_id BIGINT, instance_id INTEGER, output varchar not null, log_tm timestamp default CURRENT_TIMESTAMP, display_nm varchar not null, \"user\" varchar not null, host varchar not null, port INTEGER not null, foreign key (session_id) references session_log(id) on delete cascade)");
statement.executeUpdate("create table if not exists terminal_log (session_id BIGINT, instance_id INTEGER, output varchar not null, log_tm timestamp default CURRENT_TIMESTAMP, display_nm varchar not null, username varchar not null, host varchar not null, port INTEGER not null, foreign key (session_id) references session_log(id) on delete cascade)");

//if exists readfile to set default password
String salt = EncryptionUtil.generateSalt();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/bastillion/manage/db/SessionAuditDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static void insertTerminalLog(Connection con, SessionOutput sessionOutput

if (sessionOutput != null && sessionOutput.getSessionId() != null && sessionOutput.getInstanceId() != null && sessionOutput.getOutput() != null && !sessionOutput.getOutput().toString().equals("")) {
//insert
PreparedStatement stmt = con.prepareStatement("insert into terminal_log (session_id, instance_id, display_nm, \"user\", host, port, output) values(?,?,?,?,?,?,?)");
PreparedStatement stmt = con.prepareStatement("insert into terminal_log (session_id, instance_id, display_nm, username, host, port, output) values(?,?,?,?,?,?,?)");
stmt.setLong(1, sessionOutput.getSessionId());
stmt.setLong(2, sessionOutput.getInstanceId());
stmt.setString(3, sessionOutput.getDisplayNm());
Expand Down Expand Up @@ -331,13 +331,13 @@ public static List<HostSystem> getHostSystemsForSession(Connection con, Long ses

List<HostSystem> hostSystemList = new ArrayList<>();
try {
PreparedStatement stmt = con.prepareStatement("select distinct instance_id, display_nm, \"user\", host, port from terminal_log where session_id=?");
PreparedStatement stmt = con.prepareStatement("select distinct instance_id, display_nm, username, host, port from terminal_log where session_id=?");
stmt.setLong(1, sessionId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
HostSystem hostSystem = new HostSystem();
hostSystem.setDisplayNm(rs.getString("display_nm"));
hostSystem.setUser(rs.getString("user"));
hostSystem.setUser(rs.getString("username"));
hostSystem.setHost(rs.getString("host"));
hostSystem.setPort(rs.getInt("port"));
hostSystem.setInstanceId(rs.getInt("instance_id"));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/bastillion/manage/db/SystemDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SystemDB {
private static Logger log = LoggerFactory.getLogger(SystemDB.class);

public static final String DISPLAY_NM = "display_nm";
public static final String USER = "user";
public static final String USER = "username";
public static final String HOST = "host";
public static final String PORT = "port";
public static final String INSTANCE_ID = "instance_id";
Expand Down Expand Up @@ -331,7 +331,7 @@ public static void insertSystem(Connection con, HostSystem hostSystem) {

try {

PreparedStatement stmt = con.prepareStatement("insert into system (display_nm, \"user\", host, port, instance_id, region, state, instance_status, system_status, m_alarm, m_insufficient_data, m_ok) values (?,?,?,?,?,?,?,?,?,?,?,?)");
PreparedStatement stmt = con.prepareStatement("insert into system (display_nm, username, host, port, instance_id, region, state, instance_status, system_status, m_alarm, m_insufficient_data, m_ok) values (?,?,?,?,?,?,?,?,?,?,?,?)");
stmt.setString(1, hostSystem.getDisplayNm());
stmt.setString(2, hostSystem.getUser());
stmt.setString(3, hostSystem.getHost());
Expand Down Expand Up @@ -389,7 +389,7 @@ public static void updateSystem(Connection con, HostSystem hostSystem) {

try {

PreparedStatement stmt = con.prepareStatement("update system set display_nm=?, \"user\"=?, host=?, port=?, instance_id=?, region=?, state=?, instance_status=?, system_status=?, m_alarm=?, m_insufficient_data=?, m_ok=? where id=?");
PreparedStatement stmt = con.prepareStatement("update system set display_nm=?, username=?, host=?, port=?, instance_id=?, region=?, state=?, instance_status=?, system_status=?, m_alarm=?, m_insufficient_data=?, m_ok=? where id=?");
stmt.setString(1, hostSystem.getDisplayNm());
stmt.setString(2, hostSystem.getUser());
stmt.setString(3, hostSystem.getHost());
Expand Down

0 comments on commit 9532334

Please sign in to comment.